fix #1115. The datapicker is now passed the current locale to localize the datepicker

This commit is contained in:
Reinier Balt 2011-02-25 17:10:33 +01:00
parent a3837cc4e3
commit da93b82b2b
5 changed files with 62 additions and 1 deletions

View file

@ -240,7 +240,7 @@ module ApplicationHelper
end
def generate_i18n_strings
js = ""
js = "i18n_locale='#{I18n.locale}';\n"
js << "i18n = new Array();\n"
%w{
shared.toggle_multi shared.toggle_multi_title
@ -259,4 +259,10 @@ module ApplicationHelper
return js
end
def javascript_tag_for_i18n_datepicker
# do not include en as locale since this the available by default
locales_without_en = I18n::available_locales.find_all{|locale| !(locale.to_s == 'en') }
return javascript_include_tag(locales_without_en.map{|locale| "i18n/jquery.ui.datepicker-#{locale}.js"})
end
end

View file

@ -8,6 +8,7 @@
'jquery.truncator','jquery.jeditable.mini', 'jquery.cookie', 'jquery.blockUI',
'jquery.form','jquery.ui.autocomplete.selectFirst',
:cache => 'jquery-cached' %>
<%= javascript_tag_for_i18n_datepicker %>
<%= javascript_include_tag 'hoverIntent','superfish','application',
'accesskey-hints','niftycube','swfobject',
:cache => 'tracks-cached' %>

View file

@ -973,6 +973,12 @@ function enable_rich_interaction(){
$('input.Date').datepicker({
'dateFormat': dateFormat,
'firstDay': weekStart,
'showButtonPanel': true,
'showWeek': true,
'changeMonth': true,
'changeYear': true,
'maxDate': '+5y',
'minDate': '-1y',
'showAnim': 'fold'
});
@ -1178,6 +1184,8 @@ $(document).ready(function() {
TodoItemsContainer.setup_container_toggles();
$.datepicker.setDefaults($.datepicker.regional[i18n_locale]);
/* enable page specific behavior */
$([ 'IntegrationsPage', 'NotesPage', 'ProjectListPage', 'ContextListPage',
'FeedsPage', 'RecurringTodosPage', 'TodoItems', 'TracksPages',

View file

@ -0,0 +1,23 @@
/* German initialisation for the jQuery UI date picker plugin. */
/* Written by Milian Wolff (mail@milianw.de). */
jQuery(function($){
$.datepicker.regional['de'] = {
closeText: 'schließen',
prevText: '&#x3c;zurück',
nextText: 'Vor&#x3e;',
currentText: 'heute',
monthNames: ['Januar','Februar','März','April','Mai','Juni',
'Juli','August','September','Oktober','November','Dezember'],
monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
'Jul','Aug','Sep','Okt','Nov','Dez'],
dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
weekHeader: 'Wo',
dateFormat: 'dd.mm.yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
$.datepicker.setDefaults($.datepicker.regional['de']);
});

View file

@ -0,0 +1,23 @@
/* Dutch (UTF-8) initialisation for the jQuery UI date picker plugin. */
/* Written by Mathias Bynens <http://mathiasbynens.be/> */
jQuery(function($){
$.datepicker.regional['nl'] = {
closeText: 'Sluiten',
prevText: '←',
nextText: '→',
currentText: 'Vandaag',
monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni',
'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
monthNamesShort: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun',
'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
weekHeader: 'Wk',
dateFormat: 'dd-mm-yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
$.datepicker.setDefaults($.datepicker.regional['nl']);
});