Let ordinal translations interpolate the number (#270)#361
Closed
RavinduPabasara wants to merge 1 commit into
Closed
Let ordinal translations interpolate the number (#270)#361RavinduPabasara wants to merge 1 commit into
RavinduPabasara wants to merge 1 commit into
Conversation
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #270
ordinal()builds its result asf"{value}{suffix}", so a translation can only ever supply a trailing suffix. As reported in #270, that makes languages whose ordinals place the number inside the word impossible to translate — e.g. Romanianal 2-lea(m) /a 2-a(f), where the number sits between a prefix and a suffix.Changes proposed in this pull request:
ordinal(), if the (context-aware) translated string contains a%s/%dplaceholder, format the number into it (suffix % value) so the translation controls where the number goes; otherwise keep the existing"<number><suffix>"behaviour.al 2-lea/a 2-a, plus a%dvariant) and the unchanged suffix path.Backward compatibility:
"nd" -> "e","th" -> "º", …) with no placeholder, so they take the unchanged branch and their output is identical. The English default is unaffected (ordinal(2) == "2nd"). Nomsgidchanges, so no existing translation needs re-merging.Verified with a throwaway Romanian locale loaded through the real gettext path (
activate("ro", path=...)):Full local run:
786 passed,ruff/blackclean.