Neah/node_modules/@nextcloud/l10n/dist/index.js
2025-04-20 12:21:37 +02:00

174 lines
4.1 KiB
JavaScript

"use strict";
require("core-js/modules/es.object.define-property.js");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getCanonicalLocale = getCanonicalLocale;
exports.getDayNames = getDayNames;
exports.getDayNamesMin = getDayNamesMin;
exports.getDayNamesShort = getDayNamesShort;
exports.getFirstDay = getFirstDay;
exports.getLanguage = getLanguage;
exports.getLocale = getLocale;
exports.getMonthNames = getMonthNames;
exports.getMonthNamesShort = getMonthNamesShort;
exports.translate = translate;
exports.translatePlural = translatePlural;
require("core-js/modules/es.regexp.exec.js");
require("core-js/modules/es.string.replace.js");
/// <reference types="@nextcloud/typings" />
/**
* Returns the user's locale
*/
function getLocale() {
return document.documentElement.dataset.locale || 'en';
}
function getCanonicalLocale() {
return getLocale().replace(/_/g, '-');
}
/**
* Returns the user's language
*/
function getLanguage() {
return document.documentElement.lang || 'en';
}
/**
* Translate a string
*
* @param {string} app the id of the app for which to translate the string
* @param {string} text the string to translate
* @param {object} vars map of placeholder key to value
* @param {number} number to replace %n with
* @param {object} [options] options object
* @return {string}
*/
function translate(app, text, vars, count, options) {
if (typeof OC === 'undefined') {
console.warn('No OC found');
return text;
}
return OC.L10N.translate(app, text, vars, count, options);
}
/**
* Translate a plural string
*
* @param {string} app the id of the app for which to translate the string
* @param {string} textSingular the string to translate for exactly one object
* @param {string} textPlural the string to translate for n objects
* @param {number} count number to determine whether to use singular or plural
* @param {Object} vars of placeholder key to value
* @param {object} options options object
* @return {string}
*/
function translatePlural(app, textSingular, textPlural, count, vars, options) {
if (typeof OC === 'undefined') {
console.warn('No OC found');
return textSingular;
}
return OC.L10N.translatePlural(app, textSingular, textPlural, count, vars, options);
}
/**
* Get the first day of the week
*
* @return {number}
*/
function getFirstDay() {
if (typeof window.firstDay === 'undefined') {
console.warn('No firstDay found');
return 1;
}
return window.firstDay;
}
/**
* Get a list of day names (full names)
*
* @return {string[]}
*/
function getDayNames() {
if (typeof window.dayNames === 'undefined') {
console.warn('No dayNames found');
return ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
}
return window.dayNames;
}
/**
* Get a list of day names (short names)
*
* @return {string[]}
*/
function getDayNamesShort() {
if (typeof window.dayNamesShort === 'undefined') {
console.warn('No dayNamesShort found');
return ['Sun.', 'Mon.', 'Tue.', 'Wed.', 'Thu.', 'Fri.', 'Sat.'];
}
return window.dayNamesShort;
}
/**
* Get a list of day names (minified names)
*
* @return {string[]}
*/
function getDayNamesMin() {
if (typeof window.dayNamesMin === 'undefined') {
console.warn('No dayNamesMin found');
return ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
}
return window.dayNamesMin;
}
/**
* Get a list of month names (full names)
*
* @return {string[]}
*/
function getMonthNames() {
if (typeof window.monthNames === 'undefined') {
console.warn('No monthNames found');
return ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
}
return window.monthNames;
}
/**
* Get a list of month names (short names)
*
* @return {string[]}
*/
function getMonthNamesShort() {
if (typeof window.monthNamesShort === 'undefined') {
console.warn('No monthNamesShort found');
return ['Jan.', 'Feb.', 'Mar.', 'Apr.', 'May.', 'Jun.', 'Jul.', 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.'];
}
return window.monthNamesShort;
}
//# sourceMappingURL=index.js.map