I have coded the translation algorithm mentioned in the earlier, included message. I 
am getting an error.
The line:

        <cfset label = Application.langlabels[currentlanguage]> 

Is getting the error:

The expression specifying dimension 1 of the object Application.langlabels is not an 
integer expression. Only integer expressions can be used to index objects.

This is on a struct, so why would it not allow me to use a string value as an index?
Can anyone see what I am doing wrong? Code below: (sorry if my email program ruins my 
tabbing)
I've tried it with and without the commented parts.

The data structure should look like this:

Application.langlabels.en[ labelname ] = "Englishvalue"
Application.langlabels.fr[ labelname ] = "Frenchvalue"
...and so on...

<!--- from Application.cfm --->
<!--- Load multilingual values ONCE ---> 
<cfif NOT IsDefined("Application.langlabels")> 
<cfquery name="dbLangLabels" datasource= #SCDSN#> 
        select language, labelname, value from LangLabels 
</cfquery> 
<cflock scope="Application" type="Exclusive" timeout=60> 
        <cfset Application.langlabels = StructNew()> 
        <!--- Tried with & without this:
        <cfset Application.langlabels['en'] = StructNew()>
        <cfset Application.langlabels['fr'] = StructNew()>
        --->
        <cfloop query="dbLangLabels"> 
                <!--- tried with and witthout this:
                <cfif NOT StructKeyExists( Application.langlabels, 
dbLangLabels.language)> 
                        <cfset Application.langlabels[dbLangLabels.language] = 
StructNew()> 
                </cfif>
                --->
                <cfset 
Application.langlabels[dbLangLabels.language][dbLangLabels.labelname] 
                        = dbLangLabels.value> 
        </cfloop> 
</cflock> 
</cfif>

<!--- for every page, load local variable with appropriate language values ---> 
<cflock scope='Session' timeout=30 type="Exclusive"> 
        <cfparam name="Session.currentlanguage" default="en"> 
        <cfset variables.currentlanguage = Session.currentlanguage> 
</cflock> 
<!--- <cfset label = StructNew()> ??? ---> 
<cflock scope='Application' timeout=30 type="ReadOnly"> 
        <cfset label = Application.langlabels[currentlanguage]> 
        <!--- ERROR OCCURS HERE ^^^^^ --->
</cflock>

<!--- throughout page access labels like this: #label.lblname# --->



At 01:15 AM 8/5/00 -0400, Peter Theobald wrote:
>Dan, I hope you dont mind I decided to share this with the list...
>
>Please tell me how you are currently doing it, as I'd like to hear everything on the 
>topic.
>
>We were originally just doing the site in English and French, and planned to have two 
>completely parallel versions of the site. UGH! What a pain to maintain. We were 
>spending all our time putting changes into both versions of the page. Now we are 
>doing English, French, German, Italian, and Spanish so it is out of the question to 
>maintain 5 parallel sites!
>
>We needed a way to efficiently substitute the appropriate text in whichever language, 
>and to maintain the lists of text.
>We looked at XML/XSL (too complex), we looked at having database queries pull each 
>and every label out (too slow).
>
>We finally decided to put every single label and text in the entire site into 
>variables in a structure, and encase the entire page in one long <CFOUTPUT> do to the 
>substitution (instead of hundreds of little <CFOUTPUT>s).
>Originally we were going to INCLUDE a file with:
>
><CFSCRIPT>
>enlabel.welcome = "Welcome";
>delabel.welcome = "Velkommen";
>frlabel.welcome = "Bienvenue";
>
>and so on...
>
>But after the great help of people on the CFTALK list I learned a few things about 
>scoping variables. Now I can store all the values in the database for great 
>maintainability and put the values into an Application scoped variable that only gets 
>loaded once.
>
>table multilingual
>        language char[2]
>        labelname char[15]
>        value varchar[1000]
>
>We will build appropriate admin pages, and an import facility from EXCEL files.
>
>Now, in the Application.cfm file we do ONE initial load into an Application scope 
>variable (or a Server scope variable - what is the difference??) that is only 
>executed ONCE like so:
>
>// Load all multilingual values ONCE
>If (NOT IsDefined("Application.langlabels")) {
>        query all rows from multilingual
>        lock application
>        application.langlabels = new array (two dimensional hash/struct)
>        loop for all rows {
>                application.langlabels[language][labelname] = value;
>                application.langlabels['db'][labelname] = labelname; // for debugging 
>language 'db' will show labels on page
>                }
>        unlock application
>        }
>
>// for every page, load local variable with appropriate language values (to avoid 
>locking every access)
>readonly lock application
> label = new array (one dimensional hash/struct)
> label = langlabels[session.currentlanguage]
>unlock
>
>---------------
>Now in each page I put <CFOUTPUT> at the top and </CFOUTPUT> at the bottom.
>I got rid of all my old plain <CFOUTPUT>s
>I fixed all my db query <CFOUTPUT QUERY='queryname'> to </CFOUTPUT><CFOUTPUT 
>QUERY='queryname'>
>        and </CFOUTPUT> to </CFOUTPUT><CFOUTPUT>
>I did this because you can't nest CFOUTPUT blocks :-(
>I fixed all # to ##
>And I pulled out all English text and replaced it with #label.varname#
>
>Phwew....
>Pulling out all the English text is a big job and we're not done yet. I'll let you 
>know how it works!
>
>                
>
>At 03:27 PM 8/4/00 -0700, Dan Haley wrote:
>>I'd love to hear more on how you are doing translations . . . we are
>>embarking on a rebuild of both the front-end and the back-end of our website
>>and we need to come up with a better way of handling translations.  Let me
>>know if you'd rather I call you and I can do that too.  I'm PST in the US.
>>
>>Thanks,
>>Dan Haley
>>Telect, Inc. 
>
>
>---------------------------------------------------------------------------
>Peter Theobald, Chief Technology Officer
>LiquidStreaming http://www.liquidstreaming.com
>[EMAIL PROTECTED]
>Phone 1.212.545.1232 Fax 1.212.679.8032


---------------------------------------------------------------------------
Peter Theobald, Chief Technology Officer
LiquidStreaming http://www.liquidstreaming.com
[EMAIL PROTECTED]
Phone 1.212.545.1232 Fax 1.212.679.8032

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to