A Framework to make your project multilanguagual.
Go to file
kolaente 01266ec459 Updated Travis-CI 2016-07-27 12:01:55 +02:00
examples Added: Add Languagestrings dynamically via function 2016-07-03 15:53:35 +02:00
.travis.yml Updated Travis-CI 2016-07-27 11:52:28 +02:00
LICENSE Initial commit 2016-06-16 12:52:17 +02:00
README.md Added: Change the displayed language function 2016-06-23 18:10:16 +02:00
lang.class.php Updated Travis-CI 2016-07-27 12:01:55 +02:00
test.php Updated Travis-CI 2016-07-27 12:01:55 +02:00

README.md

#Mowie Multilanguage

A Class which takes care of deploying your site in multiple languages.

##Usage

$lang = new lang($defaultLanguage);

The default language, which will be used if the users language is not found, is english. However, you can change this to any language you want.

$lang->setLangFolder('../langs');
$lang->setLang($langfile, $lang);
$lang->setLang('langfile.en.php', 'en');

You can either define multiple languagefiles, which contain the languagestrings, or define a folder, where the different files are placed. If you do a folder, the files need to be named clearly. For example lang.en.php.

The script will find the file and use it.

You can also define multiple langfiles to get the strings of (see example.php).

To output a string, simply use the following command:

$lang->get($identifier);
$lang->get('Home');

Where $identifier is the Key OR the value defined in the default's langfile.

###Change the displayed language

You can change the displayed language to one the user selects. To do this, use this command:

$lang->setCurrentLang($lang);

##Reserved Identifiers

The two idetifiers __Lang__ and __Countrycode__ are reserved identifiers and used by the script to output a list of all available languages to the user.

##Langfile

A languagefile consists of the following code:

$lang = [];
$lang['__Lang__'] = 'English (English)';
$lang['__Countrycode__'] = 'en_US';

$lang['Home'] = 'Home is where your wifi connects automatically';
$lang['About'] = 'About us';
$lang['Contact'] = 'Contact us';
...

NOTE: To make sure all your languages are displayed correctly, set the file encoding to UTF-8.

##Examples

Examples can be found in the examples folder.