Merge pull request #785 from Lin-Buo-Ren/patch/fix-i18n-locale-detection

Is. #783 PR #785 - Fix language detection
This commit is contained in:
Geoff McLane 2019-01-08 14:41:54 +01:00 committed by GitHub
commit f53ee9db90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,6 +36,7 @@
#include "attrs.h"
#include "sprtf.h"
#if SUPPORT_LOCALIZATIONS
# include "stdlib.h"
# include "locale.h"
#endif
@ -119,7 +120,13 @@ TidyDocImpl* tidyDocCreate( TidyAllocator *allocator )
#if SUPPORT_LOCALIZATIONS
if ( TY_(tidyGetLanguageSetByUser)() == no )
{
TY_(tidySetLanguage)( setlocale( LC_ALL, "") );
if( ! TY_(tidySetLanguage)( getenv( "LC_MESSAGES" ) ) )
{
if( ! TY_(tidySetLanguage)( getenv( "LANG" ) ) )
{
TY_(tidySetLanguage)( setlocale( LC_ALL, "" ) );
}
}
}
#endif