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
Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
OpenLDAP set password to expire 7 694
Use System DSN 6 88
Finding an Azure real-time monitoring dashboard 2 74
Web server settings related to keepalive 1 126
A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 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