Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hint the user about why compilation fails #191

Closed
machour opened this issue Mar 18, 2018 · 1 comment
Closed

Hint the user about why compilation fails #191

machour opened this issue Mar 18, 2018 · 1 comment

Comments

@machour
Copy link
Contributor

machour commented Mar 18, 2018

Migrating from react-native-i18n to lingui, I needed to automate the catalog conversion a bit.

At some point, I messed up a string in a message.json file, and struggled a bit to find the culprit:

$ lingui compile
Compiling message catalogs…

/Users/didou/js/react-native/git-point/node_modules/messageformat-parser/parser.js:1975
    throw peg$buildStructuredError(
    ^
SyntaxError: Expected [\t-\r \x85‎‏

] or [^\t-\r \x85‎‏

!-/:-@[-\^`{-~¡-§©«¬®°±¶»¿×÷‐-‧‰-‾⁁-⁓⁕-⁞←-⑟─-❵➔-⯿⸀-⹿、-〃〈-〠〰﴾﴿﹅﹆] but "{" found.
    at peg$buildStructuredError (/Users/didou/js/react-native/git-point/node_modules/messageformat-parser/parser.js:392:12)
    at peg$parse (/Users/didou/js/react-native/git-point/node_modules/messageformat-parser/parser.js:1975:11)
    at compile (/Users/didou/js/react-native/git-point/node_modules/@lingui/cli/api/compile.js:74:47)
    at /Users/didou/js/react-native/git-point/node_modules/@lingui/cli/api/compile.js:89:51
    at Array.map (<anonymous>)
    at createCompiledCatalog (/Users/didou/js/react-native/git-point/node_modules/@lingui/cli/api/compile.js:87:56)
    at /Users/didou/js/react-native/git-point/node_modules/@lingui/cli/lingui-compile.js:85:62
    at Array.map (<anonymous>)
    at command (/Users/didou/js/react-native/git-point/node_modules/@lingui/cli/lingui-compile.js:45:18)
    at Object.<anonymous> (/Users/didou/js/react-native/git-point/node_modules/@lingui/cli/lingui-compile.js:109:17)
error An unexpected error occurred: "Command failed.

I managed to find the issue by tracing in lingui-compile:

  "{0} files": {
    "translation": "{{numFiles}} dosieroj",   // <---- {{numFiles}} should be {0} instead
    "origin": [["src/repository/screens/pull-diff.screen.js", 98]]
  },

catching errors from messageformat-parser and outputting something like Error: Invalid string found in locale/eo/messages.json for message "{0} files" would be helpful.

@tricoder42
Copy link
Contributor

Fixed in latest release v2.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants