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

Refactor i18n implementation #213

Merged
merged 2 commits into from
Jan 15, 2025
Merged

Refactor i18n implementation #213

merged 2 commits into from
Jan 15, 2025

Conversation

lkeegan
Copy link
Member

@lkeegan lkeegan commented Dec 17, 2024

  • main improvements
    • all language texts can now be edited from the admin interface
    • in frontend code we now have autocomplete for translation ids
  • change in use
    • i18n-svelte -> lib/i18n.svelte
    • $locale -> i18n.locale
    • $locales -> i18n.locales
    • $_('a.b') -> i18n.tr.a.b
    • to add a text, add the id to lib/translations.ts
  • code changes
    • remove i18n-svelte library
    • remove locales/de.json: this is now included in the static folder of the deployed website, not part of the frontend source code anymore
    • use camel case for all translation ids for consistency and to allow use without quotes
    • de is now also editable in admin interface
  • resolves Allow admins to edit the german translations #211

@codecov-commenter
Copy link

codecov-commenter commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 0.14245% with 701 lines in your changes missing coverage. Please review.

Project coverage is 30.30%. Comparing base (8acd15e) to head (7ea1a85).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
frontend/src/lib/translations.ts 0.33% 297 Missing ⚠️
...end/src/lib/components/ChildrenRegistration.svelte 0.00% 40 Missing ⚠️
...rontend/src/lib/components/ChildrenFeedback.svelte 0.00% 35 Missing ⚠️
frontend/src/lib/i18n.svelte.ts 0.00% 28 Missing and 1 partial ⚠️
...ntend/src/lib/components/Admin/Translations.svelte 0.00% 22 Missing ⚠️
...ontend/src/lib/components/MilestoneOverview.svelte 0.00% 21 Missing ⚠️
frontend/src/lib/components/Milestone.svelte 0.00% 20 Missing ⚠️
frontend/src/lib/components/MilestoneGroup.svelte 0.00% 18 Missing ⚠️
...b/components/Admin/SubmittedMilestoneImages.svelte 0.00% 16 Missing ⚠️
frontend/src/lib/components/Frontpage.svelte 0.00% 15 Missing ⚠️
... and 40 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #213      +/-   ##
==========================================
- Coverage   32.04%   30.30%   -1.74%     
==========================================
  Files         114      115       +1     
  Lines        4179     4421     +242     
  Branches       99      100       +1     
==========================================
+ Hits         1339     1340       +1     
- Misses       2756     2997     +241     
  Partials       84       84              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lkeegan lkeegan force-pushed the fix_211_i18n_de_editable branch from 03dfb76 to fe4d038 Compare January 13, 2025 15:59
- main improvements
  - all language texts can now be edited from the admin interface
  - in frontend code we now have autocomplete for translation ids
- change in use
  - i18n-svelte -> lib/i18n.svelte
  - `$locale` -> `i18n.locale`
  - `$locales` -> `i18n.locales`
  - `$_('a.b')` -> `i18n.tr.a.b`
  - to add a text, add the id to lib/translations.ts
- code changes
  - remove i18n-svelte library
  - remove locales/de.json: this is now included in the static folder of the deployed website, not part of the frontend source code anymore
  - use camel case for all translation ids for consistency and to allow use without quotes
  - de is now also editable in admin interface
- resolves #211
@lkeegan lkeegan force-pushed the fix_211_i18n_de_editable branch from 3c70332 to fd1c13a Compare January 13, 2025 19:28
@lkeegan lkeegan requested a review from MaHaWo January 14, 2025 07:45
Copy link
Collaborator

@MaHaWo MaHaWo left a comment

Choose a reason for hiding this comment

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

nice addition, looks good. The only question I have is if there would be a way to have defaults for, e.g., the names of the buttons in the profile popover or similar functional elements. Someone who is not familiar with the code might be a little confused by the amount of names and labels and doesn´t know what to provide there upon initial deployment.

@lkeegan
Copy link
Member Author

lkeegan commented Jan 15, 2025

nice addition, looks good. The only question I have is if there would be a way to have defaults for, e.g., the names of the buttons in the profile popover or similar functional elements. Someone who is not familiar with the code might be a little confused by the amount of names and labels and doesn´t know what to provide there upon initial deployment.

Yes I was also thinking about that and I agree - I guess the most developer-friendly option would be to put the actual german text in https://github.com/ssciwr/mondey/pull/213/files#diff-63f05097c4a548b2bc2106f45ca89b7986d834aaddc361c23ea8b1850c2e59b6 instead of empty strings, even if this wastes some bandwidth.

The alternative would be to ship a de.json as part of the source code but not part of the website, and modify the local docker / testing setup to serve that at runtime, but don't think it's worth the extra complications just to avoid downloading some redundant data, at least for now.

Copy link

sonarqubecloud bot commented Jan 15, 2025

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@lkeegan lkeegan merged commit 08777e5 into main Jan 15, 2025
8 checks passed
@lkeegan lkeegan deleted the fix_211_i18n_de_editable branch January 15, 2025 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow admins to edit the german translations
3 participants