Skip to content
William Desportes edited this page Jan 7, 2020 · 8 revisions

Default Options

v0.x

{
    debug: false,
    sort: false,
    lngs: ['en'],
    defaultValue: '',
    resGetPath: 'i18n/__lng__/__ns__.json',
    resSetPath: 'i18n/__lng__/__ns__.json',
    nsseparator: ':',
    keyseparator: '.',
    interpolationPrefix: '__',
    interpolationSuffix: '__',
    ns: {
        namespaces: [],
        defaultNs: 'translation'
    }
}

v1.0

  • Change the default value of interpolation prefix/suffix from __ to {{ and }}
  • Changed interpolationPrefix to interpolation.prefix
  • Changed interpolationSuffix to interpolation.suffix
  • Changed ns.namespaces to ns
  • Changed ns.defaultNs to defaultNs
  • Changed resGetPath to resource.loadPath
  • Changed resSetPath to resource.savePath
  • Renamed nsseparator to nsSeparator
  • Renamed keyseparator to keySeparator
  • Added func for parsing translation function
  • Added attr for parsing HTML attribute
{
    debug: false,
    sort: false,
    attr: {
        list: ['data-i18n'],
        extensions: ['.html', '.htm']
    },
    func: {
        list: ['i18next.t', 'i18n.t'],
        extensions: ['.js', '.jsx']
    },
    lngs: ['en'],
    ns: ['translation'],
    defaultNs: 'translation',
    defaultValue: '',
    resource: {
        loadPath: 'i18n/{{lng}}/{{ns}}.json',
        savePath: 'i18n/{{lng}}/{{ns}}.json',
    },
    nsSeparator: ':',
    keySeparator: '.',
    interpolation: {
        prefix: '{{',
        suffix: '}}'
    }
}

API Changes from v0.x to v1.0

  • parser.parseHashArguments is no longer included. You can copy sample code from here.
  • Renamed parser.parse(key, defaultValue) to parser.set(key, defaultValue) for custom processing
  • Added the following methods:
    • parser.parseFuncFromString(content, [options], [callback])
    • parser.parseAttrFromString(content, [options], [callback])
    • parser.set(key, [defaultValue])
    • parser.get([key], [options])
    • parser.toJSON([options])
Clone this wiki locally