Translation class new features - RFC
| From: | Wojciech Zieliński | Date: | Mon, 02 Dec 2002 15:54:28 +0000 |
| Subject: | Translation class new features - RFC | ||
| Groups: | php.pear.dev php.pear.general | ||
| Request: | Send a blank email to pear-dev+get-11297@lists.php.net to get a copy of this message | ||
Hi,
I finally found some time to think over again the features of Translation class and make the full list of additions I would like to add to this class.
However before starting coding I would like to see some you comments for these features - so I won't do something that is completelly unusable, or do something, that will be not used becouse of comlicity of the solution. Please find the description below and any comments will be highly desirable.
1. Error handling - all the languages will have the string, that will be showed to the user, if the string has not been found for the specified language - e.g. if string STRING1 has only the Polish version, then for English there will be "No english available" showed.
2. Custom table and column names - user will be able to specify the names for the tables and columns in which all the information will be stored. This will be passed to the class constructor as additional parameter - CustomTables. This parameter will be the array with the following structure:
"langsavail" -> table, in which all the information of the possible languages is kept. This array item may be the string - then the structure of the table remains as original, but the name is specified here; or the array with the following items:
"name" - the name of the table.
"lang_id" - the name of the column, that stores the language identifier. Original column name is "lang_id".
"lang_name" - the name of the column, that stores the language name. Original column name is "name".
"metatags" - the metatags that should be included in the page header, so the page will be displayed properly. Original column name is "metatags".
"nostringtext" - the text that will be displayed if the string for the specified string_id has not been found in the language. This is new feature available since this version (please refer point 1).
"strings_en_tablename" -> table, in which the strings of language "en" (the corresponding lang_id) are kept. This array item may be the string - then the structure of the table remains as original, but the name is specified here; or the array with the following items:
"name" - the name of the table.
"page_id" - the page identifier. Original column name is "page_id".
"string_id" - the string indetifier. Original column name is "string_id".
"string" - the string itself. Original column name is "string".
3. Reducing the DB connections by possibility to use the existing ones - the constructor right now needs the PEAR DB DSN to make the connection do the DB. The new version will allow user to use the existing DB connection (PEAR DB connection) instead of making the new one. To do so he just needs to pass to the constructor the handle for this connection instead of DSN.
4. Getting the strings in more then one way - adding more flexibility for gstr() method, so it will be able to get the strings in the following ways:
gstr("PAGE_ID.STRING_ID") - this will get the string not for the current, but for the specified page_id.
gstr("STRING","LANG") - this will ry to find the STRING in the strings table of the specified LANG and will retrieve the translation for the current language - e.g. if the current language is "pl", and we will make the gstr("Some string","en") - this will return as the corresponding string in Polish (in this example "Jakiś napis"). This method is not recommened as the indexes are not made on the string column, but sometimes - if we simply need the translation, and have no page_id and string_id - this might be usefull.
5. Ability to use the PHP native gettext support - instead of db_handle the constructor may be provided with hadle (DSN in fact) in the following format:
gettext://LOCALE:LANG:BINDTEXTDOMAIN:TEXTDOMAINFILE:TEXTDOMAIN:CONFIGFILE
LOCALE - the locale id (e.g. "LC_ALL")
LANG - language id (e.g. "de")
BINDTEXTDOMAIN - localization tables (e.g. "myPHPApp")
TEXTDOMAINFILE - localization tables file (e.g. "./locale") - if not supplied - it equals "./locale".
TEXTDOMAIN - text domain (e.g. "myPHPApp") - if not supplied - it equals BINDTEXTDOMAIN
CONFIGFILE - the config file directory. Config file should be in the following format:
pl_langname = "Polish"
pl_metatags = "<!--meta...--!>"
pl_nostringtext = "Brak polskiej wersji !"
en_langname = "English"
en_metatags = "<!--meta...--!>"
en_nostringtext = "English version not available"
...
In this file the first 2 characters are the language code.
This functionality is the most advanced - so I would really appreciate the comments from people, that actively uses the gettext functions (in fact - I have never used these functions, so I might missunderstood something :) ).
As I said before - any comments highly requested :)
Regards
Voyteck