/
defaults.js
68 lines (58 loc) · 2.45 KB
/
defaults.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
export 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
keySeparator: '.',
nsSeparator: ':',
pluralSeparator: '_',
contextSeparator: '_',
saveMissing: false, // enable to send missing values
saveMissingTo: 'fallback', // 'current' || 'all'
missingKeyHandler: false, // function(lng, ns, key, fallbackValue) -> override if prefer on handling
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() {}, // 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(args) {
return { defaultValue: args[1] };
},
interpolation: {
escapeValue: true,
format: function(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
}
};
}
export 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.push('cimode');
return options;
}