Merge branch 'fix-datepicker-locale-path' into 'develop'

Fix datepicker locale path

Closes #279

See merge request framasoft/framadate!242
This commit is contained in:
Thomas Citharel 2018-03-21 14:22:30 +01:00
commit 2991b9e1d3
3 changed files with 30 additions and 4 deletions

View File

@ -75,3 +75,29 @@ function smarty_modifier_addslashes_single_quote($string) {
function smarty_modifier_html($html) { function smarty_modifier_html($html) {
return Utils::htmlEscape($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];
}
return $locale;
}
function path_for_datepicker_locale($lang) {
return __DIR__ . '/../../js/locales/bootstrap-datepicker.' . $lang . '.js';
}

View File

@ -23,8 +23,8 @@
<script type="text/javascript" src="{'js/jquery-1.12.4.min.js'|resource}"></script> <script type="text/javascript" src="{'js/jquery-1.12.4.min.js'|resource}"></script>
<script type="text/javascript" src="{'js/bootstrap.min.js'|resource}"></script> <script type="text/javascript" src="{'js/bootstrap.min.js'|resource}"></script>
<script type="text/javascript" src="{'js/bootstrap-datepicker.js'|resource}"></script> <script type="text/javascript" src="{'js/bootstrap-datepicker.js'|resource}"></script>
{if "en" != $locale} {if 'en' != $locale}
<script type="text/javascript" src="{"js/locales/bootstrap-datepicker.$locale.js"|resource}"></script> <script type="text/javascript" src="{$locale|datepicker_path|resource}"></script>
{/if} {/if}
<script type="text/javascript" src="{'js/core.js'|resource}"></script> <script type="text/javascript" src="{'js/core.js'|resource}"></script>

View File

@ -26,9 +26,9 @@
</p> </p>
<p> <p>
{__('Step 1', 'More informations here:')} {__('Step 1', 'More informations here:')}
<a href="http://{$locale}.wikipedia.org/wiki/Markdown">http://{$locale}.wikipedia.org/wiki/Markdown</a> <a href="http://{$locale|locale_2_lang}.wikipedia.org/wiki/Markdown">http://{$locale|locale_2_lang}.wikipedia.org/wiki/Markdown</a>
</p> </p>
</div> </div>
</div> </div>
</div> </div>
</div> </div>