Solved

replacing tags and html easy to read tags for nice db storage and user friendly tranlation

Posted on 2009-07-07
3
267 Views
Last Modified: 2013-12-24
we're building a site in several languages and store a good part of the text in tables in sql server. Sometime we store whole blocks with a little too much code. I am trying to find a way to best separate code from text so when we give the text to translate the people translating the text aren't confused by the code and don't have to worry (too much) about not touching the code.

How could I do this to minimize code store in tables?

eg this is code we store in a table right now:
<p><span class="boldtext">Hey: </span>this is a small test</p>
<p>&nbsp;</p>
<p>I hope you don't run over the code <p>
<p>&nbsp;</p>
<p>&nbsp;</p>

what I would like to store is something like this:
{1}Hey: {2} this is a small test{3}I hope you don't run over the code {4}
In the .cfm I could then somehow call the string and replace the {1} with the code

I'm sure there is a technique for this sort of thing.
0
Comment
Question by:Shawn
  • 2
3 Comments
 
LVL 13

Expert Comment

by:srikanthmadishetti
ID: 24801056
I don' think there is an inbuilt stuff for this ,
Writting a regular epxression is the only solution i think so .

or an logic like list with delimeter </p> then from the taken string you can try to remove the left 3 characters which is <p> and take the remaining string.



0
 
LVL 1

Author Comment

by:Shawn
ID: 24804241
not quite sure if that would work with all of the fields shown above. It might be though a question fo a structured search and replace. Still not quite sure how to approch this.
0
 
LVL 1

Accepted Solution

by:
Shawn earned 0 total points
ID: 25337815
I found a rather simple solution just using replacenocase. I set them up on a file called dsp_format_vars.cfm and include it whenever I need it. Works great and keeps it simple. Code below is an example.
<cfset var = "{4}{1}Hey: {/1} this is a small test. I hope you don't run over the code{5}">
 

<cfset var = replacenocase(var,"{1}", "<span class=""boldtext"">", "all")> 

<cfset var = replacenocase(var,"{/1}", "</span>", "all")> 

<cfset var = replacenocase(var,"{4}", "<p>", "all")> 

<cfset var = replacenocase(var,"{5}", "</p>", "all")> 
 

<cfoutput>

<p>#var#</p>

</CFOUTPUT> 

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now