Localization improvements and fixes #956

Merged
Fs00 merged 15 commits from i18n-fixes into main 2023-09-07 21:09:03 -03:00
Fs00 commented 2023-09-02 07:13:24 -04:00 (Migrated from github.com)

This PR aims to fix several issues in UI localization that I've found while working to update the Italian translation to the latest version.
The issues I've fixed can be roughly divided in the following categories:

  • the UI displayed some strings that couldn't be translated
  • the UI displayed some strings in their untranslated form even if the translation was actually present, due to missing/wrong gettext lookups (eaf29a1, 63daf47, 63ca572, 2399808)
  • the source code included some strings that could have been translated, but those strings belonged to unused functions or were never displayed to the user (fe1297f, af1881f)

Overall, there is a fair amount of different changes in this PR, but they should be fairly quick and easy to review commit by commit.

This PR aims to fix several issues in UI localization that I've found while working to update the Italian translation to the latest version. The issues I've fixed can be roughly divided in the following categories: - the UI displayed some strings that couldn't be translated - the UI displayed some strings in their untranslated form even if the translation was actually present, due to missing/wrong gettext lookups (eaf29a1, 63daf47, 63ca572, 2399808) - the source code included some strings that could have been translated, but those strings belonged to unused functions or were never displayed to the user (fe1297f, af1881f) Overall, there is a fair amount of different changes in this PR, but they should be fairly quick and easy to review commit by commit.
Exzap commented 2023-09-06 00:20:38 -03:00 (Migrated from github.com)

Looks good!

Just one nitpick:
We have specific wrappers for string conversation to guaranteed that all std::string are utf8. For wxString <-> std::string there is to_wxstring/from_wxstring. Always use this over e.g. .ToStdString()

Looks good! Just one nitpick: We have specific wrappers for string conversation to guaranteed that all `std::string` are utf8. For wxString <-> std::string there is [to_wxstring/from_wxstring](https://github.com/cemu-project/Cemu/blob/d7f0d679047e9fe87de6b36cdd7f2be8b9800477/src/gui/helpers/wxHelpers.h#L90). Always use this over e.g. `.ToStdString()`
Fs00 commented 2023-09-06 14:40:21 -03:00 (Migrated from github.com)

Thanks for letting me know!
I noticed that wxWidgets actually has a .utf8_string() method that does the same thing, so I used that instead.
At that point I admit I got a bit sidetracked and took the opportunity to use .utf8_string() everywhere in place of ToStdString and from_wxstring.
But not only that: when I saw the helper wxStringFormat2 I thought "why not use it instead of repeating fmt::format(fmt:::runtime([].utf8_string()) all the time?", and that's what I did. I also renamed it into formatWxString because the wx prefix initially misled me into thinking that it was a method coming from wxWidgets.

And that's how this PR became way bigger than I anticipated 😅
Hope it won't be much of a hassle reviewing the 3 commits I added following your comment.

Thanks for letting me know! I noticed that wxWidgets actually has a `.utf8_string()` method that does the same thing, so I used that instead. At that point I admit I got a bit sidetracked and took the opportunity to use `.utf8_string()` everywhere in place of `ToStdString` and `from_wxstring`. But not only that: when I saw the helper `wxStringFormat2` I thought _"why not use it instead of repeating `fmt::format(fmt:::runtime([].utf8_string())` all the time?"_, and that's what I did. I also renamed it into `formatWxString` because the `wx` prefix initially misled me into thinking that it was a method coming from wxWidgets. And that's how this PR became way bigger than I anticipated :sweat_smile: Hope it won't be much of a hassle reviewing the 3 commits I added following your comment.
Exzap commented 2023-09-07 21:08:57 -03:00 (Migrated from github.com)

FYI Using wxWidgets functions in the emulation core (or really anything outside of src/gui subdirectory) is something we ideally want to avoid. The goal is to fully decouple UI code from the core eventually to make it possible to introduce other UI libraries. Hence it is preferable to use std::format over formatWxString in the core. Of course there are other existing issues too like direct calls to wxMessageBox and various wx dialogs but let that be a problem for another day.

At any rate this PR looks good as-is. Thanks!

FYI Using wxWidgets functions in the emulation core (or really anything outside of `src/gui` subdirectory) is something we ideally want to avoid. The goal is to fully decouple UI code from the core eventually to make it possible to introduce other UI libraries. Hence it is preferable to use `std::format` over `formatWxString` in the core. Of course there are other existing issues too like direct calls to `wxMessageBox` and various wx dialogs but let that be a problem for another day. At any rate this PR looks good as-is. Thanks!
Fs00 commented 2023-09-08 04:45:46 -03:00 (Migrated from github.com)

Hence it is preferable to use std::format over formatWxString in the core

Yeah makes a lot of sense. But as you've already pointed out, the real problem here is calling wxMessageBox outside the GUI code... unless we move those calls outside the core, we have no choice but to deal with wxStrings in one way or another 🤷‍♂️

> Hence it is preferable to use std::format over formatWxString in the core Yeah makes a lot of sense. But as you've already pointed out, the real problem here is calling `wxMessageBox` outside the GUI code... unless we move those calls outside the core, we have no choice but to deal with `wxString`s in one way or another :man_shrugging:
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: cemu-project_Mirror/Cemu-2024-03-05#956
No description provided.