First off, my system in its present iteration doesn't try to translate on its own.  
Thats left up to humans.  And further it doesn't try to synch up various versions of 
content (i.e. the German, Dutch, French and English versions of Page Foo must all be 
updated before they can be published as a group)... but its been requested and might 
be a reality by the time I get around to a release.

What it does do is translate the system itself: the admin side and anything public 
thats system-related.

We wound up taking the advice of a user and put together a system that is 
extraordinarily simple and *fast*.  I had to see it demo'd to be won over, as I had no 
confidence in keeping it outside of a db.  

It pulls a text file which contains a struct (where the delimiter is the equal sign).  
This is then put onto the page as query output.  There is one text file per cf 
template, and the files are named to match their cf 'parents'.

CF processes this so fast I was astonished.  20ms is average, and its not uncommon to 
get times so fast the reading is 0ms in the debugger.

So for example admin.txt goes with admin.cfm, and an excerpt from the English and 
French versions looks like this:

Sorry=Sorry
Message1=The retry count was exceeded and a lockout is currently in effect.

vs. 

Sorry=D�sol�
Message1=Le nombre d'essais a �t� d�pass� et le verrouillage est toujours actif.

This calls the file (as an include its faster than a tag)
<cfset variables.dictLoad_TheFile="admin">
<cfinclude template="includes/inc_dictload.cfm">

This is the 'dictionary' loader:

<cffile 
        action="read"
        
file="#GetDirectoryFromPath(ExpandPath("*.*"))#lang\#client.dictLoad_Language#\#variables.dictLoad_TheFile#.txt"
        variable="DictList">
<cfset "#variables.dictLoad_TheFile#"=StructNew()>
<cfloop 
        list="#DictList#" 
        index="DictRow" 
        delimiters="#chr(13)##chr(10)#">
        <cfset variables.TheKey=listGetAt(DictRow,1,"=")>
        <cfset variables.TheValue=listGetAt(DictRow,2,"=")>             
        <cfset 
variables.temp=StructInsert(Evaluate(variables.dictLoad_TheFile),variables.TheKey,variables.TheValue)>
</cfloop>

And this would be the typical output:
<cfoutput>#admin.Sorry#<br>#admin.Message1#</cfoutput>

The way the system is presently designed the user can switch languages at a mouse 
click, hence the client variable housing the language presently in use.

Its simple if tedious to create a new language set.  The one drawback I expect will 
only be solved via database is the duplication of terms (i.e. each template has a 
'BACK' translation, and a 'WARNING' and so on.  If it becoes an obstacle probably can 
only truly be fixed with a db with a unique index on the phrase itself.



--
-------------------------------------------
 Matt Robertson,     [EMAIL PROTECTED]
 MSB Designs, Inc. http://mysecretbase.com
-------------------------------------------

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to