From ea3e391b877f90c1c828415972d1a5bf67fffbf5 Mon Sep 17 00:00:00 2001
From: Thomas Citharel
Date: Mon, 19 Mar 2018 18:01:19 +0100
Subject: [PATCH] Fix datepicker locale path Closes #279
Signed-off-by: Thomas Citharel
---
app/inc/smarty.php | 27 +++++++++++++++++++++++++++
tpl/page.tpl | 4 ++--
tpl/part/description_markdown.tpl | 4 ++--
3 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/app/inc/smarty.php b/app/inc/smarty.php
index 90afe4b..e3d6d4b 100644
--- a/app/inc/smarty.php
+++ b/app/inc/smarty.php
@@ -75,3 +75,30 @@ function smarty_modifier_addslashes_single_quote($string) {
function smarty_modifier_html($html) {
return Utils::htmlEscape($html);
}
+
+function smarty_modifier_datepicker_path($lang) {
+ $i = 0;
+ while (!is_file(path_for_datepicker_locale($lang)) && $i < 3) {
+ $lang_arr = explode('-', $lang);
+ if ($lang_arr && count($lang_arr) > 1) {
+ $lang = $lang_arr[0];
+ } else {
+ $lang = 'en';
+ }
+ $i += 1;
+ }
+ return 'js/locales/bootstrap-datepicker.' . $lang . '.js';
+}
+
+function smarty_modifier_locale_2_lang($locale) {
+ $lang_arr = explode('-', $locale);
+ if ($lang_arr && count($lang_arr) > 1) {
+ return $lang_arr[0];
+ } else {
+ return $locale;
+ }
+}
+
+function path_for_datepicker_locale($lang) {
+ return __DIR__ . '/../../js/locales/bootstrap-datepicker.' . $lang . '.js';
+}
diff --git a/tpl/page.tpl b/tpl/page.tpl
index e307e59..f04705d 100644
--- a/tpl/page.tpl
+++ b/tpl/page.tpl
@@ -23,8 +23,8 @@
- {if "en" != $locale}
-
+ {if 'en' != $locale}
+
{/if}
diff --git a/tpl/part/description_markdown.tpl b/tpl/part/description_markdown.tpl
index e2bb823..7a407df 100644
--- a/tpl/part/description_markdown.tpl
+++ b/tpl/part/description_markdown.tpl
@@ -26,9 +26,9 @@
{__('Step 1', 'More informations here:')}
- http://{$locale}.wikipedia.org/wiki/Markdown
+ http://{$locale|locale_2_lang}.wikipedia.org/wiki/Markdown
-
\ No newline at end of file
+