Création d'un site multilingue avec "php class translate"

Choisissez la langue désirée

Texte traduit (par exemple avec Google translator)

"Translate" est très simple à mettre en œuvre un outil facile classe php. Seuls les 3 lignes de code suffisent pour préparer votre site pour montrer les différentes langues:

		require_once ('Translate/Translate_class.php');
		$translate = new translate();
		$translate->setBrowserLanguage();

Caractéristiques principales

Les fonctions suivantes publics ne sont pas traduits, car ils sont un héritage de la classe de fonction "showAllPublicfunctions ();" ...

Public functions of php class 'translate'

setBrowserLanguage()
This function determines the browser language and tries to load the corresponding language file. If the file does not exist the php class uses the fallback language (defined in the Translate_class.php). There is no return value.
setLanguage()
Instead of determin the browser language the webmaster can define the used language manually. Not matter of the language of the user this language file is used. If the file does not exist the php class uses the fallback language. There is no return value.
getLanguageByIP()
Translate can try to resolve the IP address of the user and to determine the country of origin. Please be aware that this function needs some time because it reads an array with more than 11.000 lines. The input variable can be 2, 3 or 4:
  > 2 return a two letter country code like 'us'.
  > 3 return three letters like 'usa'
  > 4 return the complete name like 'UNITED STATES OF AMERICA'.
getCurrentLanguage()
This function returns a string with the currently used language. For example: 'en' or 'de'.
getLanguageFilesInDirectory()
This function returns an array with all found language files in the folder of the Translate_class.php. For example: array('lang_en.php', 'lang_de.php').
getAllLanguages()
This function returns an array with all found languages in the folder of the Translate_class.php. For example: array('en', 'de').
_($keyword, $replaceArray = '')
This is the central function to return a string with the text piece corresponding to the keyword. In addition it is possible to replace placeholders in the text with another text piece. Imagine the keyword for 'welcome' is 'Hello #surname# #name#'. In this case the usage could be: echo $translate->_('welcome', array('#surname#=>'Christoph', '#name#=>'Dyllick-Brenzinger').
showAllTextsAndKeywords()
This is one of the three supporting function and shows a table with all keywords and text pieces of the currently selected language.
showAllTexts()
This is the second of three supporting functions and shows only the text pieces without the keywords.
showAllPublicFunctions()
Shows all public functions of this php class. (If you read this you are currently using this function...)
compareLanguageFileWithFallback()
This is the last supporting function which compaires the de...