Open MarcVanDaele90 opened 2 years ago
The getstrings feature was contributed by @bauerj
The markForI18n
still seems a bit like a hack.
Can you elaborate on why the current approach doesn't work for you? I don't really understand why the name can't be translated immediately.
Maybe I'm missing something. What I'm doing right now is something like this
I have some objects in my data layer like
objects = [{"name": "car".markForI18n, "image":"car.png"}, {"name": "apple".markForI18n, "image":"apple.png"}, ...]
In my UI, I use these names in a number of different ways:
"How many %s do you see".i18n.fill([name.plural(100)] //here I want to use the plural
"Pick the first/second/middle/... %s".i18n.fill(name.i18n) //here I want to use the singular
"Jan has 7 %s and John has 1 %s".i18n.fill(name.plural(7), name.plural(1))
How would you suggest to handle this with the current approach?
Note that eg Qt/QML, where I come from and which might introduce some bias, have similar macros (QT_TR_NOOP
Okay, I understand now. Yes, in that case it would make sense to have a no-op like markForI18n
.
The corresponding change to https://github.com/marcglasberg/i18n_extension/blob/master/lib/i18n_getstrings.dart#L18 should be trivial. Can you send in a PR that does just that?
I never contributed to a project so I might need some assistance. Should I first create a branch, make the changes and then create a pull request or should I start with creating a pull request? Or first create a fork?
Yes, the usual process would be:
See e.g. here for a more detailed rundown.
If you don't want to do that yourself, just let me know. It might take a few days until I have time to do it though.
@bauerj Change is committed (I think :-) )
Proposed fix is not sufficient (see comments in https://github.com/marcglasberg/i18n_extension/pull/122). I'll close the issue and
I have a number of <name, image> pairs like "apple", "car", "bike", ... and a corresponding image.
I want to be able to use the 'name' in both
When creating the objects, I would like to mark the name for translation (such that it gets picked up by getstrings) but don't do an actual translation. I would like to defer the actual translation to where I use the 'name', like in
"How many %s do you see".i18n.fill([name.plural(100)]
or something along those lines(note: I assume that plural(100) is valid to use after 'how many' but that's another discussion I guess)
I currently use
"apple".version
since I noticed that getstrings scans for i18n, fill, plural but also for version and .allVersions. But I'm sure I'm abusing getstrings here. So a dedicated markForI18n (next to the existing i18n) would be useful IMO.