summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-02-08 15:07:47 -0500
committerFrederic Guillot <fred@kanboard.net>2015-02-08 15:07:47 -0500
commitacf3941b4aa95bff9e80aa03e22dc064036e69cf (patch)
treefa00598349637eb125c8eb132f3dd74a2e3e9e6f /app/Model
parent813b7c4c0036a73c3bb5ef31f98e83cce2630e9e (diff)
Improve js and add native language support for datepicker and calendar
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/Config.php53
1 files changed, 47 insertions, 6 deletions
diff --git a/app/Model/Config.php b/app/Model/Config.php
index d078a00a..542cedf7 100644
--- a/app/Model/Config.php
+++ b/app/Model/Config.php
@@ -76,6 +76,52 @@ class Config extends Base
}
/**
+ * Get javascript language code
+ *
+ * @access public
+ * @return string
+ */
+ public function getJsLanguageCode()
+ {
+ $languages = array(
+ 'da_DK' => 'da',
+ 'de_DE' => 'de',
+ 'en_US' => 'en',
+ 'es_ES' => 'es',
+ 'fr_FR' => 'fr',
+ 'it_IT' => 'it',
+ 'hu_HU' => 'hu',
+ 'pl_PL' => 'pl',
+ 'pt_BR' => 'pt-br',
+ 'ru_RU' => 'ru',
+ 'fi_FI' => 'fi',
+ 'sv_SE' => 'sv',
+ 'zh_CN' => 'zh-cn',
+ 'ja_JP' => 'ja',
+ 'th_TH' => 'th',
+ );
+
+ $lang = $this->getCurrentLanguage();
+
+ return isset($languages[$lang]) ? $languages[$lang] : 'en';
+ }
+
+ /**
+ * Get current language
+ *
+ * @access public
+ * @return string
+ */
+ public function getCurrentLanguage()
+ {
+ if ($this->userSession->isLogged() && ! empty($this->session['user']['language'])) {
+ return $this->session['user']['language'];
+ }
+
+ return $this->get('application_language', 'en_US');
+ }
+
+ /**
* Get a config variable from the session or the database
*
* @access public
@@ -152,12 +198,7 @@ class Config extends Base
*/
public function setupTranslations()
{
- if ($this->userSession->isLogged() && ! empty($this->session['user']['language'])) {
- Translator::load($this->session['user']['language']);
- }
- else {
- Translator::load($this->get('application_language', 'en_US'));
- }
+ Translator::load($this->getCurrentLanguage());
}
/**