Skip to content
Snippets Groups Projects
Commit 2c8a557c authored by hahn's avatar hahn
Browse files

use lang code XX-XX in plugins

parent aecf7139
Branches
No related tags found
1 merge request!195534 add docker
This commit is part of merge request !19. Comments created here will be created in the context of that merge request.
...@@ -36,7 +36,14 @@ class rollout_base implements iRolloutplugin{ ...@@ -36,7 +36,14 @@ class rollout_base implements iRolloutplugin{
* file "lang_en.json" is required in the plugin dir * file "lang_en.json" is required in the plugin dir
* @var string * @var string
*/ */
protected $_sLang = 'en'; protected $_sFallbackLang = 'en-en';
/**
* set language; 2 letter code, i.e. "de"; default language is "en" ; a
* file "lang_en.json" is required in the plugin dir
* @var string
*/
protected $_sLang = 'en-en';
/** /**
* string with phase of project; one of preview|stage|live * string with phase of project; one of preview|stage|live
...@@ -336,7 +343,7 @@ class rollout_base implements iRolloutplugin{ ...@@ -336,7 +343,7 @@ class rollout_base implements iRolloutplugin{
* translated texts can be done with $this->_t("your_key") * translated texts can be done with $this->_t("your_key")
* *
* @see _t() * @see _t()
* @param string $sLang language code, i.e. "de" * @param string $sLang language code, i.e. "de-de"
* @return boolean * @return boolean
*/ */
public function setLang($sLang=false){ public function setLang($sLang=false){
...@@ -344,6 +351,10 @@ class rollout_base implements iRolloutplugin{ ...@@ -344,6 +351,10 @@ class rollout_base implements iRolloutplugin{
$oReflection=new ReflectionClass($this); $oReflection=new ReflectionClass($this);
$sFile=dirname($oReflection->getFileName()) . '/lang_'.$this->_sLang.'.json'; $sFile=dirname($oReflection->getFileName()) . '/lang_'.$this->_sLang.'.json';
if (!file_exists($sFile)){
$sFile=dirname($oReflection->getFileName()) . '/lang_'.$this->_sFallbackLang.'.json';
$this->_sLang=$this->_sFallbackLang;
}
$this->_aLang=(file_exists($sFile)) ? json_decode(file_get_contents($sFile), 1) : $this->_aLang; $this->_aLang=(file_exists($sFile)) ? json_decode(file_get_contents($sFile), 1) : $this->_aLang;
return true; return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment