diff --git a/README.md b/README.md index b3af1ef..9497b52 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/examples/example.php b/examples/example.php index 1fffd70..8f3132a 100644 --- a/examples/example.php +++ b/examples/example.php @@ -6,8 +6,9 @@ $lang->setLangFolder('langs/'); $lang->setLang('lang.es.php', 'es'); echo $lang->get('Home').'
'; -echo $lang->get('something'); +echo $lang->get('something').'
'; +echo $lang->get('Home is where your wifi connects automatically').'
';//Get Languagestring by Languagestring $lang->setLang('lang.de_extra.php', 'de'); echo $lang->get('fail'); diff --git a/lang.class.php b/lang.class.php index 859302e..c800aa0 100644 --- a/lang.class.php +++ b/lang.class.php @@ -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'])) {