mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-07 23:02:27 +03:00
30 lines
577 B
JavaScript
30 lines
577 B
JavaScript
import enUS from './locale/en';
|
|
|
|
let defaultLocale = 'en';
|
|
const locales = {};
|
|
locales[defaultLocale] = enUS;
|
|
|
|
export function locale(name, object, isLocal) {
|
|
if (typeof name !== 'string') return locales[defaultLocale];
|
|
let l = defaultLocale;
|
|
if (locales[name]) {
|
|
l = name;
|
|
}
|
|
if (object) {
|
|
locales[name] = object;
|
|
l = name;
|
|
}
|
|
if (!isLocal) {
|
|
defaultLocale = l;
|
|
}
|
|
return locales[name] || locales[defaultLocale];
|
|
}
|
|
|
|
/**
|
|
* get locale object
|
|
* @param {string} name lang
|
|
*/
|
|
export function getLocale(name) {
|
|
return locale(name, null, true);
|
|
}
|