Comments (7)
👍 great I will explore putting a PR together for this today and see how much it would take to support ICU plurals in this plugin. If it turns out to be too intensive, I'll turn my attention to #110 and look to implement this as a middleware.
cc @fatmali, @brandones, and @jonathandick - this is an important issue for OpenMRS to easily and correctly support pluralization with Transifex. I'm going to look through it and see what I can do with it, but ultimately it might fall on you to push it forward if I cannot.
from babel-plugin-i18next-extract.
After some searching through the code, I think that the following code is what would be need to be modified:
babel-plugin-i18next-extract/src/keys.ts
Lines 118 to 157 in 81addcf
To generate the correct string, we could either write the code right into this babel plugin, or perhaps use a package such as https://github.com/messageformat/messageformat that already deals with the ICU format.
from babel-plugin-i18next-extract.
Sorry about the misclick 😥.
This issue may be related to #60.
I'd like to have proper support for ICU somehow because it definitely seems to have some traction, yet I know nothing about this format and I have the feeling that plurals aren't the only requirement to have a good-enough support for ICU (and again, I'm quite ignorant on this format so I could be wrong). Would contexts, namespaces and the Babel macro work properly with your suggestion? Or do they already work?
To be honest, I'm not sure I really want to maintain the ICU part myself as I don't want to miss fundamental things that would require breaking changes everytime, and I don't want to handle issues and PRs related to it while having very poor knowledge about it. I'd be much more comfortable should this was possible through some kind of external plug-in that is not maintained by me.
Any thoughts?
from babel-plugin-i18next-extract.
I appreciate your quick response
Would contexts, namespaces and the Babel macro work properly with your suggestion? Or do they already work?
- Contexts: My understanding is that, in ICU format, contexts are represented through the select keyword (also see here). For my purposes with Transifex, the select keyword is not supported. The
plural
keyword is a special case of theselect
keyword, so if we start by supportingplural
then we're most of the way there to supportingcontext
, too. The main difference here is that there's only one translation key for contexts instead of multiple. - Namespaces: I don't believe that ICU really deals with namespaces - my understanding is that ICU format is only talking about the values for the strings, not the keys or namespaces.
- Babel macro: I don't use the babel macro for the Trans component. Based on #60, it sounds like the babel macro isn't really working right anyway with babel-plugin-i18next-extract? The babel macro is something that would be related to extracting the keys and values, not related to exporting them. My suggestion is solely related to exporting, so I don't think it would have any impact on the babel macro.
To be honest, I'm not sure I really want to maintain the ICU part myself as I don't want to miss fundamental things that would require breaking changes everytime, and I don't want to handle issues and PRs related to it while having very poor knowledge about it.
I totally get this. Maintaining ICU stuff would probably be hard.
I'd be much more comfortable should this was possible through some kind of external plug-in that is not maintained by me.
Is there a way to extend/override the extractor and exporter? I see that the published code is all in one file - I can't think of a way to do this. Do you know of a way?
from babel-plugin-i18next-extract.
Thanks for all the insights on how ICU works with i18next. 👍
Is there a way to extend/override the extractor and exporter? I see that the published code is all in one file - I can't think of a way to do this. Do you know of a way?
You're right, it's not possible yet unfortunately. Such interface is quite demanded actually, but I'm not sure I'd get it right first try.
from babel-plugin-i18next-extract.
Such interface is quite demanded actually, but I'm not sure I'd get it right first try.
Hmm well I'm very keen on trying to get ICU support for plurals working with this. I'm open to making a PR to add direct support or discussing the creation of a middleware or extension api for people wanting to create their own babel plugin or modify yours to do so.
How should we proceed?
from babel-plugin-i18next-extract.
I sincerely apologize for the delay @joeldenning . I'm kind of overwhelmed by work and personal things right now, but I should have responded to you earlier 😰 .
My rationale on this is the following:
- If you can make a very simple change (i.e. a few lines) that saves you from a lot of hassle, then do a PR and I'll look into it. Maybe we could decide to let the option undocumented for now (until we have proper support for middlewares) or even expose it with a visible warning in docs stating that the API may change or even be dropped in future versions.
- In the meantime, I have opened a very minimalistic RFC about middlewares (#110) since it popped up way too often in the few issues this project had. Feel free to contribute to it if you have strong opinions on how it should or should not look. Unfortunately, I don't think I'll be able to spend a lot of efforts implementing such API in the next upcoming weeks, but if anybody feels like tackling it I'll definitely review the PR or the draft 😄 .
from babel-plugin-i18next-extract.
Related Issues (20)
- Support i18next JSON v4's format HOT 5
- Translations not extracted when `t` is used as a template tag literal
- when running tests, I get a warning
- Align Trans key extraction with react-i18next for elements with i18nIsDynamicList
- Ability to extract plurals from defaultValues HOT 1
- Using discardOldKeys keeps only strings from last file
- Allow specifying fallback-functions to parse AST-node for extractors
- Allow defining defaults in the "i18next-extract-mark-context-next-line" directive HOT 1
- extraction not working for TransComponent HOT 5
- Feature key prefixes
- excludes doesn't seem to work HOT 1
- One project where "nested
- Race condition in extract HOT 4
- Can't get an Array of strings to translate HOT 1
- Support fallback keys
- Add comment hint to explicitly register translation keys
- Adding count to t options throws error at computeDerivedKeys and causes webpack build to fail HOT 1
- [BUG][0.9.1] Latest Release Packaging is broken? HOT 2
- translation resource files get overwritten HOT 2
- Docs at netlify appears to be down/not running HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babel-plugin-i18next-extract.