WHAT IS THAT?
I am submitting my 2 cents on a simple solution to
handle part of the internationalization of Swiki.  I
am currently testing this solution and it seems to
work so far (4 files translated).  I wanted it to be
simple, easy to code and maintain and absolutely
wanted to be easy to work with for translators.  The
whole "strings" file is a plain text file that can be
edited with a standard text editor.

HOW IT WORKS
On startup of Comanche, a text file containing the app
strings is loaded.  The file format is simply a
key/value pair that gets read and transformed in a 
dictionary.  The values of the dictionary are accessed
with the #msgAt: selector.

One class, MessageCatalog is responsible for loading
the file and handling accesses to the dictionary while
the class UserMessage handles the parsing of every
line to transform them into instances of UserMessage.

To simplify code, class Object implements #msgAt:,
#msgAt:with:, #msgAt:with:with:,
#msgAt:with:with:with:, #msgAt:with:with:with:with:,
and #msgAt:with:with:with:with:.
These selectors just redirect the message to the
MessageCatalog class and access the dictionary.  The
"with" part is to handle parameter substitution
(equivalent of #bindWith in VisualAge).

NEEDED CHANGES
We just need to change the Comanche files minimaly. 
We just replace the "hard coded string" with a (self
msgAt: aKey) and insert that key and its value (the
string) into a catalog file.

For instance, here's the original
swiki/refs/addresses/12 file

Actual file (swiki/refs/addresses/12)
=======================================================
"Close the Individual Log File"
(book setup at: 'logging' ifAbsent: ['none']) caseOf:
{
        ['none']->[book modulesRemove: 'logFile'].
        ['individual']->[
                (book modulesAt: 'logFile') close.
                book modulesRemove: 'logFile'].
        ['site']->["Do nothing"]}
        otherwise: [shelf error: 'That is not a valid value
for logging']


Here is the modified file (swiki/refs/addresses/12)     
=======================================================
"Close the Individual Log File"
(book setup at: 'logging' ifAbsent: ['none']) caseOf:
{
        ['none']->[book modulesRemove: 'logFile'].
        ['individual']->[
                (book modulesAt: 'logFile') close.
                book modulesRemove: 'logFile'].
        ['site']->["Do nothing"]}
        otherwise: [shelf error: (self msgAt: 'Kom0002')]
        

NOTICE THE (self msgAt: 'Kom0002')!


The catalog file, for an english Swiki would look
like:

English.msg
=======================================================
Kom0001 Congratulations! This is a new Swiki.
Kom0002 That is not a valid value for logging


And in French :

French.msg
=======================================================
Kom0001 F�licitations!  Ceci est un nouveau Swiki.
Kom0002 Ceci n'est pas une valeur acceptable pour le
fichier de log


What do you think?  I've coded the MessageCatalog and
UserMessage classes (not really rocket science here!)
and I'm translating a files here and there to see if
it still works and my solution is possible and
workable.

Any opinions?  Better ideas/suggestions?

Thanks

=====
Benoit St-Jean
[EMAIL PROTECTED]
http://cactus.swiki.net

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Reply via email to