PHP’s intl only accepts locale formats like en_US, de_DE, it doesn’t accept setlocale(LC_ALL, null) as it returns a format like English.United_States. If I want to use default server locale for intl, is it fine to get HTTP_ACCEPT_LANGUAGE and just replace - with _ (HTTP_ACCEPT_LANGUAGE is something like en-US, but intl accepts only en_US)? or is there any better way to get server default locale and convert it into a format that intl recognizes it?
This would be [FPHP]locale.getdefault[/FPHP] which returns the correct string that you’re looking for.
Is there any other way to get it that doesn’t use intl? locale:getDefault as you said relies on intl.
PS. I tested it I got en_US_POSIX that is still invalid for intl. Is there any other way to get default locale that doesn’t rely on intl itself?
But… you want it… for use… in intl…i’m confused.
Actually I want the returned locale in intl but I prefer the way I get server default locale would be independent from intl. Is there any way? I guess the way I said about HTTP_ACCEPT_LANGUAGE is unreliable and this environment has nothing to do with server default locale. so how to get server default locale independently from intl with the format I said?
Btw, even if I want to get default locale with the way you suggested I got something like en_US_POSIX which is still invalid for intl’s meonyFormatter as it accepts only a format like en_US. using split method to cut off _POSIX
will be unreliable, as I don’t know what I get on different servers. what about if I am on windows and there will not be _POSIX
?
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.