-
Notifications
You must be signed in to change notification settings - Fork 394
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
messages.json is looking different than in documentation #53
Comments
That's definitely a bug. Tutorial is outdated, that format was using in |
Ah, so this is meant to be correct. It is however far less user-friendly for a translator - a lot of unneccessary cruft for somebody, who should just translate the strings. Could there be a switch (eg. |
There might be a switch I change the format, because I needed default message. When translator gets a message catalog with keys like What do you think about the |
Your solution is even better, however I am currently too busy to improve your lib. I convinced my boss to use jsLingui on new projects instead of react-i18n we used on others, mainly because of lingui-cli, which seemed awesome, however there were several bugs that I reported and I spent with it a whole day getting it to work. This project seems very promising though, few more features in my head and it could be the ultimate translation tool... |
Sounds good. Don't worry, I'm gonna spend some time on grooming jsLingui issues, so I'll probably sweep this one as well. If you still had some spare time, I'm curious what were the biggest blockers/pain points when you were implementing this (except for the bugs you've already reported). |
The bad thing is, that when using a stable non-beta library (>= 1.0), I do not expect any bugs during simple stuff, so I always expected, that Im doing something wrong, so there was a LOT of debugging and breaking code into pieces... Except from what I have reported, I spent a lot of time trying to achieve having some translated texts in a separate config file, eg. export default [
[route: '/', title: 'Homepage'],
[route: '/about', title: 'About'],
...etc
] and then translate the title in components that import this config const title = i18n.t([route.title]) I tried to bypass your variable-aware translation system by passing an array to the t function, instead of using it as tag, I even created a mock i18n object in the config file in order to get them into extracted translations, however after many tries it just didnt work, so I had to stick with having these lists directly in components... I will post some feature requests regarding this. I believe it would be very beneficial to have an alternate way to translate texts, without the variable and node separation. Eg. |
Use However, this way the message won't be extracted. I need to add sth like export default [
[route: '/', title: i18n.noop('Homepage')],
[route: '/about', title: i18n.noop('About')],
...etc
] And later you would use: const title = i18n._(route.title)
// or
<Trans id={route.title} /> Good points anyway. Thank you and sorry for any inconveniences. |
Nice, I should have asked :)
import helper from 'lingui-react/helper'
export default [
[route: '/', title: helper.markForExtraction('Homepage')],
[route: '/about', title: helper.markForExtraction('About')],
...etc
] |
I don't understand what you mean. Either you use message IDs or source language as IDs: export default [
[route: '/', title: noop('Homepage')],
[route: '/about', title: noop('About')],
] or export default [
[route: '/', title: noop('routes.Homepage.title')],
[route: '/about', title: noop('routes.About.title')],
] In both cases What might be missing in second example is default message, but we could use the same function signature as i18n.t('translation.title', { values: { variable: '42' } })
// or
<Trans id="translation.title" values={{ variable: '42' }} />
You're absolutely right. Simple import { noop } from 'lingui-i18n'
// or
// import { noop } from 'lingui-react'
// this import and noop call will be removed after transformation anyway
export default [
[route: '/', title: noop('Homepage')],
[route: '/about', title: noop('About')],
] |
Create a new issue for this feature: #60 |
Following https://lingui.gitbooks.io/js/tutorials/react.html got me to:
And then it shows nicely formatted language file:
However mine looks very different, containing origin values (it does compile though):
What am I doing wrong? I was just following the tutorial.
The text was updated successfully, but these errors were encountered: