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

Retain custom flags during merge #369

Closed
johantell opened this issue Jul 31, 2023 · 3 comments · Fixed by #370
Closed

Retain custom flags during merge #369

johantell opened this issue Jul 31, 2023 · 3 comments · Fixed by #370

Comments

@johantell
Copy link
Contributor

Background:
In our project, we've implemented an auto-translate feature that helps team members translate to languages they don't know (and we'll help adjust them through the review process or send them over to someone who helps us with the translation).

We've set up a mix task that back-fills all empty translations in a specific language with translations from an external language model and adds the auto-translated tag to the message.

We've noticed recently that all those tags get removed when doing a mix gettext.extract --merge, which causes some disruption for us as we use those tags to know which messages we should send to our external human translators for verification.

Problem
From my understanding (by looking through the Merger module), fuzzy is the only flag allowed to be retained over multiple merges (https://github.com/elixir-gettext/gettext/blob/main/lib/gettext/merger.ex#L230-L236), which is why we're experiencing our problem

Suggested solution
I understand that there is most likely a very sound reason to resetting the tags on each extraction so my suggestion is that we make the retained titles configurable through our mix-file:

def project do
  [
    #...
    gettext: [
      retain_flags: ["fuzzy", "auto-translated"]
    ]
    #...
  ]
end

Where we either use ["fuzzy"] as a default or merge the "internal" flags with the configured value


If this suggestion sounds good to you, I'd be happy to implement it and shoot a PR your way :)

@whatyouhide
Copy link
Contributor

@johantell yes, the retain_flags option sounds great. Let's have fuzzy in there by default and keep it in there though, so that you don't have to configure it manually. In that case, we can call the option :custom_flags_to_keep, wdyt?

@johantell
Copy link
Contributor Author

Sure thing, :custom_flags_to_keep sounds good 👍

@whatyouhide
Copy link
Contributor

@johantell awesome. PR is definitely appreciated!! 💟

johantell added a commit to johantell/gettext that referenced this issue Jul 31, 2023
Background:
While merging translations with `mix gettext.merge`
flags get cleared out and replaced with the exception of
`fuzzy`, which is kept.

This change will allow the `custom_flags_to_keep` flag to
add a list of flags to be kept in addition to `fuzzy` which
helps prevent information loss if external tools adds their
own flags to messages.

Fixes elixir-gettext#369
whatyouhide pushed a commit that referenced this issue Jul 31, 2023
Co-authored-by: Andrea Leopardi <an.leopardi@gmail.com>

Closes #369.

While merging translations with "mix gettext.merge",
flags get cleared out and replaced with the exception of
"fuzzy", which is kept.

This change will allow the ":custom_flags_to_keep" option to
add a list of flags to be kept in addition to "fuzzy" which
helps prevent information loss if external tools adds their
own flags to messages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants