@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
57 lines • 1.99 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.useDateTranslationContext = exports.DateTranslationContextProvider = exports.getGlobalTranslations = exports.getTranslations = exports.getLocaleFromString = void 0;
const locale_1 = require("date-fns/locale");
const create_context_1 = require("../util/create-context");
const en_1 = __importDefault(require("../util/i18n/locales/en"));
const nn_1 = __importDefault(require("../util/i18n/locales/nn"));
/** @private */
const getLocaleFromString = (locale = "nb") => {
switch (locale) {
case "nn":
return locale_1.nn;
case "en":
return locale_1.enGB;
default:
return locale_1.nb;
}
};
exports.getLocaleFromString = getLocaleFromString;
/**
* @private
* Temporary for backwards compatibility with locale prop. Can be removed when locale prop has been removed.
*/
const getTranslations = (locale) => {
switch (locale) {
case "nn":
return nn_1.default.DatePicker;
case "en":
case "en-GB":
return en_1.default.DatePicker;
default:
return undefined;
}
};
exports.getTranslations = getTranslations;
/**
* @private
* Temporary for backwards compatibility with locale prop. Can be removed when locale prop has been removed.
*/
const getGlobalTranslations = (locale) => {
switch (locale) {
case "nn":
return nn_1.default.global;
case "en":
case "en-GB":
return en_1.default.global;
default:
return undefined;
}
};
exports.getGlobalTranslations = getGlobalTranslations;
_a = (0, create_context_1.createContext)(), exports.DateTranslationContextProvider = _a[0], exports.useDateTranslationContext = _a[1];
//# sourceMappingURL=Date.locale.js.map