Translating Static TextThe first step towards internationalization is translating all of the static content.
Xataface 0.6 adds i18n support (internationalization) via the
Dataface_LanguageTool class which allows you to transform all interface
text into the language of the user. This version also adds support for
multi-lingual database content (i.e., the ability to store records in
multiple languages), but this how-to deals only with the translation of
"static" text - i.e., text that is not drawn from the database. Procedure for Internationalizing Your Interface
Caveats: EncodingXataface
0.6 uses UTF-8 to encode its web pages. What this means is that you
will need to use UTF-8 encoding for all of your language files (e.g.,
en.ini, fr.ini). If you do not, some special characters such as "à"
may be displayed as gibberish. If your text editor supports UTF-8
encoding then there will likely be a menu option to select the
encoding of the document. If it does not support UTF-8, you will need
to download one that does. A non-comprehensive list of editors
supporting UTF-8 can be found at http://www.alanwood.net/unicode/utilities_editors_unix.html Using ParametersThe "Welcome" example above is a very basic case. There will, however, be many cases where you need to use parameters inside your translation. For example, the text "Found 23 records in table 'Profiles'" should not need to have a separate translation for each possible number of records and each table. For this, you can use parameters in your translation as follows. Likely the PHP code that generates this text looks like: echo "Found $found records in table '$table'"; Change it to: echo df_translate( Then your en.ini file would look like: Found records in table = "Found $found records in table $table" and your fr.ini file would look like: Found records in table = "A trouvé $found disques dans des '$table' de table" Translating Smarty TemplatesThe
best and easiest way to do Xataface development is by using Smarty
templates with the Xataface SkinTool. Most of Xataface's default UI
uses teh Xataface SkinTool and templates. Xataface SkinTool provides a
number of additional tags that you can use in your templates. The
'translate' is a wrapper for the df_translate() function that allows
you to translate text in templates. For example, in the template: <h1>Welcome to my site</h1> You would change it to: <h1>{translate id="Welcome"}Welcome to my site{/translate}</h1> The
text between the {translate} tags is the fall-back text that will be
displayed if no text with id "Welcome" can be found for the current
language. Using Parameters in smarty templatesSuppose you wanted to translate the following text in your template: <p>Found {$found} records in table {$table}</p>Our translation will want to have parameters for $found and $table, so our internationalized template would look like: <p>
|