Added: Find a Translation by the defaults languagestring

This commit is contained in:
kolaente 2016-06-16 13:17:40 +02:00 committed by kola
parent 5faeabf1f9
commit 10ef326e08
3 changed files with 13 additions and 5 deletions

View File

@ -28,7 +28,7 @@ To output a string, simply run the following command:
$lang->get($identifier);
$lang->get('Home');
```
Where `$identifier` is the Key _**OR**_ the value defined in the file.
Where `$identifier` is the Key _**OR**_ the value defined in the default's langfile.
##Reserved Identifiers

View File

@ -6,8 +6,9 @@ $lang->setLangFolder('langs/');
$lang->setLang('lang.es.php', 'es');
echo $lang->get('Home').'<br/>';
echo $lang->get('something');
echo $lang->get('something').'<br/>';
echo $lang->get('Home is where your wifi connects automatically').'<br/>';//Get Languagestring by Languagestring
$lang->setLang('lang.de_extra.php', 'de');
echo $lang->get('fail');

View File

@ -71,11 +71,17 @@ class lang
//If Langueage exists...
if (array_key_exists($this->lang, $this->langfiles))
{
//...and a value for the corresponding key
$array_key = array_search($identifier, $this->langfiles[$this->default]['langstrings']);
//...and a value for the corresponding key...
if (array_key_exists($identifier, $this->langfiles[$this->lang]['langstrings']))
{
//Outpout it
//Output it
return $this->langfiles[$this->lang]['langstrings'][$identifier];
}//...or find String by the defaults languagestring
elseif($array_key !== false)
{
//Output it
return $this->langfiles[$this->lang]['langstrings'][$array_key];
}
else
{
@ -91,7 +97,8 @@ class lang
}
}
}
else//Fallback to the default language
//Fallback to the default language
else
{
if (array_key_exists($identifier, $this->langfiles[$this->default]['langstrings']))
{