phpBB has support for over 40 languages. The MODing community supports the use of the phpBB multilingual system. Many MODs have been translated into several languages but until now there has not been any standization of how multilingual support for MODs should work.
The least you need to know:
- restrict FINDs to only the $lang[] key
- do not use comments as FIND targets in a lang_ file
- translations for lang_main type files are stored as a seperate lang_xxxxxx.txt MOD-style file
- translations for MOD specific lang files are stored in the same directory as lang_filename_xxxxx.php
FIND and lang_ files
For our purposes, there are two kinds of lang_ files. First we have the files including lang_main and lang_admin that have $lang keys defined. We also have the FAQ files that include lang_bbcode and lang_faq. You must keep in mind that ALL languages are going to be updated as best we can do so a convention must be adopted for MODing both kind of files. This discussion is also covered in the FIND section of this document.
The lang_main and lang_admin files are the most commonly MODed files. Fortunately they are also the easiest to deal with. No matter what language we are using, the keys in the $lang[] array always remain the same. Between the numerous translations, the values may change and the code comments may change, but the keys will always remain the same. Therefore when performing a FIND to add more $lang[] entries in the file, you must restrict the FIND to include only the $lang[] key and not the value. For example, instead of this...
Code: Select all
#
#-----[ FIND ]----------------------------------
#
$lang['Forum'] = 'Forum';
Code: Select all
$lang['Forum']
Code: Select all
// That's all folks!
Code: Select all
// Eso es todo amigos!!!!
The FAQ lang_ files are more tricky and fortunately used much less. These files do not have any $lang[] keys that we can rely on for positioning. Therefore the searching in this files in all but the native language is impossible. The only solution is to MOD these files as you normally would and EasyMOD will update files from other language by placing any lines to be added to the file just before the closing ?>
About Translations
It is intended that MODs will be written for one primary language. In the case of http://www.phpBB.com" target="_blank that means English. Many MODs, especially the most popular, have been translated into many different languages so they may be used by the international phpBB audience. But when it comes to development, it is just not possible to have all the translations ready before releasing the MOD. Also, the translations may need to be updated for various reasons, such as typos, independently of the MOD. We need to allow translators the maximum flexiblity in providing translations as frequently as they need to and whenever they need to. Therefore the best solution is to store all non-English langauage data outside of the MOD script, in seperate files.
Translations for lang_ Files
Some MODs need to add some additional lines to files like lang_main.php. These lines are simply added through the MOD script. The process is very straight forward, requiring no explanation... until you consider translations. But don't worry this is pretty simple as well
Let's start with by explaining the name of the file. For our example, let's say we want to provide a Spanish translation. The filename will be lang_spanish.txt. Notice that "spanish" is lowercase. The name needs to match the directory name in /languages/lang_xxxx where xxxx is the name of the language as assigned by phpBB. As for location of this type of file, to provide maximum flexiblity for Authors, you may locate this file anywhere in this MOD's directory. It is recommened that you keep all language files for this MOD in the same directory, such as /translations or /languages.
As for the content of the file, this is very straight forward. Say the original MOD script contains the following...
Code: Select all
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
# NOTE: the complete line to find is:
# $lang['A_critical_error'] = 'A Critical Error Occurred';
#
$lang['A_critical_error']
#
#-----[ AFTER, ADD ]------------------------------------------
#
// FLAGHACK-start
$lang['Country_Flag'] = 'Country Flag';
$lang['Select_Country'] = 'SELECT COUNTRY' ;
// FLAGHACK-end
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
Code: Select all
#
#-----[ OUVRIR ]------------------------------------------
#
language/lang_french/lang_main.php
#
#-----[ TROUVER ]------------------------------------------
#
# NOTE: la ligne complète à trouver est:
# $lang['A_critical_error'] = 'Une Erreur Critique est Survenue';
#
$lang['A_critical_error']
#
#-----[ APRES, AJOUTER ]------------------------------------------
#
// FLAGHACK-start
$lang['Country_Flag'] = 'drapeau de pays';
$lang['Select_Country'] = 'choisissez le pays' ;
// FLAGHACK-end
#
#-----[ SAUVEGARDER/FERMER TOUS LES FICHIERS ]----------------
#
#FdM
Providing a header at the start of your file is also a good idea. It is especially important to note what versions of the MOD the translation is compliant with. Noting the revision date of the translation is also effective in determining the latest version. A sample header looks like this...
Code: Select all
##############################################################
## MOD Title: Country Flags
## MOD Versions: 1.0.0 to 1.2.0
## Translation: French
## Rev Date: September 15, 2003
##
## Translator: Nuttzy99 < [email protected] > (n/a) http://www.blizzhackers.com" target="_blank
##
##############################################################
MODs with thier own lang files
Often times it is easier for larger MODs such as Attach MOD or EasyMOD to create their own lang_ files instead of adding to lang_main or lang_admin. The MOD script will move these files into the appropraite language directory through the use of the COPY command. Under the old convention, this file would also be copied to all other languages directories as well. So for example, assume you have a lang_easymod.php file written in English and you have both English and Spanish lang packs installed. The file would also get copied to /language/lang_spanish even though it is written in English.
The new convention will detect if a lang_easymod.php file translated for Spanish exists and will copy this file to language/lang_spanish instead. All you need to do is add _spanish to the file name (before the suffix) and have the file in the same directory as the English file (or whatever the default language). So if a lang_easymod_spanish.php file exists in the same directory as lang_easymod.php then the file will be copied correctly. The _spanish will be stripped off while moving to the new location.
Translated files that are not needed will be ignored. Therefore if a lang_easymod_french.php also exists in the directory but the French lang pack is not installed, then the file is ignored. If French is installed, but a lang_easymod_french.php file is not present in the same directory as lang_easymod.php, then lang_easymod.php will by default be copied to /langauge/lang_french. It is better to have something present, even in the wrong language, rather than nothing