GlitterWare / Passy

Offline password manager with cross-platform synchronization
https://glitterware.github.io/Passy/
GNU General Public License v3.0
132 stars 21 forks source link

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

Open umlaeute opened 3 months ago

umlaeute commented 3 months ago

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 .: https://github.com/GlitterWare/Passy/blob/f69bf2bbe7d72830407fde594e3aa84942c77614/lib/screens/export_screen.dart#L47

and the translation must take care to not include this dot: https://github.com/GlitterWare/Passy/blob/f69bf2bbe7d72830407fde594e3aa84942c77614/lib/l10n/app_en.arb#L111

i think this is wrong:

placeholders

also, some text requires placeholders. e.g. https://github.com/GlitterWare/Passy/blob/f69bf2bbe7d72830407fde594e3aa84942c77614/lib/l10n/app_en.arb#L34-L35 where there's an implicit placeholder at the end of the translation string. or https://github.com/GlitterWare/Passy/blob/f69bf2bbe7d72830407fde594e3aa84942c77614/lib/l10n/app_en.arb#L196-L199 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:

Submission checklist

GleammerRay commented 3 months ago

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 commented 3 months ago

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!