-
Notifications
You must be signed in to change notification settings - Fork 399
docs: Document gettext incompatibility #1941
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
base: main
Are you sure you want to change the base?
Conversation
|
This should be added to the php documentation as well. And maybe php should even fail to compile |
|
After further research, it seems this isn't strictly gettext specific but in fact related to setlocale having a process-wide effect on Linux. This probably also affects libintl in general whenever changes to the locale occur but I'm not 100% sure either. How should we go about documenting it ? |
|
I wonder if this couldn't be changed in php-src. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placeholder so we don't accidentally merge. Asking php maintainers first.
|
I will create a php RFC to rework |
|
I have a POC working, but it's more complicated than I'd hoped, because uselocale doesn't support setting individual locales. I need to createlocale with the intended masks and free old locales, if no longer required. To convert them to locale strings individually, we need to track one per available LC_ constant,, which is 5 in general and then another 5 gnu extensions. Tl;dr: working, but messy. |
|
Given the following PHP code to simulate different FrankenPHP requests: <?php
use parallel\Runtime;
setlocale(LC_ALL,'C');
echo "main@start : ".setlocale(LC_ALL,0)." | dp=".localeconv()['decimal_point']."\n";
$f = (new Runtime())->run(function () {
setlocale(LC_ALL,'de_DE.UTF-8');
echo "worker@set : ".setlocale(LC_ALL,0)." | dp=".localeconv()['decimal_point']."\n";
});
echo "main@after : ".setlocale(LC_ALL,0)." | dp=".localeconv()['decimal_point']."\n";
$f->value();Currently: Expected, after proposed implementation: |
gettext is not thread safe and can only load a single locale per process, this causes a mix and match of languages to be returned from translations.
https://stackoverflow.com/a/1646343