215 lines
No EOL
6.3 KiB
JavaScript
215 lines
No EOL
6.3 KiB
JavaScript
"use strict";
|
||
|
||
Object.defineProperty(exports, "__esModule", {
|
||
value: true
|
||
});
|
||
exports.default = void 0;
|
||
exports.numberToLocale = numberToLocale;
|
||
|
||
var _index = _interopRequireDefault(require("../../../_lib/buildLocalizeFn/index.js"));
|
||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
||
var numberValues = {
|
||
locale: {
|
||
'1': 'ā§§',
|
||
'2': 'ā§¨',
|
||
'3': 'ā§Š',
|
||
'4': 'ā§Ē',
|
||
'5': 'ā§Ģ',
|
||
'6': 'ā§Ŧ',
|
||
'7': 'ā§',
|
||
'8': 'ā§Ž',
|
||
'9': 'ā§¯',
|
||
'0': 'ā§Ļ'
|
||
},
|
||
number: {
|
||
'ā§§': '1',
|
||
'ā§¨': '2',
|
||
'ā§Š': '3',
|
||
'ā§Ē': '4',
|
||
'ā§Ģ': '5',
|
||
'ā§Ŧ': '6',
|
||
'ā§': '7',
|
||
'ā§Ž': '8',
|
||
'ā§¯': '9',
|
||
'ā§Ļ': '0'
|
||
}
|
||
};
|
||
var eraValues = {
|
||
narrow: ['āĻā§āĻ°āĻŋāĻāĻĒā§āĻ', 'āĻā§āĻ°āĻŋāĻ'],
|
||
abbreviated: ['āĻā§āĻ°āĻŋāĻāĻĒā§āĻ°ā§āĻŦ', 'āĻā§āĻ°āĻŋāĻ'],
|
||
wide: ['āĻā§āĻ°āĻŋāĻ¸ā§āĻāĻĒā§āĻ°ā§āĻŦ', 'āĻā§āĻ°āĻŋāĻ¸ā§āĻāĻžāĻŦā§āĻĻ']
|
||
};
|
||
var quarterValues = {
|
||
narrow: ['ā§§', 'ā§¨', 'ā§Š', 'ā§Ē'],
|
||
abbreviated: ['ā§§āĻ¤ā§āĻ°ā§', 'ā§¨āĻ¤ā§āĻ°ā§', 'ā§ŠāĻ¤ā§āĻ°ā§', 'ā§ĒāĻ¤ā§āĻ°ā§'],
|
||
wide: ['ā§§āĻŽ āĻ¤ā§āĻ°ā§āĻŽāĻžāĻ¸āĻŋāĻ', 'ā§¨ā§ āĻ¤ā§āĻ°ā§āĻŽāĻžāĻ¸āĻŋāĻ', 'ā§Šā§ āĻ¤ā§āĻ°ā§āĻŽāĻžāĻ¸āĻŋāĻ', 'ā§ĒāĻ°ā§āĻĨ āĻ¤ā§āĻ°ā§āĻŽāĻžāĻ¸āĻŋāĻ']
|
||
};
|
||
var monthValues = {
|
||
narrow: ['āĻāĻžāĻ¨ā§', 'āĻĢā§āĻŦā§āĻ°ā§', 'āĻŽāĻžāĻ°ā§āĻ', 'āĻāĻĒā§āĻ°āĻŋāĻ˛', 'āĻŽā§', 'āĻā§āĻ¨', 'āĻā§āĻ˛āĻžāĻ', 'āĻāĻāĻ¸ā§āĻ', 'āĻ¸ā§āĻĒā§āĻ', 'āĻ
āĻā§āĻā§', 'āĻ¨āĻā§', 'āĻĄāĻŋāĻ¸ā§'],
|
||
abbreviated: ['āĻāĻžāĻ¨ā§', 'āĻĢā§āĻŦā§āĻ°ā§', 'āĻŽāĻžāĻ°ā§āĻ', 'āĻāĻĒā§āĻ°āĻŋāĻ˛', 'āĻŽā§', 'āĻā§āĻ¨', 'āĻā§āĻ˛āĻžāĻ', 'āĻāĻāĻ¸ā§āĻ', 'āĻ¸ā§āĻĒā§āĻ', 'āĻ
āĻā§āĻā§', 'āĻ¨āĻā§', 'āĻĄāĻŋāĻ¸ā§'],
|
||
wide: ['āĻāĻžāĻ¨ā§ā§āĻžāĻ°āĻŋ', 'āĻĢā§āĻŦā§āĻ°ā§ā§āĻžāĻ°āĻŋ', 'āĻŽāĻžāĻ°ā§āĻ', 'āĻāĻĒā§āĻ°āĻŋāĻ˛', 'āĻŽā§', 'āĻā§āĻ¨', 'āĻā§āĻ˛āĻžāĻ', 'āĻāĻāĻ¸ā§āĻ', 'āĻ¸ā§āĻĒā§āĻā§āĻŽā§āĻŦāĻ°', 'āĻ
āĻā§āĻā§āĻŦāĻ°', 'āĻ¨āĻā§āĻŽā§āĻŦāĻ°', 'āĻĄāĻŋāĻ¸ā§āĻŽā§āĻŦāĻ°']
|
||
};
|
||
var dayValues = {
|
||
narrow: ['āĻ°', 'āĻ¸ā§', 'āĻŽ', 'āĻŦā§', 'āĻŦā§', 'āĻļā§', 'āĻļ'],
|
||
short: ['āĻ°āĻŦāĻŋ', 'āĻ¸ā§āĻŽ', 'āĻŽāĻā§āĻāĻ˛', 'āĻŦā§āĻ§', 'āĻŦā§āĻš', 'āĻļā§āĻā§āĻ°', 'āĻļāĻ¨āĻŋ'],
|
||
abbreviated: ['āĻ°āĻŦāĻŋ', 'āĻ¸ā§āĻŽ', 'āĻŽāĻā§āĻāĻ˛', 'āĻŦā§āĻ§', 'āĻŦā§āĻš', 'āĻļā§āĻā§āĻ°', 'āĻļāĻ¨āĻŋ'],
|
||
wide: ['āĻ°āĻŦāĻŋāĻŦāĻžāĻ°', 'āĻ¸ā§āĻŽāĻŦāĻžāĻ°', 'āĻŽāĻā§āĻāĻ˛āĻŦāĻžāĻ°', 'āĻŦā§āĻ§āĻŦāĻžāĻ°', 'āĻŦā§āĻšāĻ¸ā§āĻĒāĻ¤āĻŋāĻŦāĻžāĻ° ', 'āĻļā§āĻā§āĻ°āĻŦāĻžāĻ°', 'āĻļāĻ¨āĻŋāĻŦāĻžāĻ°']
|
||
};
|
||
var dayPeriodValues = {
|
||
narrow: {
|
||
am: 'āĻĒā§',
|
||
pm: 'āĻ
āĻĒ',
|
||
midnight: 'āĻŽāĻ§ā§āĻ¯āĻ°āĻžāĻ¤',
|
||
noon: 'āĻŽāĻ§ā§āĻ¯āĻžāĻšā§āĻ¨',
|
||
morning: 'āĻ¸āĻāĻžāĻ˛',
|
||
afternoon: 'āĻŦāĻŋāĻāĻžāĻ˛',
|
||
evening: 'āĻ¸āĻ¨ā§āĻ§ā§āĻ¯āĻž',
|
||
night: 'āĻ°āĻžāĻ¤'
|
||
},
|
||
abbreviated: {
|
||
am: 'āĻĒā§āĻ°ā§āĻŦāĻžāĻšā§āĻ¨',
|
||
pm: 'āĻ
āĻĒāĻ°āĻžāĻšā§āĻ¨',
|
||
midnight: 'āĻŽāĻ§ā§āĻ¯āĻ°āĻžāĻ¤',
|
||
noon: 'āĻŽāĻ§ā§āĻ¯āĻžāĻšā§āĻ¨',
|
||
morning: 'āĻ¸āĻāĻžāĻ˛',
|
||
afternoon: 'āĻŦāĻŋāĻāĻžāĻ˛',
|
||
evening: 'āĻ¸āĻ¨ā§āĻ§ā§āĻ¯āĻž',
|
||
night: 'āĻ°āĻžāĻ¤'
|
||
},
|
||
wide: {
|
||
am: 'āĻĒā§āĻ°ā§āĻŦāĻžāĻšā§āĻ¨',
|
||
pm: 'āĻ
āĻĒāĻ°āĻžāĻšā§āĻ¨',
|
||
midnight: 'āĻŽāĻ§ā§āĻ¯āĻ°āĻžāĻ¤',
|
||
noon: 'āĻŽāĻ§ā§āĻ¯āĻžāĻšā§āĻ¨',
|
||
morning: 'āĻ¸āĻāĻžāĻ˛',
|
||
afternoon: 'āĻŦāĻŋāĻāĻžāĻ˛',
|
||
evening: 'āĻ¸āĻ¨ā§āĻ§ā§āĻ¯āĻž',
|
||
night: 'āĻ°āĻžāĻ¤'
|
||
}
|
||
};
|
||
var formattingDayPeriodValues = {
|
||
narrow: {
|
||
am: 'āĻĒā§',
|
||
pm: 'āĻ
āĻĒ',
|
||
midnight: 'āĻŽāĻ§ā§āĻ¯āĻ°āĻžāĻ¤',
|
||
noon: 'āĻŽāĻ§ā§āĻ¯āĻžāĻšā§āĻ¨',
|
||
morning: 'āĻ¸āĻāĻžāĻ˛',
|
||
afternoon: 'āĻŦāĻŋāĻāĻžāĻ˛',
|
||
evening: 'āĻ¸āĻ¨ā§āĻ§ā§āĻ¯āĻž',
|
||
night: 'āĻ°āĻžāĻ¤'
|
||
},
|
||
abbreviated: {
|
||
am: 'āĻĒā§āĻ°ā§āĻŦāĻžāĻšā§āĻ¨',
|
||
pm: 'āĻ
āĻĒāĻ°āĻžāĻšā§āĻ¨',
|
||
midnight: 'āĻŽāĻ§ā§āĻ¯āĻ°āĻžāĻ¤',
|
||
noon: 'āĻŽāĻ§ā§āĻ¯āĻžāĻšā§āĻ¨',
|
||
morning: 'āĻ¸āĻāĻžāĻ˛',
|
||
afternoon: 'āĻŦāĻŋāĻāĻžāĻ˛',
|
||
evening: 'āĻ¸āĻ¨ā§āĻ§ā§āĻ¯āĻž',
|
||
night: 'āĻ°āĻžāĻ¤'
|
||
},
|
||
wide: {
|
||
am: 'āĻĒā§āĻ°ā§āĻŦāĻžāĻšā§āĻ¨',
|
||
pm: 'āĻ
āĻĒāĻ°āĻžāĻšā§āĻ¨',
|
||
midnight: 'āĻŽāĻ§ā§āĻ¯āĻ°āĻžāĻ¤',
|
||
noon: 'āĻŽāĻ§ā§āĻ¯āĻžāĻšā§āĻ¨',
|
||
morning: 'āĻ¸āĻāĻžāĻ˛',
|
||
afternoon: 'āĻŦāĻŋāĻāĻžāĻ˛',
|
||
evening: 'āĻ¸āĻ¨ā§āĻ§ā§āĻ¯āĻž',
|
||
night: 'āĻ°āĻžāĻ¤'
|
||
}
|
||
};
|
||
|
||
function dateOrdinalNumber(number, localeNumber) {
|
||
if (number > 18 && number <= 31) {
|
||
return localeNumber + 'āĻļā§';
|
||
} else {
|
||
switch (number) {
|
||
case 1:
|
||
return localeNumber + 'āĻ˛āĻž';
|
||
|
||
case 2:
|
||
case 3:
|
||
return localeNumber + 'āĻ°āĻž';
|
||
|
||
case 4:
|
||
return localeNumber + 'āĻ āĻž';
|
||
|
||
default:
|
||
return localeNumber + 'āĻ';
|
||
}
|
||
}
|
||
}
|
||
|
||
var ordinalNumber = function ordinalNumber(dirtyNumber, options) {
|
||
var number = Number(dirtyNumber);
|
||
var localeNumber = numberToLocale(number);
|
||
var unit = options === null || options === void 0 ? void 0 : options.unit;
|
||
|
||
if (unit === 'date') {
|
||
return dateOrdinalNumber(number, localeNumber);
|
||
}
|
||
|
||
if (number > 10 || number === 0) return localeNumber + 'āĻ¤āĻŽ';
|
||
var rem10 = number % 10;
|
||
|
||
switch (rem10) {
|
||
case 2:
|
||
case 3:
|
||
return localeNumber + 'ā§';
|
||
|
||
case 4:
|
||
return localeNumber + 'āĻ°ā§āĻĨ';
|
||
|
||
case 6:
|
||
return localeNumber + 'āĻˇā§āĻ ';
|
||
|
||
default:
|
||
return localeNumber + 'āĻŽ';
|
||
}
|
||
}; // function localeToNumber(locale: string): number {
|
||
// const enNumber = locale.toString().replace(/[ā§§ā§¨ā§Šā§Ēā§Ģā§Ŧā§ā§Žā§¯ā§Ļ]/g, function (match) {
|
||
// return numberValues.number[match as keyof typeof numberValues.number]
|
||
// })
|
||
// return Number(enNumber)
|
||
// }
|
||
|
||
|
||
function numberToLocale(enNumber) {
|
||
return enNumber.toString().replace(/\d/g, function (match) {
|
||
return numberValues.locale[match];
|
||
});
|
||
}
|
||
|
||
var localize = {
|
||
ordinalNumber: ordinalNumber,
|
||
era: (0, _index.default)({
|
||
values: eraValues,
|
||
defaultWidth: 'wide'
|
||
}),
|
||
quarter: (0, _index.default)({
|
||
values: quarterValues,
|
||
defaultWidth: 'wide',
|
||
argumentCallback: function argumentCallback(quarter) {
|
||
return quarter - 1;
|
||
}
|
||
}),
|
||
month: (0, _index.default)({
|
||
values: monthValues,
|
||
defaultWidth: 'wide'
|
||
}),
|
||
day: (0, _index.default)({
|
||
values: dayValues,
|
||
defaultWidth: 'wide'
|
||
}),
|
||
dayPeriod: (0, _index.default)({
|
||
values: dayPeriodValues,
|
||
defaultWidth: 'wide',
|
||
formattingValues: formattingDayPeriodValues,
|
||
defaultFormattingWidth: 'wide'
|
||
})
|
||
};
|
||
var _default = localize;
|
||
exports.default = _default; |