ED php framework :: Tutorial #12
Internationalization. How to add a new language to your website
All locales are stored under "protected/i18n". If you list the directory "en", you'll see many files ending with ".i18n". The major one is "default.i18n". In case you want to add a new language version, in this case the Spanish one, then you have to copy "en" to "es" and translate "default.i18n". The rest of the files belong to different widgets. Translate them only in case your website uses those widgets. Add all your application strings below "APPLICATION DATA START HERE".
snippet/i18n/
default.i18n
[page charset]
SYS_PAGE_CHARSET="utf-8"
 
 
[shared]
BTN_OK="VALE"
BTN_CLOSE="CERRAR"
BTN_CANCEL="CANCELAR"
BTN_YES="SI"
BTN_NO="NO"
SYS_MSG_ARE_YOU_SURE="Estas seguro ?"
 
 
[system messages]
SYSMSG_ERROR_SQL_INJECTION_DETECTED="Error. Sql injection detected."
SYSMSG_ERROR_NO_RIGHTS_TO_VIEW_PAGE="Error. No rights to view this page."
SYSMSG_ERROR_PAGE_REQUIRES_AUTHORIZATION="Error. This page requires authorization."
SYSMSG_ERROR_APP_FAILURE="Error. Application failure."
SYSMSG_ERROR_ACTION_TERMINATED="Action has been terminated"
 
 
[page info(s) dialog]
SYS_UI_PAGE_INFO_TITLE="INFORMACION"
 
 
[page error(s) dialog]
SYS_UI_PAGE_ERRORS_TITLE="ERRORS"
 
 
[page confirm dialog]
SYS_UI_PAGE_CONFIRM_TITLE="CONFIRM"
 
 
 
 
[======================================== APPLICATION DATA START HERE ====================================== ]
 
str_work="Trabajo"
str_white_house="Casa blanca"
str_my_car="Mi coche"
You have to save all locale files with the right encoding, which is "UTF-8". The quotation marks are not obligatory, but it is always better to use them because sometimes the special language characters can break the function that parses these files.

Then to change to the new language version all you have to do is:
    public function btnSpanish_OnClick() {
        $this->setLocale("es");

        $str1 = i18n("str_white_house");
        $str2 = TLocale::get("str_white_house"); // same result
    }


The default language version is English. You can always change it to whatever you'd like in appconfig.inc
    $application = TApplication::createInstance();
    $application->setName("app-myApp");
    $application->setCheckForSqlInjection(TRUE);
    $application->setDevMode(TRUE);
    $application->setDefaultLocale("es"); // change to Spanish