• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

i18next / i18next / #12544

19 Apr 2018 07:07AM UTC coverage: 87.43% (+2.0%) from 85.448%
#12544

push

jamuhl
rebuild

932 of 1066 relevant lines covered (87.43%)

39.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.12
/src/defaults.js
1
export function get() {
2
  return {
3
    debug: false,
1✔
4
    initImmediate: true,
5

6
    ns: ['translation'],
1✔
7
    defaultNS: ['translation'],
1✔
8
    fallbackLng: ['dev'],
5✔
9
    fallbackNS: false, // string or array of namespaces
10

11
    whitelist: false, // array with whitelisted languages
12
    nonExplicitWhitelist: false,
13
    load: 'all', // | currentOnly | languageOnly
14
    preload: false, // array with preload languages
15

16
    simplifyPluralSuffix: true,
17
    keySeparator: '.',
18
    nsSeparator: ':',
19
    pluralSeparator: '_',
20
    contextSeparator: '_',
21

22
    saveMissing: false, // enable to send missing values
23
    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)
24
    saveMissingTo: 'fallback', // 'current' || 'all'
25
    saveMissingPlurals: true, // will save all forms not only singular key
26
    missingKeyHandler: false, // function(lng, ns, key, fallbackValue) -> override if prefer on handling
27
    missingInterpolationHandler: false, // function(str, match)
28

29
    postProcess: false, // string or array of postProcessor names
30
    returnNull: true, // allows null value as valid translation
31
    returnEmptyString: true, // allows empty string value as valid translation
32
    returnObjects: false,
33
    joinArrays: false, // or string to join array
34
    returnedObjectHandler: () => {}, // function(key, value, options) triggered if key returns object but returnObjects is set to false
35
    parseMissingKeyHandler: false, // function(key) parsed a key that was not found in t() before returning
36
    appendNamespaceToMissingKey: false,
37
    appendNamespaceToCIMode: false,
38
    overloadTranslationOptionHandler: function handle(args) {
39
      const ret = {};
40
      if (args[1]) ret.defaultValue = args[1];
41
      if (args[2]) ret.tDescription = args[2];
42
      return ret;
43
    },
44

45
    interpolation: {
1✔
46
      escapeValue: true,
1✔
47
      format: (value, format, lng) => value,
1✔
48
      prefix: '{{',
1✔
49
      suffix: '}}',
50
      formatSeparator: ',',
51
      // prefixEscaped: '{{',
52
      // suffixEscaped: '}}',
53
      // unescapeSuffix: '',
54
      unescapePrefix: '-',
1✔
55

56
      nestingPrefix: '$t(',
57
      nestingSuffix: ')',
58
      // nestingPrefixEscaped: '$t(',
59
      // nestingSuffixEscaped: ')',
60
      // defaultVariables: undefined // object that can have values to interpolate on - extends passed in interpolation data
61
      maxReplaces: 1000 // max replaces to prevent endless loop
62
    }
63
  };
64
}
65

66
/* eslint no-param-reassign: 0 */
67
export function transformOptions(options) {
68
  // create namespace object if namespace is passed in as string
69
  if (typeof options.ns === 'string') options.ns = [options.ns];
70
  if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
71
  if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
72

73
  // extend whitelist with cimode
74
  if (options.whitelist && options.whitelist.indexOf('cimode') < 0) {
75
    options.whitelist = options.whitelist.concat(['cimode']);
1✔
76
  }
1✔
77

78
  return options;
9✔
79
}
9✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc