-
Notifications
You must be signed in to change notification settings - Fork 393
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
Feature: lingui extract should collect messages from multiple sources #257
Comments
Hey @HamidAghdaee, Just to clarify: you have N source folders and you would like to extract message to N separate locale folders, right? Something like: {
"localeDirs": {
"./locale/package1": "./src/package1",
"./locale/package2": "./src/package2",
}
} |
@tricoder42 yes. that would solve part of our problem. Our use case is more like what you're trying to solve here: #14 We maintain our code in packages in a mono-repo of npm published packages, manages by yarn workspaces and Lerna. We want each package to maintain their own local locale files. For one of the packages there are enough translations that having more than one locale folder is a necessity. For the others one locale folder is sufficient, but I don't want to install lingui for each package. I want to run Let me know what you think. Thanks. |
Make sense. It should be enough to have That's what I was suggesting with {
"localeDirs": {
"./locale/package1": "./src/package1",
"./locale/package2": "./src/package2",
}
} but we could pick this config from Regarding namespaces: This might be indeed related, but {
"msg.header": "Header from App",
"@CreditCardInput/msg.header": "Header from CreditCardInput",
"@RelativeDateTime/msg.header": "Header from RelativeDateTime",
} |
@tricoder42 with regards to your first point: I just don't to have to add a row for each package to the config you mentioned. I agree with your point about name-spacing. That could be helpful for us. One challenge I see however is:
thanks. |
I understand that. There' one possible workaround which should work out of the box: Add lingui config to each package: {
"lingui": {
"localeDir": "./locale"
}
} The problem is that if you have any additional config in root, it will be overwritten. On the other hand, this should create Namespacing is still in progress and there're many challenges to solve. But yes, if developer doen't provide explicit ID, then the ID is the message itself. Instead of |
I see. You're right about the packages within the monorepo solution you mentioned. I forgot that lerna exec makes the cwd the package in which it's executing. Having multiple src and locale combos in the same config is still useful for us for the case of splitting translations in the same package. With regards to name-spacing: How do you intend to determine what the namespace is to be if not specified in the key by the user? That's what i18next does and I have to say I don't love it. On a related note, it would be nice to be able to do some mapping of keys when the keys are generated messageIds. After all, for the English (in our case our default lanaguage) you end up with this in your en.json file: { It would be nice to make it so that a mapping function can be applied generate keys from the value (or other factors such as file name, etc) to shorten the key string. |
I haven't really thought about all edge cases of namespacing. I'm working on #179, adding support for .po and possibly .xliff files. Also I'm preparing a video tutorial, so there's too many things going on in my head and I need to release 3.0 anyway before namespaces :) If you have any good points or suggestions, feel free to share it in #14, but right now I'll I can give you is my idea of solution, which is far from the final solution :) |
lingui extract
command
Here's a draft of splitting source catalogs. Any comments welcome. |
@tricoder42 I think the draft would address our needs. What do you think the estimate for this being available would be? In the meantime, can you think of any workarounds for this at the moment? My primary need is to have multiple catalogs located in different folders within the same npm package? It seems like at the moment js-lingui only understands one catalog per package. If I put other json files (Even locale/en/messages.json file) anywhere in the repo, it only reads the json file from the locale folder specified in the root jslingui config. Thanks for your help. |
I'm planning to work & release it next weekend. It's been on a paper for too long. At the moment there's no way to have more than one message catalog, unfortunately. |
New catalogs were already merged to |
Thank you so much for this wonderful library.
One issue we're facing at the moment::
Our application is large enough that we want to extract translations from various src folders in our application into different locale folders. Currently there is no way to pass certain config options to
lingui extract
command such assrcPathDirs
and<rootDir>/locale
It would be nice to either be able to pass these in as parameters or to force the command to read these from a custom config file.
Thanks again.
The text was updated successfully, but these errors were encountered: