mirror of
https://github.com/Mowie/Multilanguage.git
synced 2024-06-15 17:04:08 +00:00
Added: Change the displayed language function
This commit is contained in:
parent
10ef326e08
commit
0fb4026d8b
14
README.md
14
README.md
|
@ -8,7 +8,7 @@ A Class which takes care of deploying your site in multiple languages.
|
||||||
$lang = new lang($defaultLanguage);
|
$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.
|
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.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$lang->setLangFolder('../langs');
|
$lang->setLangFolder('../langs');
|
||||||
|
@ -21,15 +21,23 @@ For example `lang.en.php`.
|
||||||
|
|
||||||
The script will find the file and use it.
|
The script will find the file and use it.
|
||||||
|
|
||||||
You can also define multiple langfiles to get the strings of (see example.php)
|
You can also define multiple langfiles to get the strings of (see example.php).
|
||||||
|
|
||||||
To output a string, simply run the following command:
|
To output a string, simply use the following command:
|
||||||
```php
|
```php
|
||||||
$lang->get($identifier);
|
$lang->get($identifier);
|
||||||
$lang->get('Home');
|
$lang->get('Home');
|
||||||
```
|
```
|
||||||
Where `$identifier` is the Key _**OR**_ the value defined in the default's langfile.
|
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:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$lang->setCurrentLang($lang);
|
||||||
|
```
|
||||||
|
|
||||||
##Reserved Identifiers
|
##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.
|
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.
|
||||||
|
|
|
@ -4,6 +4,7 @@ require_once '../lang.class.php';
|
||||||
$lang = new lang();
|
$lang = new lang();
|
||||||
$lang->setLangFolder('langs/');
|
$lang->setLangFolder('langs/');
|
||||||
$lang->setLang('lang.es.php', 'es');
|
$lang->setLang('lang.es.php', 'es');
|
||||||
|
$lang->setCurrentLang('de');
|
||||||
|
|
||||||
echo $lang->get('Home').'<br/>';
|
echo $lang->get('Home').'<br/>';
|
||||||
echo $lang->get('something').'<br/>';
|
echo $lang->get('something').'<br/>';
|
||||||
|
|
|
@ -14,6 +14,12 @@ class lang
|
||||||
$this->langfiles = [];
|
$this->langfiles = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Change the current Language
|
||||||
|
function setCurrentLang($lang)
|
||||||
|
{
|
||||||
|
$this->lang = $lang;
|
||||||
|
}
|
||||||
|
|
||||||
//Get Langfiles by Folder
|
//Get Langfiles by Folder
|
||||||
public function setLangFolder($folder)
|
public function setLangFolder($folder)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user