Locales for the Vue Material datepicker
This package provides ~75 locales for the Vue Material datepicker,
i.e. day and month names, date formats and button text (all the properties that are required for
Vue.material.locale
).
All locales combined comprise about 50 kB, ~700 bytes/locale. Locales can be
installed individually or all together.
A simple online example is available here
(example source code).
Installation as ES6 modules
$ npm install @undecaf/vue-material-locales
or
$ yarn add @undecaf/vue-material-locales
Registering individual locales:
import VueMaterialLocales from '@undecaf/vue-material-locales'
import en from '@undecaf/vue-material-locales/dist/locale/en-US'
import de from '@undecaf/vue-material-locales/dist/locale/de'
...
Vue.use(VueMaterialLocales, [ en, de ])
Registering all available locales:
import VueMaterialLocales from '@undecaf/vue-material-locales'
import locales from '@undecaf/vue-material-locales/dist/locale'
...
Vue.use(VueMaterialLocales, locales)
Installation as <script>
Registering individual locales:
<script src="https://cdn.jsdelivr.net/npm/@undecaf/vue-material-locales/dist/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@undecaf/vue-material-locales/dist/locale/en-US/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@undecaf/vue-material-locales/dist/locale/de/index.js"></script>
Registering all available locales:
<script src="https://cdn.jsdelivr.net/npm/@undecaf/vue-material-locales/dist/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@undecaf/vue-material-locales/dist/locale/index.js"></script>
Selecting a locale
vm.$material.selectLocale('de')
vm.$material.selectLocale('en-US')
selectLocale()
returns the language tag that was actually selected, or undefined
if no suitable
locale could be found.
Language tags are treated case-insensitively, and both '-'
and '_'
are valid subtag separators.
If the requested locale is not available, a more specific locale is considered first,
and then a more general one. The search is carried out in registration order:
vm.$material.selectLocale('de-DE')
vm.$material.selectLocale('en')
vm.$material.selectLocale('en-AU')
vm.$material.selectLocale('it')
Fallback locales can be given as additional arguments:
vm.$material.selectLocale('de-AT', 'en')
vm.$material.selectLocale('it', 'de-DE')
vm.$material.selectLocale('it', 'en')
vm.$material.selectLocale('jp', 'it')
List of registered locales
Object vm.$material.locales
contains registered locales by language tag:
{
de: { tag: 'de', },
'en-US': { tag: 'en-US', },
...
}
Credits
Date/time formats are based on the locales of the marvelous date-fns!
License
Software: MIT
Documentation: CC-BY-SA 4.0