Writing Language Modules
We offer and support a number of translations for the Mobiscroll library. If you don't find the language you're looking for, no problem. It's easy to create a language file that you can use.
Just create your language file based on the following template:
(function () {
mobiscroll.i18n['en-GB'] = { // Core
rtl: false, // Right to left mode
setText: 'Set',
cancelText: 'Cancel',
clearText: 'Clear',
selectedText: '{count} selected',
selectedPluralText: '{count} selected',
// Datetime component
dateFormat: 'dd/mm/yy',
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
dayNamesMin: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
dayText: 'Day',
hourText: 'Hours',
minuteText: 'Minutes',
monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
monthText: 'Month',
secText: 'Seconds',
amText: 'am',
pmText: 'pm',
timeFormat: 'hh:ii A',
yearText: 'Year',
nowText: 'Now',
// Calendar component
firstDay: 0,
dateText: 'Date',
timeText: 'Time',
calendarText: 'Calendar',
closeText: 'Close',
todayText: 'Today',
prevMonthText: 'Previous Month',
nextMonthText: 'Next Month',
prevYearText: 'Previous Year',
nextYearText: 'Next Year',
// Event calendar
eventText: 'event',
eventsText: 'events',
// Daterange component
fromText: 'Start',
toText: 'End',
// Measurement components
wholeText: 'Whole',
fractionText: 'Fraction',
unitText: 'Unit',
// Numpad date
delimiter: '/',
// Numpad decimal
decimalSeparator: '.',
thousandsSeparator: ',',
// Timer / Timespan component
labels: ['Years', 'Months', 'Days', 'Hours', 'Minutes', 'Seconds', ''],
labelsShort: ['Yrs', 'Mths', 'Days', 'Hrs', 'Mins', 'Secs', ''],
// Timer component
startText: 'Start',
stopText: 'Stop',
resetText: 'Reset',
lapText: 'Lap',
hideText: 'Hide',
// Forms
offText: 'Off',
onText: 'On',
// Listview
backText: 'Back',
undoText: 'Undo'
};
})();
Download the language template file
Save the file in the following format: mobiscroll.i18n.{lang-code}.js
(e.g. mobiscroll.i18n.en-GB.js
).
We recommend the usage of ISO 639-1 language codes with region subtag, if applicable (e.g. 'de' for German, 'en-GB' for British English, 'pt-BR' for Brazilian Portuguese).
Then you can include the saved file after the mobiscroll core (or the combined mobiscroll scripts):
<script src="js/mobiscroll.core.js" type="text/javascript"></script>
<script src="js/mobiscroll.i18n.en-GB.js" type="text/javascript"></script>
Finally, you need to set the lang option to the custom language created:
mobiscroll.settings.lang = 'en-GB';
Mobiscroll Translations are supported by the community. If you have translated mobiscroll to any language, feel free to send a pull request to our GitHub repo or send us an email, so others can also download it as an official mobiscroll translation.