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

[Suggestion]: do not make assumptions about layout of translations #107

Open
1 task done
umlaeute opened this issue May 26, 2024 · 2 comments
Open
1 task done

[Suggestion]: do not make assumptions about layout of translations #107

umlaeute opened this issue May 26, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@umlaeute
Copy link

Suggestion

while translating to german i noticed a couple of issues:

highlighting substrings

highlighting of substrings is achieved by concatenating multiple translations. this assumes that the translations follow the approximately the same syntactical structure as the original code.

e.g. the string

Enter host address as shown below the QR code.

is split into two substrings ("Enter host address as shown" and "below the QR code"), where the 2nd one is highlighted.
my preferred German translation would look like:

Geben Sie die Hostadresse an, wie sie unter dem QR Code angezeigt wird.

however, this is not possible (as the highlighted string must be at the end).

I'm not fully sure what would be the best approach here, but most likely some explicit markup within the translation string.
e.g.

Enter host address as shown \<below the QR code\>.
and
Geben Sie die Hostadresse an, wie sie \<unter dem QR Code\> angezeigt wird.

and then replace the \< and \> markers to highlight-begin resp highlight-end at runtime.

punctuation

right now the final punctuation mark in a translatable is hardcoded and cannot be translated.
e.g. here the displayed string is forced to have a terminal .:

TextSpan(text: '.\n\n${localizations.confirmExport3}.'),

and the translation must take care to not include this dot:

"confirmExport3": "If your export falls into the wrong hands, all your information saved in Passy will be endangered",

i think this is wrong:

  • it makes the translation process slightly awkward, as i constantly have to wonder whether the missing trailing . in the template translation is a typo. and the correct translation does not look like a correct (full) sentence.
  • it does not allow for translated trailing punctuation. (this is not a real problem with my German translation. but there are so many differences in how various languages use punctuation marks, that i wouldn't be surprised if a trailing . would be a problem somewhere.

placeholders

also, some text requires placeholders. e.g.

"currentUsernameIs": "Current username is ",
"@currentUsernameIs": { "description": "This message is followed by a username in the Change username screen" },

where there's an implicit placeholder at the end of the translation string.
or

Passy/lib/l10n/app_en.arb

Lines 196 to 199 in f69bf2b

"noFavorites1": "You may add favorites by pressing the ",
"noFavorites2": " button at the top bar of any entry screen",
"@noFavorites1": { "description": "noFavorites, noFavorites1 and noFavorites2 make up a single message used in the Favorites search screen. noFavorites1 is followed by a star icon." },
"@noFavorites2": { "description": "noFavorites, noFavorites1 and noFavorites2 make up a single message used in the Favorites search screen. noFavorites1 is followed by a star icon." },

i think this should be handled via an explicit placeholder:
e.g.

Current username is %s.

resp.

You may add favorites by pressing the %s button at the top bar of any entry screen.

there are two pros:

  • it allows the dynamic string at an arbitrary place (e.g. displaying the current username in the middle of the string)
  • it requires less explanations in comments about how strings must be interpreted.

Submission checklist

  • I have specified my suggestion in the issue title
@umlaeute umlaeute added the enhancement New feature or request label May 26, 2024
@GleammerRay
Copy link
Collaborator

GleammerRay commented May 26, 2024

Hello @umlaeute !

Thanks for letting me know, I will consider implementing HTML-style string formatting, as well as variable placeholders. (<b> for bold, %x, %y, %z... for placeholders)

Regarding the punctuation marks, this is simply due to my lack of attention. Thanks for finding these, I will take care of them until the next update.

@GleammerRay
Copy link
Collaborator

Hello @umlaeute !

I have implemented text formatting in the exact manner I mentioned in my message above. You may now implement changes to your localization as you desire. Please let me know if I've made any mistakes during re-formatting or if there's any formatting errors that need fixing.

I thank you very much for providing wonderful suggestions and helping out with localization!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants