Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
?
275 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

618 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