Recommend this page to a friend! |
Download .zip |
Info | Documentation | View files (2) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2016-08-01 (2 months ago) | Not enough user ratings | Total: 181 | All time: 7,944 This week: 871 |
Version | License | PHP version | Categories | |||
i18n_t 1.0.1 | GNU General Publi... | 5 | Localization |
Description | Author | |
This class can translate application texts loaded from XML files. Recommendations What is the best PHP multilanguage without database class? |
This class uses two levels XML files to translate words,sentences, etc. It can load one or more translation files at one time. You can change the default $lang_folder and the default $locale to whatever you need in the class, but they are only used in the get_commun() function, wich is optionnal. A function i18N_T() is provided to ease the use of the class. In my case, the structure is : module ->langages ->fr_FR.UTF-8 ->XML file(s) ->en_GB.UTF-8 ->XML file(s) The two XML structures are : <?xml version="1.0" encoding="UTF-8"?> <dictionnaire> <module type="commun"> <couple> <source>Original word OR sentence</source> <cible>Translated word OR sentence</cible> </couple> </modules> </dictionnaire> and <?xml version="1.0" encoding="UTF-8"?> <dictionnaire> <module type="commun"> <couple> <source>Publier, gérer et lire des fanfics, des histoires originales, des poèmes<br />et autres textes en ligne</source> <cible> <couple> <source type="==1">Il y a %d objet.</source> <cible>There is %d object.</cible> </couple> <couple> <source type=">1">Il y a %d objets.</source> <cible>There are %s objects.</cible> </couple> </cible> </couple> </modules> </dictionnaire> Of course, you can mixe them. The name of the module can be empty. It has no importance in this version, but could have in a further one. Of course, you can have several modules and several couples in a dictionary. How to call a dictionary (case french to english) : include 'class.dictionnaires.php'; $dictionnaire = new dictionnaire($_SESSION['locale']); $dictionnaire->get_fichiers(array(__DIR__.'/langages/'.$_SESSION['locale'].'/commun.xml')); How to use it : print i18N_T("Un objet"); -> prints : An object Otherwise prints "Un objet" if there is no translation. You can use more than one dictionary at a time : include 'class.dictionnaires.php'; $dictionnaire1 = new dictionnaire($_SESSION['locale']); $dictionnaire2 = new dictionnaire('en_US.UTF-8'); print i18N_T("Consulter tous les articles",null,$dictionnaire1); You can use comparison for plural : printf("%d %s",7,i18N_T("nbevenements",'>0')); |
Files |
File | Role | Description |
---|---|---|
class.dictionnaires.php | Class | Translation class |
readme | Doc. | How to use this class |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
0% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.