Coder Social home page Coder Social logo

i18next-gettext-converter's Introduction

i18next: learn once - translate everywhere Tweet

CI Code Climate Coveralls Package Quality cdnjs version npm version npm

i18next is a very popular internationalization framework for browser or any other javascript environment (eg. Node.js, Deno).

ecosystem

i18next provides:

For more information visit the website:

Our focus is providing the core to building a booming ecosystem. Independent of the building blocks you choose, be it react, angular or even good old jquery proper translation capabilities are just one step away.

Documentation

The general i18next documentation is published on www.i18next.com and PR changes can be supplied here.

The react specific documentation is published on react.i18next.com and PR changes can be supplied here.


Gold Sponsors


From the creators of i18next: localization as a service - locize.com

A translation management system built around the i18next ecosystem - locize.com.

locize

With using locize you directly support the future of i18next.


i18next-gettext-converter's People

Contributors

adeelshahid avatar adrai avatar aherod-as avatar alk-saury avatar dependabot[bot] avatar difelice avatar forfolias avatar ganchenkor avatar glsignal avatar i-k avatar immortal-tofu avatar jamuhl avatar jashment avatar javiermatos avatar jdrobiecki avatar jsomsanith-tlnd avatar jstarpl avatar marsup avatar max-mykhailenko avatar melan avatar olegabr avatar perrin4869 avatar rankida avatar rebeccaalpert avatar redking avatar renchap avatar slb235 avatar stephenash avatar tagoh avatar whyhankee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

i18next-gettext-converter's Issues

Conversion errors

I have notice that I had few conversion issues when using the converter and it might have to do with the architecture of my json.

My json looks like this:

{
  "title": "Table",
  "link_column": "Number/Reference",
  "state_column": "State",
  "type_column": "Type",
  "offer_column": "Offer",
  "date_column": "Creation Date",
  "state_types": [
    {"state": "Connected"},
    {"state": "Disconnected"},
    {"state": "Stalled"},
    {"state": "Unknown"}
  ],
  "type_types": [
    {"type": "ADSL"},
    {"type": "VDSL"},
    {"type": "SDSL"},
    {"type": "FIBER"},
    {"type": "SHARED_FIBER"}
  ]
}

The civilities (not sure if that is a real word) is used for dropdown purposes and as a result, I get this output:

msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2017-06-13T09:50:07.336Z\n"
"PO-Revision-Date: 2017-06-13T09:50:07.336Z\n"
"Language: en\n"

msgid "title"
msgstr "Table"

msgctxt "column"
msgid "link"
msgstr "Number/Reference"

msgctxt "column"
msgid "state"
msgstr "State"

msgctxt "column"
msgid "type"
msgstr "Type"

msgctxt "column"
msgid "offer"
msgstr "Offer"

msgctxt "column"
msgid "date"
msgstr "Creation Date"

msgctxt "types"
msgid "state"
msgstr ""
"[object Object]\n"
"[object Object]\n"
"[object Object]\n"
"[object Object]"

msgctxt "types"
msgid "type"
msgstr ""
"[object Object]\n"
"[object Object]\n"
"[object Object]\n"
"[object Object]\n"
"[object Object]"

Is this type of formatting not possible at all ?

json to po conversion is written as a mo file instead with 0.1.5

With [email protected], I am seeing .po files written with the .mo file format instead. [email protected] did not have this problem.

$ npm install [email protected]
$ ./node_modules/.bin/i18next-conv --quiet -l en -s sample.json -t output-0.1.4.po
$ head -1 output-0.1.4.po
msgid ""

$ npm install [email protected]
$ ./node_modules/.bin/i18next-conv --quiet -l en -s sample.json -t output-0.1.5.po
$ head -1 output-0.1.5.po
??,,<=?C?HelloProject-Id-Version: node-gettext

Sample files and output: https://gist.github.com/stephenash/caac6f17c878589ee5b9

Using --keyasareference with duplicate text breaks when converting back to i18next

I have the an i18next JSON source file that contains duplicate text items for different keys. One instance looks something like this:

{
  "role-a": {
    "step": {
      "intro": "Intro",
    },
  },
  "role-b": {
    "step": {
      "intro": "Intro",
    }
  }
}

