summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerrit Uitslag <klapinklapin@gmail.com>2014-09-28 13:27:05 +0200
committerGerrit Uitslag <klapinklapin@gmail.com>2014-09-28 13:27:05 +0200
commitdd7a6159c4224a6a3dda22a1f35f5fb13b06ec2e (patch)
treefb334e50ccb72a0398fe7f0711c50bb5a9c0de54
parent89417bb7bf90154b2a5c17e0717028f7a7d9797f (diff)
downloadrpg-dd7a6159c4224a6a3dda22a1f35f5fb13b06ec2e.tar.gz
rpg-dd7a6159c4224a6a3dda22a1f35f5fb13b06ec2e.tar.bz2
use config cascade for loading of localizations
-rw-r--r--inc/config_cascade.php4
-rw-r--r--inc/init.php16
-rw-r--r--inc/plugin.php24
-rw-r--r--inc/template.php23
4 files changed, 50 insertions, 17 deletions
diff --git a/inc/config_cascade.php b/inc/config_cascade.php
index 72b4493cf..1d9f67edb 100644
--- a/inc/config_cascade.php
+++ b/inc/config_cascade.php
@@ -73,8 +73,8 @@ $config_cascade = array_merge(
),
'lang' => array(
'core' => array(DOKU_CONF . 'lang/'),
- 'template' => array(DOKU_CONF . 'plugin_lang/'),
- 'plugin' => array(DOKU_CONF . 'template_lang/')
+ 'plugin' => array(DOKU_CONF . 'plugin_lang/'),
+ 'template' => array(DOKU_CONF . 'template_lang/')
)
),
$config_cascade
diff --git a/inc/init.php b/inc/init.php
index c7f9a406d..be81ec844 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -266,18 +266,26 @@ function init_paths(){
*/
function init_lang($langCode) {
//prepare language array
- global $lang;
+ global $lang, $config_cascade;
$lang = array();
//load the language files
require(DOKU_INC.'inc/lang/en/lang.php');
+ foreach ($config_cascade['lang']['core'] as $config_file) {
+ if (@file_exists($config_file . 'en/lang.php')) {
+ include($config_file . 'en/lang.php');
+ }
+ }
+
if ($langCode && $langCode != 'en') {
if (file_exists(DOKU_INC."inc/lang/$langCode/lang.php")) {
require(DOKU_INC."inc/lang/$langCode/lang.php");
}
- }
- if (file_exists(DOKU_CONF."lang/$langCode/lang.php")) {
- require(DOKU_CONF."lang/$langCode/lang.php");
+ foreach ($config_cascade['lang']['core'] as $config_file) {
+ if (@file_exists($config_file . "$langCode/lang.php")) {
+ include($config_file . "$langCode/lang.php");
+ }
+ }
}
}
diff --git a/inc/plugin.php b/inc/plugin.php
index dd374a4a4..f632e3dd0 100644
--- a/inc/plugin.php
+++ b/inc/plugin.php
@@ -114,17 +114,29 @@ class DokuWiki_Plugin {
* this function is automatically called by getLang()
*/
function setupLocale() {
- if ($this->localised) return;
+ if($this->localised) return;
- global $conf; // definitely don't invoke "global $lang"
- $path = DOKU_PLUGIN.$this->getPluginName().'/lang/';
+ global $conf, $config_cascade; // definitely don't invoke "global $lang"
+ $path = DOKU_PLUGIN . $this->getPluginName() . '/lang/';
$lang = array();
// don't include once, in case several plugin components require the same language file
- @include($path.'en/lang.php');
- if ($conf['lang'] != 'en') @include($path.$conf['lang'].'/lang.php');
- @include(DOKU_CONF.'plugin_lang/'.$this->getPluginName().'/'.$conf['lang'].'/lang.php');
+ @include($path . 'en/lang.php');
+ foreach($config_cascade['lang']['plugin'] as $config_file) {
+ if(@file_exists($config_file . $this->getPluginName() . '/en/lang.php')) {
+ include($config_file . $this->getPluginName() . '/en/lang.php');
+ }
+ }
+
+ if($conf['lang'] != 'en') {
+ @include($path . $conf['lang'] . '/lang.php');
+ foreach($config_cascade['lang']['plugin'] as $config_file) {
+ if(@file_exists($config_file . $this->getPluginName() . '/' . $conf['lang'] . '/lang.php')) {
+ include($config_file . $this->getPluginName() . '/' . $conf['lang'] . '/lang.php');
+ }
+ }
+ }
$this->lang = $lang;
$this->localised = true;
diff --git a/inc/template.php b/inc/template.php
index f8ec637b3..15854282e 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -1277,15 +1277,28 @@ function tpl_getLang($id) {
static $lang = array();
if(count($lang) === 0) {
- $path = tpl_incdir().'lang/';
+ global $conf, $config_cascade; // definitely don't invoke "global $lang"
+
+ $path = tpl_incdir() . 'lang/';
$lang = array();
- global $conf; // definitely don't invoke "global $lang"
// don't include once
- @include($path.'en/lang.php');
- if($conf['lang'] != 'en') @include($path.$conf['lang'].'/lang.php');
- @include(DOKU_CONF.'template_lang/'.$conf['template'].'/'.$conf['lang'].'/lang.php');
+ @include($path . 'en/lang.php');
+ foreach($config_cascade['lang']['template'] as $config_file) {
+ if(@file_exists($config_file . $conf['template'] . '/en/lang.php')) {
+ include($config_file . $conf['template'] . '/en/lang.php');
+ }
+ }
+
+ if($conf['lang'] != 'en') {
+ @include($path . $conf['lang'] . '/lang.php');
+ foreach($config_cascade['lang']['template'] as $config_file) {
+ if(@file_exists($config_file . $conf['template'] . '/' . $conf['lang'] . '/lang.php')) {
+ include($config_file . $conf['template'] . '/' . $conf['lang'] . '/lang.php');
+ }
+ }
+ }
}
return $lang[$id];
}