?
Solved

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

Posted on 2009-07-07
3
Medium Priority
?
274 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

777 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