-
Notifications
You must be signed in to change notification settings - Fork 63
Use jed1x json format to correctly handle pluralization #753
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Good catch 🙂
@@ -405,7 +405,7 @@ | |||
"browse-page": { | |||
"all-no-results": "No results", | |||
"all-result-count": "{localeCount} result|{localeCount} results", | |||
"all-result-count-more": "Over {localeCount} results", | |||
"all-result-count-more": "Over {localeCount} result|Over {localeCount} results", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there's some kind of ESLint rule we could write to emit a warning or something when we find a translation string that should probably have plural variations... like maybe something basic, if the English string ends with s
and also contains a variable interpolation? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an interesting idea, @sarayourfriend !
/** | ||
* Convert a Jed1x-Translate object to a nested JSON object. | ||
* | ||
* Create a nested JSON object, clean up keys from jed1x context with special | ||
* character, remove keys without values, convert values from array to string, | ||
* if strings are for plural forms, join them with the pipe character. | ||
* Go from this: | ||
* { | ||
* "browse-page.load\u0004Load more results": [ | ||
* "Загрузить ещё результаты" | ||
* ], | ||
* "browse-page.all-result-count-more\u0004Over ###localeCount### results": [ | ||
* "Более ###localeCount### результата", | ||
* "Более ###localeCount### результатов", | ||
* "Более ###localeCount### результатов" | ||
* ] | ||
* "browse-page.search-form.button\u0004Search": [], | ||
* } | ||
* To: | ||
* { | ||
* "browse-page: { | ||
* "load": "Загрузить ещё результаты" | ||
* "all-result-count-more": "Более ###localeCount### результата|Более ###localeCount### результатов|Более ###localeCount### результатов", | ||
* } | ||
* | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is excellent documentation, great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation made it very easy to understand the changes here. LGTM!
* main: (73 commits) Make audio/image pages without ids show a 404 (#768) Fix logo button paddings and simplify implementation (#767) Fix global audio rtl close placement (#780) Check for `null` localStorage explicitly (#763) Truncate global audio text to two lines (#773) New image details page (#682) Switch to path-based i18n routing (#701) Enable source maps in production (#755) Remove Jamendo and Wikimedia Commons from audio meta sources (#747) Use jed1x json format to correctly handle pluralization (#753) Fix logo color on error page layout (#752) Add homepage content switcher for mobile screens (#716) Add inline-start border to filters on desktop (#748) Fix header items not fitting in (#718) Expose `close` to popover content via slot props (#736) Truncate row layout audio titles (#735) Stop blocking on analytics requests (#715) Style links globally (#727) Refactor the usage of i18n result count computation (#707) Use `VPopover` for the content report form (#719) ...
Fixes
Fixes #702 by @obulat
Description
This PR uses a more modern JSON format for downloading the translations from
translate.wordpress.org
,jed1x
. This enables pluralization (the NGX format did not have any information about pluralization).Testing Instructions
Run
pnpm run i18n:get-translations
to update the translations for all locales. You should see that the keys that need to be pluralized (eg.waveform.current-time
,browse-page.all-result-count-more
), have several values joined with a pipe if translations for that locale has been done.Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin