-
Notifications
You must be signed in to change notification settings - Fork 364
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
babel-plugin-lingui-extract-messages doesn't work when targeting IE 11 #32
Comments
Thank you for bug report! Unfortunately, I'm not able to replicate it. There's major release coming in next few days, could you please try it? npm install --save lingui-react@next
npm install --save-dev babel-preset-lingui-react@next
npm install --global lingui-cli@next And then run:
Moreover, |
OK. Will test it if the new version is released.
Could it not test if the catalog is up-to-date based on a timestamp cached for every catalog. So that the catalog gets automatically built if something has changed? |
That could work, but still you need a catalog only when extracting messages for translators, not for development. Also, having babel plugin added in |
@akkie I've just published new major version, could you please try if the bug is still there. There're few backward incompatible changes covered in Migration guide. Most of changes are low-level api, only few affects react |
I've just tried following {
"presets": [
[
"env",
{
"targets": {
"browsers": ["ie 11"]
}
}
],
"react",
"lingui-react"
]
} in tutorial repository, but I still get no error. Closing now, feel free to reopen when you have more info. |
I try to migrate to 1.0.1, but for me it's not really clear how a catalog should look like. Previously we had message files in the form:
But now we have a catalog in the form:
Does this mean that the files are now structured like this:
If yes, then this part of the documentation is outdated. |
Yes, good catch, sorry for mistake. It should be: <I18nProvider language="en" catalogs={{ en: { messages } }} development={dev}> (just wrap messages in dictionary) However, it's better to load compiled message catalogs during development, so it works exactly as in production: import catalog from 'locale/en/messages.js'
const App = () => (
<I18nProvider language="en" catalogs={{ en: catalog }} development={dev}>
...
</I18nProvider>
) You can compile catalog with |
Tutorial fixed in #36 |
It's a bit confusing sometimes you use:
and sometimes:
|
I went through docs and it's consistent now. Recommended way is The other way is supported for backward compatibility and when you can't/don't want to compile messages. I should probably remove it from docs completely, so it's less confusing. |
Yes, I think it's better to remove it or to explain the difference between the two file formats. JSON: Source file from which the catalog will be built Anyway, I cannot get the lib to work. Is it normal that the compiled format has the form:
? |
My apologies! I was fixing every little detail before the major release and I forgot to document the most important part: The message catalog is "minified" and need to be unpacked before loaded: import { unpackCatalog } from 'lingui-i18n'
import catalog from 'locale/cs/messages.js'
const App = () => (
<I18nProvider language="cs" catalogs={{ cs: unpackCatalog(catalog) }} development={dev}>
<Inbox />
</I18nProvider>
) Also, take a look at example how to load messages with webpack. It looks way cleaner. |
Thanks 👍
Yea, I use this in a similar manner. If I compile my German messages file, then the compiled catalog contains only the English variant. My source file contains as example:
The compiled catalog contains then:
It seems that it uses the key also as value. |
I see. I was able to replicate this error by using old-style message catalog. Format of message catalog have changed as stated in migration guide (https://lingui.gitbooks.io/js/content/guides/migration-1.html#cli). All you need is run Finally, After running {
"msg.heading": {
"translation": "Ukázková aplikace",
"defaults": "Application Example",
"origin": [
[
"test/fixtures/App.js",
5
]
]
},
"Example of <0>react-trans</0> usage.": {
"translation": "Příklad použití <0>react-trans</0>.",
"origin": [
[
"test/fixtures/App.js",
7
]
]
},
...
} |
Sorry, I should better double check the documentation 😉 Can it be the case that
|
I'm using flow as well without any issues. Is async function fetchCatalog (language: string) {
...
} without
EDIT: Actually, it's different error... |
Yes, it's a class method.
I use neutrino.js which does all the magic. Neutrino pulls in dynamically Any idea for a workaround? |
Isolate {
"lingui": {
"srcPathIgnorePatterns": [
"/node_modules/",
"I18nApi.js$"
]
} Please update to latest lingui-cli@1.0.3. I fixed pattern matching so it excludes also files, not only directories. Does it work for you as a temporary workaround? I don't have any translations inside |
I use flow also in react components, so your proposal won't work. I've created a
Then I can execute I'll ask in the Neutrino.js Slack Channel if there is a way to execute third party commands with the generated babel configuration. |
@tricoder42 Is it intended that the An example: {
"Dashboard": {
"translation": "Dashboard",
"origin": [
[
"src\\components\\MainMenu\\MainMenu.jsx",
86
],
[
"src\\components\\MainMenu\\MainMenu.jsx",
86
],
[
"src\\components\\MainMenu\\MainMenu.jsx",
86
],
[
"src\\components\\MainMenu\\MainMenu.jsx",
86
],
[
"src\\components\\MainMenu\\MainMenu.jsx",
86
]
]
},
...
} |
No, that's definitely bug. |
Fixed in #39, lingui-cli@1.0.4 |
If I add the browser
ie 11
to my babel-preset-env config, then I get some errors if I try to build my application:I'm not sure if this has to do with js-lingui or if it's an issue from another component.
The text was updated successfully, but these errors were encountered: