How to use the i18next-conv.i18nextToPo function in i18next-conv

To help you get started, we’ve selected a few i18next-conv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github locize / locize-cli / convertToDesiredFormat.js View on Github external
if (opt.format === 'flat') {
      cb(null, JSON.stringify(flatten(data), null, 2));
      return;
    }
    if (opt.format === 'po' || opt.format === 'gettext') {
      const flatData = flatten(data);

      const gettextOpt = {
        project: 'locize',
        language: lng,
        potCreationDate: lastModified,
        poRevisionDate: lastModified,
        ctxSeparator: '_ is default but we set it to something that is never found!!!',
        persistMsgIdPlural: true
      };
      i18nextToPo(lng, JSON.stringify(flatData), gettextOpt).then((ret) => {
        cb(null, ret.toString());
      }, cb);
      return;
    }
    if (opt.format === 'po_i18next' || opt.format === 'gettext_i18next') {
      i18nextToPo(lng, JSON.stringify(flatten(data)), {
        project: 'locize',
        language: lng,
        potCreationDate: lastModified,
        poRevisionDate: lastModified
      }).then((ret) => {
        cb(null, ret.toString());
      }, cb);
      return;
    }
    if (opt.format === 'csv') {
github locize / locize-cli / convertToDesiredFormat.js View on Github external
const gettextOpt = {
        project: 'locize',
        language: lng,
        potCreationDate: lastModified,
        poRevisionDate: lastModified,
        ctxSeparator: '_ is default but we set it to something that is never found!!!',
        persistMsgIdPlural: true
      };
      i18nextToPo(lng, JSON.stringify(flatData), gettextOpt).then((ret) => {
        cb(null, ret.toString());
      }, cb);
      return;
    }
    if (opt.format === 'po_i18next' || opt.format === 'gettext_i18next') {
      i18nextToPo(lng, JSON.stringify(flatten(data)), {
        project: 'locize',
        language: lng,
        potCreationDate: lastModified,
        poRevisionDate: lastModified
      }).then((ret) => {
        cb(null, ret.toString());
      }, cb);
      return;
    }
    if (opt.format === 'csv') {
      opt.getNamespace(opt, opt.referenceLanguage, namespace, (err, refNs) => {
        if (err) return cb(err);

        const js2CsvData = Object.keys(flatten(data)).reduce((mem, k) => {
          const value = data[k] || '';
          const line = {

i18next-conv

converts .mo and .po files to i18next's json format and vice versa.

MIT
Latest version published 6 months ago

Package Health Score

71 / 100
Full package analysis