-
Notifications
You must be signed in to change notification settings - Fork 603
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
Localization fixes follow-up #966
Conversation
We generally want to avoid Line 802 in deadcef
SetDownloadStatusText expects a wxString, but statusText is a std::string and thus an implicit conversion happens (expecting a locale dependent std::string instead of utf-8). This should be changed to titleManager->SetDownloadStatusText(to_wxString(statusText));
To reiterate, the current convention in our codebase is to use utf-8 everywhere and only convert to other (locale dependent) formats when necessary. Since wxWidgets also supports utf-8 it's not really something we have to worry about and utf-8 everywhere works just fine, as long as we avoid implicit conversion. Unrelated to your changes but I also noticed we have lines like this:
This is essentially the same as
It not only differs by OS, but is also controlled by the user's locale and language settings. On Linux you usually get utf-8, but it can be configured to be something else. I wouldn't be able to tell you the behavior on Windows without researching it first, but it certainly isn't utf-8 for std::string, at least when I checked last time. |
Oook, fixed that! Thanks for pointing me to the correct place :) I have also added a commit to disable implicit conversions from
I feel that |
We tried
Anyway, PR looks good now. Thanks! |
It turns out I've been a bit too eager in replacing
.ToStdString()
with.utf8_string()
in #956, as it caused a few strings to be displayed with broken encoding (this was particularly noticeable on Windows when using languages other than English).The problem was due to the fact that the implicit
std::string
->wxString
conversion assumes that thestd::string
contains data in the current locale encoding and not in UTF-8 (btw I have yet to understand what "current locale encoding" means, since I've observed slightly different behavior between Windows and Linux).I've tried to avoid those implicit conversions as much as possible, generally by:
wxString
directly from functions when there's no point in having astd::string
formatWxString
or a simplewxString
append/concatenation in place offmt::format
I have also taken the opportunity to replace the last two usages of the legacy
wxStringFormat
function withformatWxString
, and also made the play time translatable in game list.Regarding this last point, note that I've removed the "X seconds" text because the play time is stored in minutes and therefore it will never be displayed in seconds (it's likely a remnant of an older implementation).