-
Notifications
You must be signed in to change notification settings - Fork 775
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
Remove global locale #3611
Comments
The thing is, that we always want to have the C locale for serdes and always want to have the default locale for display.
Regarding the global locale: I don't know if we want to set it to the C locale, since it could affect the locale of gtk. |
Gtk itself sets the c-locale to the system's locale, so we should not override that after e.g. gtk_init. But setting the c++ locale to C/classic is ok. But this should still happen before the init of gtk, since c++ also sets the c locale. |
I'd do it the other way around: leave the default C++ locale to "C", and imbue the display streams with the system locale. As for GTK and the C locale, well since #3551, the C locale is forcefully reset to |
@bhennion : Sounds reasonable. The only thing I'm wondering is if we really need |
The locale of debug output is not relevant. Mostly it is not even shown to the user... But in my opinion, wrong coding should not be hidden. It should crash the app. So crashing is better than a locale shown wrongly (nearly no one complains about wrong locales). |
I could agree on principle, but in practice this leads to us (and others) wasting a lot of time. The case of #3388 is a very good example. IMO, the amount of people who got involved and the time they spent is way to much a cost for sticking to the principle |
I would argue that all debug output should be in C locale. They are meant for us devs and not for some user with a specific locale that prefers whitespace over comma or whatever. |
Let me try to summarize the above points, to make sure I understand it right. We have the following two options: (A) Use "C" locale as C++ default locale and use a custom stream (with imbue) for display relevant stuff (including CLI messages) In both cases it's pretty likely that our future selves or contributors will forget that there exists a custom stream that they should use for the respective use case. Hence we have the following Project Risks: (A) "C" locale as C++ default:
(B) system locale as C++ default:
|
If the above is correct I would prefer (A). |
That sums it up quite nicely. Definitely A for me. I would also restrict translations to the UI and the console interface. Any kind of debug or error message to the console using g_messages should stay in English. Most users can't really decipher what they mean anyway and we can't translate them from an unknown language to English when they open a ticket. That should cut down on the changes significantly as most g_messages would stay the same. |
I'm for (A), and I agree the g_message outputs should stay in english. All in all, it just means that the global locales (both C and C++) would be set to classic |
I have some objections; @bhennion summarized it very well, "leads to us (and others) wasting a lot of time", which basically means, the problem is laziness here. We have the following two options: (A) Use "C" locale as C++ default locale and use a custom stream (with imbue) for display relevant stuff (including CLI messages) In both cases it's pretty likely that our future selves or contributors will forget that there exists a custom stream that they should use for the respective use case. Hence we have the following Project Risks: (A) "C" locale as C++ default:
(B) system locale as C++ default:
(C) Don't rely on global locales, imbue every stream (maybe fallback to (A))
=> High effort Therefore, I propose to use (C) with the fallback behavior (A). The latter can be changed at least for the c++ locale but should not be relevant there. The problem I see with A and B is, that we strongly rely on global static (thread unsafe) state, which can be changed in every linked library. This is extremely dangerous, nearly impossible to find, and also hard to be fixed. For C locales, this is hard to solve, since the locale apis differ between the three great OSes. But for C++ locales, we can easily use imbue for every stream. For C locales, we should use a guard, setting the local thread locale (requires writing OS specific code), and resetting it to the previous after leaving the scope. Some References: => If implemented, we can easily switch to (C(B)) again. |
Is your feature request related to a problem? Please describe.
Setting a global cpp locale caused some problems in the past (see #3606) and required some fixes (see #3610). However, these rather cured the symptom than the cause.
Describe the solution you'd like
A cleaner way would be to remove the global locale, by adapting
xournalpp/src/core/control/XournalMain.cpp
Lines 61 to 89 in f72fe7c
Describe alternatives you've considered
imbue
to a lot of places in the codebase and testing several locales whenever input/output is implementedNote
This change should be followed by extensive testing, as it might have far reaching unintended side effects.
The text was updated successfully, but these errors were encountered: