Skip to content
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

mark a string for getstrings but don't actually translate #120

Open
MarcVanDaele90 opened this issue Oct 19, 2022 · 8 comments
Open

mark a string for getstrings but don't actually translate #120

MarcVanDaele90 opened this issue Oct 19, 2022 · 8 comments
Labels
third-party feature This feature was contributed by someone else and depends on the contributor to respond/fix

Comments

@MarcVanDaele90
Copy link

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

  • "How many %s do you see"
  • "Pick the first/second/middle/... %s"

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.

@marcglasberg
Copy link
Owner

The getstrings feature was contributed by @bauerj

@marcglasberg marcglasberg added the third-party feature This feature was contributed by someone else and depends on the contributor to respond/fix label Nov 15, 2022
@bauerj
Copy link
Contributor

bauerj commented Nov 21, 2022

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.

@MarcVanDaele90
Copy link
Author

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

@bauerj
Copy link
Contributor

bauerj commented Nov 21, 2022

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?

@MarcVanDaele90
Copy link
Author

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?

@bauerj
Copy link
Contributor

bauerj commented Nov 22, 2022

Yes, the usual process would be:

  1. Fork this repository and clone your fork
  2. Create a branch for your work
  3. Edit what you need
  4. Commit and push
  5. Open a pull request

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.

@MarcVanDaele90
Copy link
Author

@bauerj Change is committed (I think :-) )

@MarcVanDaele90
Copy link
Author

Proposed fix is not sufficient (see comments in #122).
I'll close the issue and

  • will try to get my use case more clear
  • will first locally try what works and what doesn't and create a CR when things are more clear

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
third-party feature This feature was contributed by someone else and depends on the contributor to respond/fix
Projects
None yet
Development

No branches or pull requests

3 participants