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

chore: prune Weblate translations #13875

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ben-basten
Copy link
Member

@ben-basten ben-basten commented Nov 1, 2024

Description

Cleaning up Weblate keys that are causing Dart errors with the code generation process in the slang Flutter library, which will potentially be used on mobile for translations.

  • continue - a reserved keyword in Dart, renamed to continue_text to prevent Dart errors
  • force_re-scan_library_files - the hyphen causes problems with the code generation
  • note_apply_storage_label_to_previously_uploaded assets - the space causes problems with code generation
  • durations - the object results in additional Dart classes being generated that are not needed and cause Dart inheritance errors, since the object is not present in the en.json

The cleanup needs to be done across all languages, because any translation JSON file that has a malformed key will cause Dart errors.

How Has This Been Tested?

  • Checked that there are no uses of the keys on the web
  • Running immich locally to test that the continue_text key is still working

Cleaning up weblate keys that are causing Dart errors with the slang
library in mobile.

<https://pub.dev/packages/slang>
@ben-basten ben-basten marked this pull request as ready for review November 1, 2024 21:32
@@ -483,7 +483,7 @@
"confirm_password": "تأكيد كلمة المرور",
"contain": "محتواة",
"context": "السياق",
"continue": "متابعة",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a problem? Seems like it should be a bug with the implementation not something we should have to change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The slang tool generates Dart helper classes to provide fully typed translations. It looks like this:

String get continue_text => 'Continue';

If I leave the key as "continue", I get the following error when building or running flutter:

Error (Xcode): lib/i18n/strings_en.g.dart:197:13: Error:
'continue' can't be used as an identifier because it's a
keyword.

The cause is that the generated code contains a getter using a Dart reserved keyword as a name. I'm not sure how the upstream library would fix this? Open to thoughts here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Id assume the upstream library should not generate invalid code. It should either throw an error or use an alternative naming scheme. It's probably worth opening an issue with them about it. I guess it'd be easy enough to change it either way though.

Copy link
Member Author

@ben-basten ben-basten Nov 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reported an issue upstream!

slang-i18n/slang#257

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants