Solved

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

Posted on 2009-07-07
3
272 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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

687 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