Localizing UI and messages
Sphinx provides a very strong interaction with the end-user, be it via the GUI it provides, like the login web page, registration page, etc., and the messages that the server can emit.
Thus, it's important that you might be able to tell Sphinx which language to use.
Changing the default language
Changing the login page language and server messages should be as simple as setting the UIOptions.DefaultLanguage
property in the TSphinxConfig component (from code or at design-time in object inspector):
SphinxConfig1.UIOptions.DefaultLanguage := 'pt-br';
But, of course, an existing translation should be available for the chosen language. Here are the current available translations:
- English (default)
de-de
: Germanfr-fr
: Frenchit-it
: Italiannl-be
: Dutch (Belgium)nl-nl
: Dutch (Netherlands)pt-br
: Brazilian Portuguesesv-se
: Swedish
Registration page in German:
Registration page in French:
Creating translations for other languages
It's easy to translate existing text to support a new language: all the texts are in JSON files. They are located in folder languages
, inside the directory where you installed TMS Sphinx.
Inside the languages
there are two sub-folders: web
(containing all the text for the web UI) and server
(containing all the text for server messages). Inside each of those folder there are JSON files for each available language - for example, pt-br.json
, sv-se.json
, etc.
The JSON inside each file is rather simple: just a single JSON object with the english text as the property name, and the translated text as the property value. Here is a snippet of the existing pt-br.json
as an example:
{
"Account": null,
"An error has occurred": "Ocorreu um erro",
"By clicking the %s button, I agree to the %s.": "Ao clicar em %s, concordo com os %s.",
"Cancel": "Cancelar",
"Change e-mail": "Alterar email",
"Change password": "Alterar senha",
"Check if URL is correct. Avoid using spaces and special or uppercase characters.": "Verifique se a URL da página foi informada corretamente ou se foi digitada sem erros. Evite usar espaços, caracteres especiais ou letras maiúsculas.",
"Claim \"%s\" is invalid: %s": "Claim \"%s\" é inválido: %s",
"Confirm new password": "Confirme a nova senha",
"Confirm password": "Confirme a senha",
"Continue": "Continuar",
So for example, to translate it to German, just copy the pt-br.json
files to a de.json
(or de-de.json
) file, translate the property values and send them to our support team, so we can generate the proper resources and include the new translation in an upcoming release.
Then you can use "de
" (or "de-de
") in the DefaultLanguage
property.
Testing the translation for the login web app
Ideally we should compile the translated JSON file to a resource but you can test it right away in the login web application by setting the TSphinxConfig.UIOptions.LoginAppFolder
property.
Set it to a local folder in your disk, for example:
SphinxConfig1.UIOptions.LoginAppFolder := 'D:\SphinxLoginApp';
SphinxConfig1.UIOptions.DefaultLanguage := 'de-de';
And then add a languages
folder inside D:\SphinxLoginApp
and put your JSON there.
Sphinx looks for the specific language and region. If it doesn’t find it, it looks for only the language.
For example, is you set default language to “fr-fr
”, it will look for fr-fr.json
. If such file doesn’t exist, it looks for fr.json
. The same for fr-ca
.
Thus, if you wish you can have a single fr.json
for both fr-fr
and fr-ca
languages.
Note: The above technique (using LoginAppFolder
) works only for the text displayed in the web UI. For translated server messages, they must be compiled as a resource.