Is. #783 - Fix language detection
The `setlocale` call doesn't return a single locale name in glibc when any of the locale category variable has a different value, instead it returns a composite locale name which is a concatenation of the entire list of locale name and its values, causing the language detection fail. This patch attempts to set the language via LC_MESSAGES and LANG environment variables which are commonly used in POSIX-like systems, then fallbacks to `setlocale` as the last resort.
This commit is contained in:
parent
86b52dc108
commit
88b99acdd6
|
@ -36,6 +36,7 @@
|
||||||
#include "attrs.h"
|
#include "attrs.h"
|
||||||
#include "sprtf.h"
|
#include "sprtf.h"
|
||||||
#if SUPPORT_LOCALIZATIONS
|
#if SUPPORT_LOCALIZATIONS
|
||||||
|
# include "stdlib.h"
|
||||||
# include "locale.h"
|
# include "locale.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -118,9 +119,15 @@ TidyDocImpl* tidyDocCreate( TidyAllocator *allocator )
|
||||||
*/
|
*/
|
||||||
#if SUPPORT_LOCALIZATIONS
|
#if SUPPORT_LOCALIZATIONS
|
||||||
if ( TY_(tidyGetLanguageSetByUser)() == no )
|
if ( TY_(tidyGetLanguageSetByUser)() == no )
|
||||||
|
{
|
||||||
|
if( ! TY_(tidySetLanguage)( getenv( "LC_MESSAGES" ) ) )
|
||||||
|
{
|
||||||
|
if( ! TY_(tidySetLanguage)( getenv( "LANG" ) ) )
|
||||||
{
|
{
|
||||||
TY_(tidySetLanguage)( setlocale( LC_ALL, "" ) );
|
TY_(tidySetLanguage)( setlocale( LC_ALL, "" ) );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* By default, wire tidy messages to standard error.
|
/* By default, wire tidy messages to standard error.
|
||||||
|
|
Loading…
Reference in a new issue