114 lines
3.9 KiB
JavaScript
114 lines
3.9 KiB
JavaScript
"use strict";
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.get = get;
|
|
exports.transformOptions = transformOptions;
|
|
|
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
|
|
function get() {
|
|
return {
|
|
debug: false,
|
|
initImmediate: true,
|
|
ns: ['translation'],
|
|
defaultNS: ['translation'],
|
|
fallbackLng: ['dev'],
|
|
fallbackNS: false,
|
|
// string or array of namespaces
|
|
whitelist: false,
|
|
// array with whitelisted languages
|
|
nonExplicitWhitelist: false,
|
|
load: 'all',
|
|
// | currentOnly | languageOnly
|
|
preload: false,
|
|
// array with preload languages
|
|
simplifyPluralSuffix: true,
|
|
keySeparator: '.',
|
|
nsSeparator: ':',
|
|
pluralSeparator: '_',
|
|
contextSeparator: '_',
|
|
partialBundledLanguages: false,
|
|
// allow bundling certain languages that are not remotely fetched
|
|
saveMissing: false,
|
|
// enable to send missing values
|
|
updateMissing: false,
|
|
// enable to update default values if different from translated value (only useful on initial development, or when keeping code as source of truth)
|
|
saveMissingTo: 'fallback',
|
|
// 'current' || 'all'
|
|
saveMissingPlurals: true,
|
|
// will save all forms not only singular key
|
|
missingKeyHandler: false,
|
|
// function(lng, ns, key, fallbackValue) -> override if prefer on handling
|
|
missingInterpolationHandler: false,
|
|
// function(str, match)
|
|
postProcess: false,
|
|
// string or array of postProcessor names
|
|
returnNull: true,
|
|
// allows null value as valid translation
|
|
returnEmptyString: true,
|
|
// allows empty string value as valid translation
|
|
returnObjects: false,
|
|
joinArrays: false,
|
|
// or string to join array
|
|
returnedObjectHandler: function returnedObjectHandler() {},
|
|
// function(key, value, options) triggered if key returns object but returnObjects is set to false
|
|
parseMissingKeyHandler: false,
|
|
// function(key) parsed a key that was not found in t() before returning
|
|
appendNamespaceToMissingKey: false,
|
|
appendNamespaceToCIMode: false,
|
|
overloadTranslationOptionHandler: function handle(args) {
|
|
var ret = {};
|
|
if ((0, _typeof2.default)(args[1]) === 'object') ret = args[1];
|
|
if (typeof args[1] === 'string') ret.defaultValue = args[1];
|
|
if (typeof args[2] === 'string') ret.tDescription = args[2];
|
|
|
|
if ((0, _typeof2.default)(args[2]) === 'object' || (0, _typeof2.default)(args[3]) === 'object') {
|
|
var options = args[3] || args[2];
|
|
Object.keys(options).forEach(function (key) {
|
|
ret[key] = options[key];
|
|
});
|
|
}
|
|
|
|
return ret;
|
|
},
|
|
interpolation: {
|
|
escapeValue: true,
|
|
format: function format(value, _format, lng) {
|
|
return value;
|
|
},
|
|
prefix: '{{',
|
|
suffix: '}}',
|
|
formatSeparator: ',',
|
|
// prefixEscaped: '{{',
|
|
// suffixEscaped: '}}',
|
|
// unescapeSuffix: '',
|
|
unescapePrefix: '-',
|
|
nestingPrefix: '$t(',
|
|
nestingSuffix: ')',
|
|
// nestingPrefixEscaped: '$t(',
|
|
// nestingSuffixEscaped: ')',
|
|
// defaultVariables: undefined // object that can have values to interpolate on - extends passed in interpolation data
|
|
maxReplaces: 1000 // max replaces to prevent endless loop
|
|
|
|
}
|
|
};
|
|
}
|
|
/* eslint no-param-reassign: 0 */
|
|
|
|
|
|
function transformOptions(options) {
|
|
// create namespace object if namespace is passed in as string
|
|
if (typeof options.ns === 'string') options.ns = [options.ns];
|
|
if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
|
|
if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS]; // extend whitelist with cimode
|
|
|
|
if (options.whitelist && options.whitelist.indexOf('cimode') < 0) {
|
|
options.whitelist = options.whitelist.concat(['cimode']);
|
|
}
|
|
|
|
return options;
|
|
} |