I convert this to gettext with

i18next-conv --pot -l en -s source.json -b source.json -t target.pot -K

The resulting source.pot file looks like this:

#: role-a##step##intro role-b##step##intro
msgid "Intro"
msgstr ""

Now translators provide a translation in a tool supporting gettext and I convert it back to i18next JSON with

i18next-conv -l ${locale} -s source.pot -t target.json -K

The resulting i18next JSON looks like this:

{
    "role-a": {
        "step": {
            "intro role-b": {
                "step": {
                    "intro": "Intro"
                }
            },
        }
    }
}

It's wildly different from the original JSON and broken as well.

Now I appreciate that the problem is caused by using the source string as a key which overlaps where the original msgid does not, and in any case, providing one translation for two keys results in ambiguities. However, I was hoping that the conversion would at least allow me to recover the original structure of the JSON. Am I missing something? Or am I asking the impossible?

Pluralisation for languages with multiple plurals is wrong

Right now, the converter (po -> json) returns multiple plurals in the wrong format for i18next (e.g. for Czech):

key_1 # should be key_0
key_3 # should be key_1
key_5 # should be key_2

I am guessing that is because i18next changed their format? The numbers are coming from this file and are set here.

Tracking file path references for each key

(I opened a related issue for the i18next-parser here: i18next/i18next-parser#55)

tldr:

Wanting to add the functionality to track file path references to each key for the purpose of having those comments end up in .po files for our translators to get better context as-needed, requiring modifications both in this repo and in the i18next-parser, and curious how amenable you'd be to merging that sort of thing in?


long form:

I've been helping with some efforts to internationalize a medium-large size Ember app, and since gettext doesn't play nice with html and handlebars, we needed these two repos to generate our translation strings and convert between .json -> .po and vice versa.

But we ran into a slight issue, our translators will need file path references for each key, as comments in the .po files (something that gettext does by default in a typical i18n workflow, except gettext has line numbers, which we won't be needing) and although this repo does have some* ability to add comments, the data structure output by the parser doesn't keep track of those file paths.

Initially I modified the i18next-parser to output something that looks more like:

{
  'some key': {
    msgstr: '',
    paths: ['app/templates/error.hbs', '../fake/path']
  }
}

Where paths is an array of each file path location that a given key is found at, in case you have the same key in multiple places in your source code.

rather than the current output:

{
  'some key': ''
}

and I modified the gettext-converter to handle both formats dynamically while converting from .json -> .po, so you can have keys with file path information and others without, in the same file.

Currently, my little demo of this working involves either symlinking my local changes or pointing our app at my own forks of these two repos, which is less than ideal. I'm hoping to get these changes merged in at some point, so in the past couple days I've gone through and modified my code in the parser to use an additional flag '-t, --track-paths', so it generates the original data structure unless you include that flag and set it to true.

To further support our workflow, since the i18next runtime still needs the original format, I also made it so that using '--track-paths' will prepend '/tmp' to the output location of the translation file but not the translation_old file. So rather than running the parser to get our .json, and then running this tool to get our .po - we are running the parser with --track-paths true to get our new .json format, then running this tool on the output /tmp/locales/en/translation.json to get our .po file, and finally running this tool a second time to go from .po -> .json so that we're back in the original format, and now back in the correct directory as well.

Ideally we'd like to merge these changes back into the repos, rather than maintaining our own forks. I'm doing my best to ensure that this is all opt-in behavior and that it doesn't affect any other workflows that people may be using. Just wanted to put the feelers out there before I get my PR's up. Any feedback is appreciated!

Unble to convert .po file to .json (gettext).

I have installed po2json using
npm install po2json

I am getting below error,

C:\windows\system32>po2json --errorlevel traceback fr.po fr.json
processing 1 files...

po2json: warning: Couldn't handle input file fr.po: Traceback (most recent call
last):

File "translate\misc\optrecurse.pyc", line 513, in recursiveprocess

File "translate\misc\optrecurse.pyc", line 417, in getoutputoptions

ValueError: don't know what to do with input format .po, no template file

where as my fr.po file is

SOME DESCRIPTIVE TITLE.

Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER

This file is distributed under the same license as the PACKAGE package.

FIRST AUTHOR EMAIL@ADDRESS, YEAR.

msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-03-23 22:15+0530\n"
"PO-Revision-Date: 2015-03-23 22:21+0530\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Last-Translator: \n"
"Language-Team: \n"
"X-Generator: Poedit 1.7.4\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"Language: fr\n"

: text.js:794

msgid "Search Files"
msgstr "Search Files FRENCH"

Generate nested JSON from .po

Hey!

Given the following .po key:message structure:

msgid "app.module.key"
msgstr "Some translated content"

I want to generate a JSON file in a format like so:

{
    "app": {
        "module": {
            "key": "Some translated content"
        }
    }
}

Is this possible?

Cheers,
Paul

Reverse generating problem

Generated mo file doesn't work with php gettext and I try to test it. I generate mo file with node converter.i18nextToGettext(languages[lng], source, target, options, callback);. After that I trying to generate json from this mo and got this

> node build/json.js

undefined:1
��
^

SyntaxError: Unexpected token �
    at Object.parse (native)
    at /tmp/node_modules/i18next-conv/lib/gettextWrapper.js:126:45
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:404:3)

