-
Notifications
You must be signed in to change notification settings - Fork 273
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
Automatic messages extraction? #64
Comments
This has been discussed before in #7. I am not a fan of having the source code be the source of truth for original translations for a few reasons.
The proper way to do this is to use ids in your source code and then create store your source translations in the same kind of file that your translations are in. As such, "extraction" doesn't make that much sense since if you are doing translations properly, you will need to modify your translation file anyway for each new string. That said, having a lint tool to to detect missing ids, or unused ids may/could be useful. |
by automatic extraction i mean that in source code you'll have ids, not just strings, like: func (pl *EmailPackageCollection) Description() i18n.Translation {
return i18n.T("pricing.email_packages.description")
} then when you run some script like
it will add to json
and pluralization is totally possible as well, because the call of i18n.T can be parsed smartly |
This is certainly possible to do, but I guess I am not convinced that it is worth the effort since a developer has to go in and write the source translation anyway. Maybe you can explain more why you think this would be helpful? Is it really that hard to manually add an entry to the json file every time you add a new translation? |
The main issue i have is that it's hard to keep translation files in sync with the codebase. |
Since this seems to be a common request, I am open to considering this. I imagine the API would look something like this:
The first parameter is the id for the translation and the second parameter is the default source translation. A more complicated example:
|
Why the default translation be needed if we will have the check for an untranslated strings as a console script |
Also the question to the followers: is anybody working on this ATM? If not, I'd like to work on PR |
v2 contains a proposal to fix this. See #92. |
@nicksnyder you're the man, thanks a lot! |
I just tagged 2.0.0.beta.1. Please start using it and report any issues that you have. |
@nicksnyder thanks! |
Thank you for the great project!
One thing really missing is message extraction utility.
Any plans for implementing that?
Thanks again!
The text was updated successfully, but these errors were encountered: