[phpwebapp-commits] CVS: web_app/doc to_do.txt,1.14,1.15 changes.txt,1.16,1.17 ToDo.txt,1.9,1.10
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2005-06-13 06:55:37
|
Update of /cvsroot/phpwebapp/web_app/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8209/doc Modified Files: to_do.txt changes.txt ToDo.txt Log Message: added translation (i18n/l10n) support Index: to_do.txt =================================================================== RCS file: /cvsroot/phpwebapp/web_app/doc/to_do.txt,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** to_do.txt 12 Oct 2004 10:01:46 -0000 1.14 --- to_do.txt 13 Jun 2005 06:55:21 -0000 1.15 *************** *** 1,2 **** --- 1,9 ---- + * - Add i18n support to the framework + + * - Write in DocBookWiki a programmer's guide for phpWebApp. + + * - Use the webbox docbook in the documentation of phpWebApp. + + * - Write more tutorials for phpWebApp. * - Add this functionality to the framework: any webobject can Index: changes.txt =================================================================== RCS file: /cvsroot/phpwebapp/web_app/doc/changes.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** changes.txt 9 Jun 2005 13:21:34 -0000 1.16 --- changes.txt 13 Jun 2005 06:55:21 -0000 1.17 *************** *** 73,76 **** --- 73,187 ---- </unindented> ------------------------------------------------------------------- + + * Added support for multiple languages to the framework. + translation / internationalization (i18n) / localization (l10n) + + It can use any one of the packages: + - PHP-gettext (http://savannah.nongnu.org/projects/php-gettext/) + - GNU gettext (http://www.gnu.org/software/gettext/gettext.html, + http://www.php.net/gettext) + since both of them have some advantages or disadvantages. + + The disadvantages of GNU gettext are that it does not work if gettext + package is not installed, or if the system is not configured for + using translations of a language. Also, the gettext functions in the php + seem not to be reliable, sometimes they get the translation from one + place, sometimes from another (maybe this is a caching problem?). + In general, it is a headache to make it work. + + The disadvantages of PHP-gettext are that it may not be as fast + as GNU gettext, and there may be some gettext functionality that is + not supported yet (not implemented yet). + + The application programer can choose the one that suits him best. + The choice is made at 'config/const.Options.php': + + /** if true, then use the php-gettext instead of GNU gettext */ + define('USE_PHP_GETTEXT', true); + + Other translation constants that are defined at the options file + are LNG and CODESET: + + /** + * The constants LNG and CODESET set a default language and codeset for + * the application. They are used for the localization (translation) + * of the messages. They can be changed by calling: + * $l10n->set_lng($lng, $codeset) + * where $l10n is a global variable and $codeset is optional. + * LNG can be something like 'en_US' or 'en' or UNDEFINED. + * CODESET can be UNDEFINED, 'iso-latin-1', etc. + */ + define('LNG', 'sq_AL'); + define('CODESET', 'iso-latin-1'); + + LNG sets a default language for the application, but it can also be + changed dynamically, calling $l10n->set_lng($lng). With GNU gettext, + LNG can also be UNDEFINED, and in this case the system default will + be used. However, with PHP-gettext it should have a value (or a + value should be set with $l10n->set_lng()). + CODESET is used in GNU gettext, but it is not needed by PHP-gettext, + so it can also be UNDEFINED. See the documentation of gettext + (`info gettext`) for more information about when and why it is needed. + + The framework allows to have separate translation (localization) files + foreach template that is included and for each webobject. If the + directory that contains the template (or webbox) contains also + a subdirectory named 'l10n', then the framework will look inside + this directory for the file that contains the translations of the + messages of the template/webbox. It will look for the file + l10n/lng/LC_MESSAGES/tplname.mo (or l10n/lng/LC_MESSAGES/webboxid.mo) + which contains the translation messages of the template (or webbox). + + If the subdirectory 'l10n/' does not exist, the framework will + look for the file tplname.mo (or webboxid.mo) in the first 'l10n/' + in the parent directory or in the ancestors. If even the application + directory does not contain a 'l10n/' subdir, then the last place + to look for will be the system default (usually /usr/share/locale/). + + About the language code, if it is e.g. 'en_US', then it will search + first the folder 'en_US/' and then the folder 'en/'. + + If the file tplname.mo (or webboxid.mo) is not found at all in + the searched directories, then the last translation (*.mo) file + that was found will be used for translating messages. This is usually + the translation (*.mo) file of the containing template or webbox + (from which this template/webbox is included directly or indirectly). + + This way of finding the translation files allows for modularity, + because each webbox/template can have its own translation files, + so using them in other applications can be done by just copying them + there. But it is also flexible and does not enforce unnecessary + or unneeded modularity, so that for example the whole application + can have a single translation file, or sub-webbox-es can use the + translation files of the main webbox. + + In general, translation files (*.mo) can be organized like this: + + - A single translation file 'app_name.mo' can be used for all the + application. It can be placed in /usr/share/locale/lng/LC_MESSAGES/ + or in app_path/l10n/lng/LC_MESSAGES/ + + - Generic webboxes, which are used in more that one application, + can have their own translation file 'webbox_id.mo' (besides + the application file 'app_name.mo'), which is placed in the + same directory as the application file (see above). + + - Each important webbox can have a subdirectory 'l10n/', + in which is placed the translation file of the webbox, + in /path/to/webbox/l10n/lng/LC_MESSAGES/webbox.mo . + This file can contain the translations of all the sub-webbox-es + and sub-templates as well (the ones that are included from this + webbox), or they (their translations) can be in separate + files in the same directory, which are named according to + the template name or the webbox id. + + - Each webbox can have its own 'l10n/' directory, which contains + its own translation files. This is the most modular aproach + but it may not be always needed. + + Other combinations are possible as well, so it is up to the + application and its developer to decide about it. + + ------------------------------------------------------------------- ------------------------------------------------------------------- Index: ToDo.txt =================================================================== RCS file: /cvsroot/phpwebapp/web_app/doc/ToDo.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ToDo.txt 12 Oct 2004 10:01:47 -0000 1.9 --- ToDo.txt 13 Jun 2005 06:55:21 -0000 1.10 *************** *** 61,86 **** multiple languages. ------------------------------------------------------------- - * - Add i18n support to the framework - - The GNU system has i18n support (gettext) and PHP has an API for - it, however something does not work very well for web - applications, so I think that the framework cannot use it. We can - build, however, something similar to it. - - The messages that have to be translated by the framework can be - denoted like this: {{i)Hello World!}}, or like this: <i18n>Hello - World!<i18n>. Then a tool similar to xgettext can be used to - extract all the messages from the templates. Then we can either - continue in the same way that gettext does, or we can create a - message file for each webbox. - - In the second case we will have to create the files - 'boxid_fr.msg', 'boxid_de.msg' etc. for each webbox and for each - language. They can either be stored in the same folder as the - webbox, or in the subfolder 'langs' in the same folder, or in the - folder 'messages' where are stored all the message files of the - application, etc. - - ------------------------------------------------------------- * - Build a tool for the web (graphical) designer so that he can preview the templates. (The "browse.php" does this). --- 61,64 ---- |