npm info lifecycle [email protected]~json: Failed to exec json script
npm ERR! Linux 4.1.19-boot2docker
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "json"
npm ERR! node v5.4.1
npm ERR! npm  v3.3.12
npm ERR! code ELIFECYCLE
npm ERR! [email protected] json: `node build/json.js`
npm ERR! Exit status 1

How I can debug mo in another way or fix this issue?

Undefined is not a function

Hi,

I've played a bit with i18next and had no problem with json. I tried with po/mo files and got a weird error, which does not seem to be linked to my files.
I don't know where this is coming from. I'm running Node under windows.

TypeError: undefined is not a function
    at c:\Users\Deluxe\Dropbox\Moi\Job\CityinvadersCode\cityinvaders-server\node_modules\i18next.gettext\node_modules\i18next-conv\lib\gettextWrapper.js:242:5
    at fs.js:334:14
    at FSReqWrap.oncomplete (fs.js:95:15)

I checked with the debugger, and it seems my keys are correctly readed.

json to po

I think the converter doesn't translate it correctly from i18next format to po.

here is json:

{
  "car": "__count__ car",
  "car_plural": "__count__ cars",
  "book": "I have __count__ book",
  "book_plural": "I have __count__ books"
}

command:

i18next-conv -l ru -s plurals.json -t ru_plurals.po

Output:

msgid ""
msgstr ""
"Project-Id-Version: node-gettext\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"

msgid "car"
msgid_plural "car"
msgstr[0] "__count__ cars"
msgstr[1] "__count__ car"

msgid "book"
msgid_plural "book"
msgstr[0] "I have __count__ books"
msgstr[1] "I have __count__ book"

msgstr[0] and msgstr[1] should have been swapped.

Make options optional

Currently the options argument is required for all functions.

