mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 07:09:23 +02:00
* detect language under windows, patch by Ales Katona
git-svn-id: trunk@289 -
This commit is contained in:
parent
bffd9f2cc7
commit
698e88ac72
@ -76,7 +76,7 @@ type
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses dos;
|
uses {$ifdef win32} windows, {$endif}dos;
|
||||||
|
|
||||||
var
|
var
|
||||||
GettextUsed: Boolean;
|
GettextUsed: Boolean;
|
||||||
@ -260,10 +260,39 @@ end;
|
|||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
procedure TranslateResourceStrings(const AFilename: String);
|
procedure TranslateResourceStrings(const AFilename: String);
|
||||||
|
|
||||||
|
{$ifdef win32}
|
||||||
|
procedure GetLanguageIDs(var Lang, FallbackLang: string);
|
||||||
|
var
|
||||||
|
Buffer: array[1..4] of char;
|
||||||
|
Country: string;
|
||||||
|
UserLCID: LCID;
|
||||||
|
begin
|
||||||
|
//defaults
|
||||||
|
Lang := '';
|
||||||
|
FallbackLang:='';
|
||||||
|
UserLCID := GetUserDefaultLCID;
|
||||||
|
if GetLocaleInfo(UserLCID, LOCALE_SABBREVLANGNAME, @Buffer, 4)<>0 then
|
||||||
|
FallbackLang := lowercase(copy(Buffer,1,2));
|
||||||
|
if GetLocaleInfo(UserLCID, LOCALE_SABBREVCTRYNAME, @Buffer, 4)<>0 then begin
|
||||||
|
Country := copy(Buffer,1,2);
|
||||||
|
|
||||||
|
// some 2 letter codes are not the first two letters of the 3 letter code
|
||||||
|
// there are probably more, but first let us see if there are translations
|
||||||
|
if (Buffer='PRT') then Country:='PT';
|
||||||
|
|
||||||
|
Lang := FallbackLang+'_'+Country;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
var
|
var
|
||||||
mo: TMOFile;
|
mo: TMOFile;
|
||||||
lang, FallbackLanguage: String;
|
lang, FallbackLanguage: String;
|
||||||
begin
|
begin
|
||||||
|
{$ifdef win32}
|
||||||
|
GetLanguageIDs(Lang, FallbackLanguage);
|
||||||
|
{$else}
|
||||||
lang := GetEnv('LC_ALL');
|
lang := GetEnv('LC_ALL');
|
||||||
if Length(lang) = 0 then
|
if Length(lang) = 0 then
|
||||||
begin
|
begin
|
||||||
@ -275,8 +304,8 @@ begin
|
|||||||
exit; // no language defined via environment variables
|
exit; // no language defined via environment variables
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FallbackLanguage := Copy(lang, 1, 2);
|
FallbackLanguage := Copy(lang, 1, 2);
|
||||||
|
{$endif}
|
||||||
try
|
try
|
||||||
mo := TMOFile.Create(Format(AFilename, [FallbackLanguage]));
|
mo := TMOFile.Create(Format(AFilename, [FallbackLanguage]));
|
||||||
try
|
try
|
||||||
|
Loading…
Reference in New Issue
Block a user