<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.0.10">
</HEAD>
<BODY>
Hi Stef,<BR>
<BR>
(this email use html violating every rule in netiquete, but it includes some code and the colors (i hope) will help)<BR>
<BR>
<BLOCKQUOTE TYPE=CITE>
<PRE><FONT COLOR="#737373"><I>is there a how-to document about making code translatable ? I have no
idea how this is supposed to work.</I></FONT></PRE>
</BLOCKQUOTE>
<BR>
For the 90% of the cases you only need to send #translated to every visible String. When #translated is evaluated, the receiver (one string) answer the version of this string/phrase to the current language. So,<BR>
<BR>
<FONT COLOR="#339966"><I><TT>"answer 'casa' when Spanish if the current language"</I></FONT>
<PRE> <FONT COLOR="#ff0000">'house'</FONT> translated.</PRE>
</TT><BR>
The other useful message (needed to cover the missing 10%) is #format:. String>>format: is a type of "printf()" with a really simple (aka stupid) syntax. The occurrences of '{N}' will be replaced by the string representation of the object at position N in the given SequenceableCollection, so:<BR>
<BR>
<FONT COLOR="#339966"><I><TT>"evaluates to 'My name is Diego and I'm 31 years old' when anObject it's me"</I></FONT><BR>
<FONT COLOR="#ff0000">'My name is {1} and I'm {2} years old'</FONT> format: {anObject name. anObject age}. </TT><BR>
<BR>
The goal with format is to replace former string concatenations like:<BR>
<BR>
<PRE><TT> <FONT COLOR="#ff0000">'My name is '</FONT>, anObject name, <FONT COLOR="#ff0000">' and I'm '</FONT>, anObject age asString, <FONT COLOR="#ff0000">' years old'</FONT>.</TT></PRE>
<BR>
As you can see, the order used in the concatenation makes sense only in English. Combining #translated and #format: you can make translatable almost any piece of code.<BR>
<BR>
The full previous example has to be:<BR>
<BR>
<PRE><TT> <FONT COLOR="#ff0000">'My name is {1} and I'm {2} years old'</FONT> translated format: {anObject name. anObject age}.</TT></PRE>
<BR>
Note: As the replacing made by #format: use positions, the translator can rearrange the places where the expansion occurs.<BR>
<BR>
Let me know if the explanation is clear enough.<BR>
<BR>
Cheers,<BR>
<BR>
Diego<BR>
<BR>
</BODY>
</HTML>