skyjake / lagrange

A Beautiful Gemini Client
https://gmi.skyjake.fi/lagrange/
BSD 2-Clause "Simplified" License
1.21k stars 63 forks source link

User interface localization #192

Closed skyjake closed 3 years ago

skyjake commented 3 years ago

All user-visible strings should be looked up via a translation table so the UI can be localized to different languages.

In practice, wherever there is a user-visible string, it should be replaced with a lookup key. The keys could start with a special symbol, for instance $menu.tab.new. Widgets could then perform the lookup from the translation table and keep a pointer to the user-visible string. When the language is changed at runtime, widgets can then just redo the lookup and everything will instantly update.

Dynamically formatted text is a challenge of its own, but one solution is to translate the format string and use numbered arguments so the order can be changed in the translation (like in Qt).

EDIT: There is now a Weblate server where you can contribute translations: https://weblate.skyjake.fi/projects/lagrange/ui/. Contact me if you want to start translating a new language.

sikmir commented 3 years ago

I would like to help with translating to Russian and Finnish.

skyjake commented 3 years ago

Thanks for the offer! Although I'll probably do Finnish myself, being a native speaker. 🙂 (for dev purposes, too)

sikmir commented 3 years ago

I suggest to use Weblate, it's free for open source projects.

skyjake commented 3 years ago

That's a good idea. I'll look into the supported file formats on Weblate and see what would work best for Lagrange.

laosb commented 3 years ago

Want to see this happening! I would like to help with Chinese translation.

skyjake commented 3 years ago

@sikmir @laosb I've set up a self-hosted Weblate at weblate.skyjake.fi. You're most welcome to create an account and start translating! 🙂

Let me know if you run into any issues with the site. It seems to be working for me at least.

laosb commented 3 years ago

@skyjake Hi I've set up my account, but there's no option for translating to Chinese. Could you add it?

skyjake commented 3 years ago

Which one would you like:

Chinese (Min Nan) (nan) Chinese (Pinyin) (zh_Latn) Chinese (Simplified) (zh_Hans) Chinese (Simplified, Singapore) (zh_Hans_SG) Chinese (Traditional) (zh_Hant) Chinese (Traditional, Hong Kong) (zh_Hant_HK)

laosb commented 3 years ago

I believe Chinese (Pinyin) is not really Chinese, just the pronunciation assisting symbols. I'm native in Simplified Chinese, and can help with Traditional Chinese.

skyjake commented 3 years ago

All right, added!

skyjake commented 3 years ago

@laosb I added you to the Translators group so you should be able to save the translations directly now.

laosb commented 3 years ago

Oh, OK, thank you!

sikmir commented 3 years ago

@skyjake "Save" button is disabled, I can only "Suggest" translation. Is it some restriction?

skyjake commented 3 years ago

@sikmir I've added you to the Translators, too. By default, users can suggest only.

Carmina16 commented 3 years ago

Please add Interlingue (code: ie).

Carmina16 commented 3 years ago

Is it possible to give me ("OIS") the translator rights for Interlingua [ia] and Interlingue [ie]?

skyjake commented 3 years ago

@Carmina16 I've added you as a translator.

laosb commented 3 years ago

Just finished translating to zh-Hans. Will work on translating to zh-Hant later.

Any chance getting some test build to see the real world performance?

laosb commented 3 years ago

Btw, I'm a little concerned about the font used in Lagrange. Currently it renders Chinese badly with characters changing sizes along the line. I would suggest use system font or Noto Sans CJK if possible.

skyjake commented 3 years ago

Nice! I was just testing this a moment ago.

I'll see about doing a test build. Which operating system do you use?

Currently it renders Chinese badly with characters changing sizes along the line.

Yes that is a problem at the moment, and it's also missing a few glyphs. I will update the UI font.

Screen Shot 2021-03-25 at 9 20 26
laosb commented 3 years ago

I'm using macOS on Apple Silicon. Also on iOS.

skyjake commented 3 years ago

OK, I'll do the font update and make a test build for macOS.

skyjake commented 3 years ago

@Carmina16

Interlingua [ia] and Interlingue [ie]?

Ah, earlier I missed ie in Weblate because it's called "Occidental (ie)" and not Interlingue there. (Perhaps to avoid confusing it with Interlingua.) It's now added to the project, so please go ahead. 🙂

sikmir commented 3 years ago

Status:

Translation status

skyjake commented 3 years ago

Nice, although I just noticed there are 6 untranslated strings in the quick lookup results popup... I'll commit those shortly.

skyjake commented 3 years ago

@laosb Test build for you: https://media.skyjake.fi/lagrange_v1.3.0_macos11.0-arm64.tbz

This build adds Noto Sans CJK (SC) weighing in as an additional 10 MB. Previously, glyphs have been picked from different fonts where available, so that's one possible reason for inconsistent appearance. Now they should all be coming from Noto Sans. Let me know if you spot errors in text rendering.

Some known issues:

sikmir commented 3 years ago

@skyjake It looks like plural forms are not properly extracted for Russian: https://github.com/skyjake/lagrange/blob/94f45c0fe81f7f18d65a3d701da1c8448027d8b7/po/ru.po#L532-L536 Compare: https://github.com/skyjake/lagrange/blob/94f45c0fe81f7f18d65a3d701da1c8448027d8b7/po/fi.po#L535-L538

skyjake commented 3 years ago

@sikmir This seems to be a Weblate issue. The strings originally didn't have plurals, and the export is somehow stuck on the original non-plural strings. I had to manually edit the fi.po and re-upload it to Weblate to fix this... Would you like me to do the same for ru.po?

sikmir commented 3 years ago

Would you like me to do the same for ru.po?

Yes, please.

skyjake commented 3 years ago

Done. Hopefully they are now correctly exported.

I should check German as well, I'm pretty sure it has the same problem.

EDIT: Nope, they aren't translated yet in German.

skyjake commented 3 years ago

Auto-refresh intervals didn't have strings yet, so those were added (fa746aa0766b957acbb36800d4a410c768392d4a).

laosb commented 3 years ago
image

The test build works mostly fine. Noticed two problems:

skyjake commented 3 years ago

Yeah, those problems are occurring for me too. I'll need to debug the Preferences layout a bit. There should be no need to alter the translations.

The macOS menus not retranslating on the fly is a known issue.

laosb commented 3 years ago

Fixed some date translation in Chinese (S). Also roughly finished Chinese (T), with machine translation from S to T and manual inspection. Hope native Chinese (T) speaker from Taiwan can help correct my mistakes.

skyjake commented 3 years ago

@laosb I think the exported .po file has a couple of problems with the plurals, like I had with Finnish and @sikmir had with Russian. I'll apply a fix...

skyjake commented 3 years ago

We've reached string freeze for v1.3. You still have a couple of days to finalize the translations for v1.3.0.

laosb commented 3 years ago

Received the notice. Just updated both Chinese (S) and (T) to keep it at 100%!

skyjake commented 3 years ago

Aha, of course there's still one more string missing, the menu item for Chinese (T). I'll still add that...

sikmir commented 3 years ago

Russian is 100% ready and looks good for me, looking forward 1.3.0 release.

sikmir commented 3 years ago

One note, as far as this issue will be closed on 1.3.0 release, it makes sense to enable "Start new translation" button on Weblate for registered users (it can be configured to require approval) to make it easy to request new language.

skyjake commented 3 years ago

I think I'll leave this issue open for now, but I will look into the access rights for the translation button.

sikmir commented 3 years ago

@skyjake "Translate" button is out of frame: scr1

sikmir commented 3 years ago

@skyjake Another untranslated strings:

skyjake commented 3 years ago

@sikmir Fixed the dialog layouts being sometimes too narrow.

I suppose the remaining strings can wait for a patch. Maybe the keyboard key names should also be translated?https://github.com/skyjake/lagrange/blob/dev/src/ui/util.c#L104

There's a set of about: pages that could also be translated:

sikmir commented 3 years ago

Maybe the keyboard key names should also be translated?

I think it's better to leave it as-is, translating "Ctrl/Alt/Shift/Meta/Caps/Space/Esc" seems weird.

Carmina16 commented 3 years ago

Yes, keyboard keys should be translatable.

Also, it possible to embed English strings for missing entries in translation files instead of the identifiers?

skyjake commented 3 years ago

embed English strings for missing entries in translation files instead of the identifiers?

That is not possible at the moment. I could enable this for selected things like the keyboard key names, which mostly come from SDL.

laosb commented 3 years ago

I'm not sure about how to do that, but to ensure quality, it's better to include both TC and SC variants of Noto Sans CJK, and switch to the corresponding one accordingly.

Also it might be a good idea to switch for content according to the Gemini header lang={}.

MCMic commented 3 years ago

@skyjake Hello, can I be added to translators for French? (MCMic account on the weblate)

Also I’d love to see an esperanto translation, but I’m not good enough to do it.

skyjake commented 3 years ago

@MCMic You should now have translator rights, please go ahead.

I’ve added Esperanto, too. Let’s see if someone volunteers to do it...