if (!options.quiet) console.log(('\n    --> reading file from: ' + sou
            ^
TypeError: Cannot read property 'quiet' of undefined

The library should check if it's undefined and fallback to empty object.

Plural form generation from .po

I've something like this in my .po :

"Plural-Forms: nplurals=2; plural=(n > 1);\n"

msgid "characters_min"
msgid_plural "characters_min"
msgstr[0] "Au moins un caractère"
msgstr[1] "Au moins {{count}} caractères"

According to the doc I should have in JSON characters_min and characters_min_plural keys.
But in practice what I've is :

    "characters_min_0": "Au moins un caractère",
    "characters_min_1": "Au moins {{count}} caractères",
    "characters_max_0": "Au plus un caractère",
    "characters_max_1": "Au plus {{count}} caractères",

What I need is :

    "characters_min": "Au moins un caractère",
    "characters_min_plural": "Au moins {{count}} caractères",
    "characters_max": "Au plus un caractère",
    "characters_max_plural": "Au plus {{count}} caractères",

Thx

Plural numbers

@jamuhl In the plurals file you have an array of numbers, which doesn't seem to be used at alll except for its length. Do you know if it is safe to remove then? What was it used for?

Plural & singular form are flipped when PO -> JSON

msgid "a##apple"
msgid_plural "a##apple"
msgstr[0] "I have an apple"
msgstr[1] "I have {count} apples"

become

    "a": {
        "apple_plural": "I have an apple",
        "apple": "I have {count} apples",
        "apple_negative": "I have no apples"
    },

After conversion.

npm install fails

Hi,

I'm getting this iconv error on my osx 10.6.8:

npm ERR! [email protected] preinstall: node-waf configure
npm ERR! sh "-c" "node-waf configure" failed with 127
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the iconv package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-waf configure
npm ERR! You can get their info via:
npm ERR! npm owner ls iconv
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 10.8.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "[email protected]" "-g"
npm ERR! cwd /Users/*****
npm ERR! node -v v0.10.0
npm ERR! npm -v 1.2.14
npm ERR! code ELIFECYCLE

Creating JSON for sprintf evaluated keys that are also plurals

Hey,

I have an issue with the PO parse for translations that should be evaluated via sprintf but also contain plural rules.

For example, consider the following translation

## FR
msgid "Il y a %s minute"
msgid_plural "Il y a %s minutes"
msgstr[0] "Il y a %s minute"
msgstr[1] "Il y a %s minutes"

This will produce the following JSON

{
 "Il y a %s minute": "Il y a %s minute",
 "Il y a %s minute_plural": "Il y a %s minutes",
}

I setup i18next with the sprintf post-processor. However, I always get the singular form when evaluating the key

i18n.t('ll y a %s minute', '1'); // Il y a 1 minute
i18n.t('Il y a %s minute', '10'); // Il y a 10 minute <-- Incorrect 

My remarks are

  1. I assume this is a limitation with i18next, that we cannot have a sprintf evaluated key that also manages plurals? (The sprintf evaluation only accepts strings of course - pass in the number 0 and the key is returned unparsed)
  2. If so, I think is still an issue with the parser as it produces JSON that does not work with i18next as expected.

The workaround, for the moment, is to rewrite the plural keys to use i18next double-underscore syntax and then to evaluate the key with a JSON object. It's a bit of a pity however, as it introduces a new syntax into our PO files that does not match that used on the server-side.

Stream support?

It would be awesome if this library accepted vinyl streams as sources. Then we could pass it the results from i18next-parser without creating partial result directories

New fuzzy check (v7.1.0) crashes if message has no comments

If you have a PO file that contains messages that do not have comments then it crashes with:

TypeError: Cannot read property 'flag' of undefined
    at isFuzzy (node_modules/i18next-conv/lib/gettext2json.js:182:31)
    at Object.keys.forEach.key (node_modules/i18next-conv/lib/gettext2json.js:105:39)
    at Array.forEach (<anonymous>)
    at Object.keys.forEach.m (node_modules/i18next-conv/lib/gettext2json.js:94:26)
    at Array.forEach (<anonymous>)
    at parseJSON (node_modules/i18next-conv/lib/gettext2json.js:92:21)
    at addTextLocale.then.data (node_modules/i18next-conv/lib/gettext2json.js:18:12)
    at tryCatcher (node_modules/bluebird/js/release/util.js:16:23)

The bug was added in #75

PR coming shortly...

generate pot file from cli

can you please provide a functioning example for generating a .pot file.
I tried to execute the command with all necessary parameters:

i18next-conv --pot -l en -s 'path/to/file' -b 'path/to/file' -K

produces:
start converting --> reading file from: ..../file.json <-- writing file to: ..../en/file.po file written

Untranslated entries are converted to empty strings

Hi, it seems that if I run i18next-conv on a .po file that has some untranslated entries, it will produce a json where the translation part is empty. This will make i18next to translate to an empty string. Is there a way to skip untranslated entries from being placed into the resulting json (so I can use the fallback methods provided by i18next)?

Error: Symbol iconv_module not found.

I am trying to run but get this error:

☺ i18next-conv -h

module.js:356
  Module._extensions[extension](this, filename);
                               ^
Error: Symbol iconv_module not found.
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/usr/local/share/npm/lib/node_modules/i18next-conv/node_modules/node-gettext/lib/domain.js:1:75)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

iconv is installed

☺  npm list iconv -g                                                                 ruby-2.0.0-p195""
npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/npmconf/node_modules/config-chain requires ini@'1' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
/usr/local/lib
├─┬ [email protected]
│ └─┬ [email protected]
│   └── [email protected]
└── [email protected]

any advice much appreciated

.po to .json conversion

Hi there,

in the readme it says:

"i18next-conv converts files from gettext (.mo/.po) to i18next's json format and vice versa."

any not documented way of do the "vice versa" part? :) I need to convert the .json to .po to give to the
translators but I'm unable to find the way.

Thanks in adavance.

Diego.

Could 'gettextToI18next' function be synchronous?

I would like to use this function in 'parse' function of 'backend' option of i18n.init({}) function, but 'parse' function cannot return Promise.

Something like this:

import i18n from "i18next";
import XHR from "i18next-xhr-backend";
import { gettextToI18next } from "i18next-conv";

i18n.use(XHR).init({
    lng: "sk",
    fallbackLng: "sk",
    debug: process.env.REACT_APP_ENV === "development",
    ns: ["parameter", "parametervalue"],
    backend: {
        loadPath: "i18n/json/{{ns}}.{{lng}}.json",
        parse: data => {
            return gettextToI18next("sk", data, {});
        }
    }
});

export default i18n;

return Promise.resolve(gt.catalogs[locale] && gt.catalogs[locale][domain].translations);

Convert all .po files in directory

I have a suggestion to simplify batch processing of translations.

Given the files

translations/en-US.po
translations/sv-SE.po

i18next-conv -s translations/ should generate

locales/en-US/translation.json
locales/sv-SE/translation.json

ignore fuzzy entries

Hi, is it possible to convert from .po to json ignoring fuzzy entries?

Thanks

Expose programmatic interface

It would be neat if we could convert things into each other without requiring the files to exist as a necessity. I made a (pretty hacky) fork for it here, but I would appreciate this functionality in the main module. :)

If you would like to get a PR for this, let me know.

Also on a sidenote, the docs + code formatting could use some work, I'd put up a PR for that too if you like

Google Translation Toolkit and Poedit

Two renowned solutions I guess, that both take .po files yet choke on the output generated by this tool. Am I doing something wrong? Is this a different format? Google says "Document does not have translatable content" and Poedit complains "File cannot be opened".

Obviously adding "UTF" takes/text as mentioned in the README doesn't work. The entire header of the document is garbled/binary and dumping a plain text line like that is likely not what is required.

Please advice

CLI Problems

-ks does not work as an option, error produced: error: unknown option '-k'
--keyseparator works as intended.

--project stops all processing #57 (comment)

i18next-conv: 4.0.1

output incompatible with i18next 2.0

this plugin doesn't work with the new version of i18next. For instance, in the current version multiple plural forms are parsed like this:

{           
  "ar": { 
    "translation": {  
      "key": "singular",
      "key_plural_0": "zero",
      "key_plural_2": "two",
      "key_plural_3": "few",
      "key_plural_11": "many",
      "key_plural_100": "plural"
    } 
  }
};

but i18n 2.0 expects something like this:

{
  "ar": {
    "translation": {
      "key_0": "zero",
      "key_1": "singular",
      "key_2": "two",
      "key_3": "few",
      "key_11": "many",
      "key_100": "plural"
    }
  }
}

Wrong `Plural-Forms` for Brazilian Portuguese

Hi. Thanks for this great tools!

I have encountered an issue when trying to generate a PO file for Brazilian Portugal. This may be user, error, but this is what I see:

I run

./node_modules/.bin/i18next-conv -l pt_br -s hello.json -t hello.po

where hello.json is nothing more than { "Hello": "Olá" } and I get a PO file with

"Plural-Forms: nplurals=2; plural=(n != 1)\n"

The issue is that for Brazillian Portuguese it should be nplurals=( n > 1), and it is correct in plurals.json here https://github.com/i18next/i18next-gettext-converter/blob/master/src/lib/plurals.js#L494-L498

I have tried using pt-BR or pt-br but they both give me the regular Portuguese plural forms.

I suspect the problem is down to this line

const ext = plurals.rules[locale.replace('_', '-').split('-')[0]];

const ext = plurals.rules[locale.replace('_', '-').split('-')[0]];

i18next variable interpolation

I convert my .po file using this lib but I have problem using interpolation in i18next.

for example my .po file is:

  msgid: "Date: {date}"
  msgstr: "foo: {date}"

I use it like this i18next.t('Date: {date}', {date: '2017/2/2'}) but it doesn't work.

Don't automatically reorganize order of entries

I have the entries in my PO files organized according to the page they're used on. When I use the converter it automatically alphabetizes all the entries, causing me to lose the structure of my PO files. If there could be an option to not sort the keys alphabetically that would be very helpful.

Deprecate filter option

I don't see the value of having filter in the core library, since you could actually filter the translations yourself after completion...
Any opinions @jamuhl?

Passing options to `GettextParser.po` compiler in `i18nextToGettext`

Hello, everyone, sorry if this issue was created somewhere, I tried to searching through the list but did not find anything relevant.

The problem I've encountered is that when I'm trying to parse json -> po I get the following output of po file:

msgid "Accept offer note"
msgstr ""
"Jetzt bräuchten wir noch ein paar Informationen von Ihnen um die Bestellung "
"abzuschliessen."

whereas expected output would be:

msgid "Accept offer note"
msgstr "Jetzt bräuchten wir noch ein paar Informationen von Ihnen um die Bestellung abzuschliessen."

I've dug deep into the library and found out that pocompiler which is used by gettext-parser has a default of 76 foldLength of a string, that's why you get such result.

It seems that when i18nextToGettext passes the data into parser.compile it is not possible to pass any options for the compiler itself, which imo would be awesome to have! Or at least default foldLength to 0 (disable) because this is, imho, is an opinionated feature.

Or maybe there's a workaround? Because right now we have a bunch of translation keys which are longer than 76 chars and our translation service does not accept "invalid" po files

Could someone clarify if it's an issue at all?

Install fails if there is no python installed.

The docs doesn't say anything about python

Here is the log

C:\Users\alone_000\AppData\Roaming\npm\node_modules\i18next-conv\node_modules\node-gettext\node_modules\iconv>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..
\node_modules\node-gyp\bin\node-gyp.js" rebuild
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:113:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:81:11
gyp ERR! stack     at Object.oncomplete (fs.js:107:15)
gyp ERR! System Windows_NT 6.2.9200
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\alone_000\AppData\Roaming\npm\node_modules\i18next-conv\node_modules\node-gettext\node_modules\iconv
gyp ERR! node -v v0.10.8
gyp ERR! node-gyp -v v0.9.5
gyp ERR! not ok
npm ERR! weird error 1
npm ERR! not ok code 0

Newlines in msgstr are wrongly converted to .json

The problem occurs when there's a msgstr that end with a newline. For instance, when my .po file contains:

msgid "key"
msgstr "My string.\n"

When I try to convert from .po to .json, I'm expecting the following output

        "key": "My string."

but instead I'm getting

        "key": [
            "My string.",
            ""
        ]

Can you trim the strings before conversion?

Thanks!

TypeError: Cannot read property '_translationTable' of undefined

I am facing this error while building compiling the source. Would highly appreciate your help.

--> reading file from: src/www/locales/zh-TW1/translation.po

/usr/local/lib/node_modules/i18next-conv/lib/gettextWrapper.js:218
callback(null, gt._domains[domain]._translationTable);
^
TypeError: Cannot read property '_translationTable' of undefined
at /usr/local/lib/node_modules/i18next-conv/lib/gettextWrapper.js:218:39
at fs.js:266:14
at Object.oncomplete (fs.js:107:15)

Wrong conversion .po to .json

Hi,
i have this situation:
my .po file contains something like that '\303\250' ('è' in Italian language), and when i convert the .po file into json its contains something like that '303250'...the backslash was ignored.
While when i try to convert .mo file (generated by msgfmt python module) to .json is correct and in the output file i found 'è'.

Bye
Gabriele

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.