| 1 |
<!-- ############################################################################# --> |
| 2 |
<!-- Localization |
| 3 |
<!-- ############################################################################# --> |
| 4 |
<div id="tp-localization"> |
| 5 |
|
| 6 |
<h2>Working with Localizations</h2> |
| 7 |
|
| 8 |
<p>Timepicker comes with many translations and localizations, thanks to all the contributors. They can be found in the i18n folder in the git repo.</p> |
| 9 |
|
| 10 |
<p>The quick and cheap way to use localizations is to pass in options to a timepicker instance:</p> |
| 11 |
|
| 12 |
<pre>$('#example123').timepicker({ |
| 13 |
timeOnlyTitle: 'Выберите время', |
| 14 |
timeText: 'Время', |
| 15 |
hourText: 'Часы', |
| 16 |
minuteText: 'Минуты', |
| 17 |
secondText: 'Секунды', |
| 18 |
currentText: 'Сейчас', |
| 19 |
closeText: 'Закрыть' |
| 20 |
}); |
| 21 |
</pre> |
| 22 |
<p>However, if you plan to use timepicker extensively you will need to include (build your own) localization. It is simply assigning those same variables to an object.</p> |
| 23 |
<p>As you see in the example below we maintain a separate object for timepicker. This way we aren't bound to any future changes within datepicker.</p> |
| 24 |
|
| 25 |
<pre>$.datepicker.regional['ru'] = { |
| 26 |
closeText: 'Закрыть', |
| 27 |
prevText: '<Пред', |
| 28 |
nextText: 'След>', |
| 29 |
currentText: 'Сегодня', |
| 30 |
monthNames: ['Январь','Февраль','Март','Апрель','Май','Июнь', |
| 31 |
'Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'], |
| 32 |
monthNamesShort: ['Янв','Фев','Мар','Апр','Май','Июн', |
| 33 |
'Июл','Авг','Сен','Окт','Ноя','Дек'], |
| 34 |
dayNames: ['воскресенье','понедельник','вторник','среда','четверг','пятница','суббота'], |
| 35 |
dayNamesShort: ['вск','пнд','втр','срд','чтв','птн','сбт'], |
| 36 |
dayNamesMin: ['Вс','Пн','Вт','Ср','Чт','Пт','Сб'], |
| 37 |
weekHeader: 'Не', |
| 38 |
dateFormat: 'dd.mm.yy', |
| 39 |
firstDay: 1, |
| 40 |
isRTL: false, |
| 41 |
showMonthAfterYear: false, |
| 42 |
yearSuffix: '' |
| 43 |
}; |
| 44 |
$.datepicker.setDefaults($.datepicker.regional['ru']); |
| 45 |
|
| 46 |
|
| 47 |
$.timepicker.regional['ru'] = { |
| 48 |
timeOnlyTitle: 'Выберите время', |
| 49 |
timeText: 'Время', |
| 50 |
hourText: 'Часы', |
| 51 |
minuteText: 'Минуты', |
| 52 |
secondText: 'Секунды', |
| 53 |
millisecText: 'Миллисекунды', |
| 54 |
timezoneText: 'Часовой пояс', |
| 55 |
currentText: 'Сейчас', |
| 56 |
closeText: 'Закрыть', |
| 57 |
timeFormat: 'HH:mm', |
| 58 |
amNames: ['AM', 'A'], |
| 59 |
pmNames: ['PM', 'P'], |
| 60 |
isRTL: false |
| 61 |
}; |
| 62 |
$.timepicker.setDefaults($.timepicker.regional['ru']); |
| 63 |
</pre> |
| 64 |
|
| 65 |
<p>Now all you have to do is call timepicker and the Russian localization is used. Generally you only need to include the localization file, it will setDefaults() for you.</p> |
| 66 |
<p>As of version 1.4.5 a combined file of all localizations available is included. This file DOES NOT call setDefaults(), so you will need to pass, or merge with your options.</p> |
| 67 |
|
| 68 |
<pre>$('#example123').timepicker($.timepicker.regional['ru']); |
| 69 |
</pre> |
| 70 |
|
| 71 |
<p>Localization files for datepicker are typically available in your jQueryUI downloads.</p> |
| 72 |
</div> |