I'll try and take a stab at your question, with regard to a very basic
type of resource bundle. I'm sure there's much more to this but here's
how my CMPro cms handles it:
First of all, all text that a user sees in the site has to be a variable
in your code, so you never write a template that says
<a href="" Here</a>
Instead you write
<cfoutput><a href="">
Assuming the template's name is admin.cfm. More on that: each CF
template has a corresponding 'dictionary' file dedicated to it, which
has the same name. (i.e. admin.cfm is the CF template and admin.txt is
its dictionary). The collection of all of these files are grouped
according to language in a dedicated folder, so I have a folder called
/lang/english/, another called /lang/chinese/ and so on.
At the top of each CF template (that needs it) I have a statement like
this:
<cfset variables.dictionary_TheFile="admin">
<cfinclude template="inc/load_dictionary.cfm">
The include file looks like this:
<cfprocessingdirective pageEncoding="utf-8">
<cffile
action="">
file="#request.thePath#lang\#client.dictionary_PickedLanguage#\#variable
s.dictionary_TheFile#.txt"
variable="DictList">
<cfset "#variables.dictionary_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.dictionary_TheFile),varia
bles.TheKey,variables.TheValue)>
</cfloop>
And it is reading a plain text file that is set up in a variable=value
format, like this:
ClickHere=Click Here
ErrorMsg01=Invalid Value Specified
GoBack=Go Back
In the include, Request.thePath is the physical path to the web root.
#client.dictionary_PickedLanguage# is the user-specified language, and
this value matches the folder name (i.e. English). I let the user pick
the language rather than auto-sensing it, but you can do whatever you
like.
So this include produces a struct that you then use for all text output
that would otherwise be in a fixed language.
The performance impact of doing this is miniscule. Barely noticeable.
This is largely because the text files are so small. In some cases you
may opt to combine the text from multiple templates, or all of them. I
went for a template-by-template approach rather than a global dictionary
for admin reasons. Doing a single global template would be more
efficient in some ways. I'd like to hear about better ways to do this
myself as maintenance is an ongoing issue I'd like to minimize.
HtH,
--------------------------------------------
Matt Robertson [EMAIL PROTECTED]
MSB Designs, Inc. http://mysecretbase.com
--------------------------------------------
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

