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

Updating comment/note in source template file does not correctly update comment/note in translations #11133

Open
2 tasks done
henry-torproject opened this issue Mar 4, 2024 · 4 comments
Labels
enhancement Adding or requesting a new feature. undecided These features might not be implemented. Can be prioritized by sponsorship.

Comments

@henry-torproject
Copy link
Contributor

Describe the issue

Seen when using Fluent, but I imagine it would effect other formats that use a template.

Whenever the source file changes the comment/note on one of its strings, the translation files do not pick up on this change, and Weblate shows the "string description" as a concatenation of the old and new strings.

I already tried

  • I've read and searched the documentation.
  • I've searched for similar filed issues in this repository.

Steps to reproduce the behavior

Tested with my local weblate instance, but I've seen this for the Tor Project before:

  1. Have a Fluent component with a template file "en.ftl" containing a Fluent string with a comment "Original comment.", and translate it to "de.ftl".
  2. Change the comment in the locally stored file "en.ftl" to be "New comment.".
  3. Force weblate to pick up the new changes.

Weblate will show the en string with the string description: "New comment.". But the de string will have the string description: "New comment. Original Comment.". Moreover, the "de.ftl" file will only contain the old comment: "Original Comment.".

NOTE: The concatenation comes from this line:

if self.template is not None:
# Avoid duplication in case template has same notes
template_comment = self.template.getnotes()
if template_comment != comment:
comment = f"{template_comment}\n{comment}"
and seems to be a result of the translated file not picking up on the comment change.

Expected behavior

If the notes on a template unit changes, then all translation units with the same original note should update their note to match the new value. I.e. the new comment should entirely replace the old comment on Weblate, and in the translated files.

Screenshots

No response

Exception traceback

No response

How do you run Weblate?

weblate.org service

Weblate versions

No response

Weblate deploy checks

No response

Additional context

No response

@nijel
Copy link
Member

nijel commented Mar 7, 2024

Are actually comments in the translated file desired? Keeping them in sync is an additional effort which would have to be performed on each template file update.

@henry-torproject
Copy link
Contributor Author

Are actually comments in the translated file desired? Keeping them in sync is an additional effort which would have to be performed on each template file update.

@nijel I think for tor project's use case, no comments in the translated files would function ok, and I'm not sure we ever really read the comments in the translated files anyway.

But I'm not sure for other projects, since as far as I can tell this bug would also effect other template-based formats besides Fluent.

@nijel
Copy link
Member

nijel commented Mar 7, 2024

I'm not 100% sure how all the formats work, but there is definitely no synchronization in place.

From what I know:

  • Some formats discard the comments while adding strings to the translation. This applies to all LISA based formats which store content in XML tree and not in the translate-toolkit Unit (Android, TS2 or XLIFF).
  • There are formats which do not support comments at all (plain JSON) or in translate-toolkit (YAML).
  • Others which store info on the translate-toolkit unit will probably preserve comments (Properties, Fluent, some JSON variants as WebExtension).

Possible solutions:

  • Remove comments completely when adding new strings to translated files. This avoids synchronization issues, but will look weird in some formats (eg. WebExtension JSON).
  • Sync comments while translating. This would help in situations where both source and comment change.
  • Implement add-on to sync comments on template file update. This is a similar approach to https://docs.weblate.org/en/latest/admin/addons.html#update-po-files-to-match-pot-msgmerge.

@nijel nijel added enhancement Adding or requesting a new feature. undecided These features might not be implemented. Can be prioritized by sponsorship. labels Mar 7, 2024
Copy link

github-actions bot commented Mar 7, 2024

This issue has been put aside. It is currently unclear if it will ever be implemented as it seems to cover too narrow of a use case or doesn't seem to fit into Weblate.

Please try to clarify the use case or consider proposing something more generic to make it useful to more users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding or requesting a new feature. undecided These features might not be implemented. Can be prioritized by sponsorship.
Projects
None yet
Development

No branches or pull requests

2 participants