diff --git a/ide/include/unix/lazbaseconf.inc b/ide/include/unix/lazbaseconf.inc index cf3c569280..7324758196 100644 --- a/ide/include/unix/lazbaseconf.inc +++ b/ide/include/unix/lazbaseconf.inc @@ -194,6 +194,26 @@ begin Result:='gtk'; end; +procedure GetLanguageIDs(var Lang, FallbackLang: string); +begin + Lang := GetEnv('LC_ALL'); + FallbackLang:=''; + + if Length(Lang) = 0 then + begin + Lang := GetEnv('LC_MESSAGES'); + if Length(Lang) = 0 then + begin + Lang := GetEnv('LANG'); + if Length(Lang) = 0 then + exit; // no language defined via environment variables + end; + end; + + FallbackLang := Copy(Lang, 1, 2); + Lang := Copy(Lang, 1, 5); +end; + {--------------------------------------------------------------------------- procedure InternalInit; ---------------------------------------------------------------------------} diff --git a/ide/include/win32/lazconf.inc b/ide/include/win32/lazconf.inc index 8c4d6494b2..b859097cb7 100644 --- a/ide/include/win32/lazconf.inc +++ b/ide/include/win32/lazconf.inc @@ -21,6 +21,9 @@ * * *************************************************************************** } +uses + windows; + const DefaultFPCSrcDirs: array[1..1] of string = ( 'C:\pp' @@ -111,7 +114,7 @@ end; function FindDefaultCompilerPath: string; begin Result:=SearchFileInPath(GetDefaultCompilerFilename,'', - GetEnvironmentVariable('PATH'),';', + SysUtils.GetEnvironmentVariable('PATH'),';', [sffDontSearchInBasePath]); if Result<>'' then exit; Result:='c:\pp\bin\win32\ppc386.exe'; @@ -121,7 +124,7 @@ end; function FindDefaultMakePath: string; begin Result:=SearchFileInPath('make.exe','', - GetEnvironmentVariable('PATH'),';', + SysUtils.GetEnvironmentVariable('PATH'),';', [sffDontSearchInBasePath]); end; @@ -159,7 +162,7 @@ end; function GetDefaultTestBuildDirectory: string; begin - Result:=GetEnvironmentVariable('TEMP'); + Result:=SysUtils.GetEnvironmentVariable('TEMP'); if Result<>'' then exit; Result:='c:\temp\'; if DirPathExists(Result) then exit; @@ -187,19 +190,45 @@ begin Result:='win32'; end; +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; + {--------------------------------------------------------------------------- procedure InternalInit; ---------------------------------------------------------------------------} procedure InternalInit; begin PrimaryConfigPath:=ChompPathDelim(ExtractFilePath(Paramstr(0))); - SecondaryConfigPath:=GetEnvironmentVariable('WINDIR'); + SecondaryConfigPath:=SysUtils.GetEnvironmentVariable('WINDIR'); If SecondaryConfigPath = '' Then SecondaryConfigPath:='c:\windows'; end; { $Log$ + Revision 1.26 2004/12/09 14:30:12 vincents + moved GetLanguageIDs from Translations to LazConf + Revision 1.25 2004/12/04 01:17:41 mattias implemented Target Directory for IDE diff --git a/ide/lazconf.pp b/ide/lazconf.pp index caabf449d7..1f737d27e9 100644 --- a/ide/lazconf.pp +++ b/ide/lazconf.pp @@ -112,6 +112,9 @@ const function GetDefaultLCLWidgetType: string; procedure GetDefaultLCLLibPaths(List: TStrings); function GetDefaultLCLLibPaths(const Prefix, Postfix, Separator: string): string; + + // returns the user language ID from the OS + procedure GetLanguageIDs(var Lang, FallbackLang: string); const EmptyLine = LineEnding + LineEnding; @@ -130,7 +133,7 @@ begin Result:=Executable else Result:=SearchFileInPath(Executable,'', - GetEnvironmentVariable('PATH'),':', + SysUtils.GetEnvironmentVariable('PATH'),':', [sffDontSearchInBasePath]); end; @@ -222,6 +225,9 @@ end. { $Log$ + Revision 1.35 2004/12/09 14:30:12 vincents + moved GetLanguageIDs from Translations to LazConf + Revision 1.34 2004/12/04 01:17:41 mattias implemented Target Directory for IDE diff --git a/ide/translations.pas b/ide/translations.pas index 3f54ec63e9..428db96a8e 100644 --- a/ide/translations.pas +++ b/ide/translations.pas @@ -79,7 +79,7 @@ var implementation uses - Dos; + Dos, LazConf; function GetLazarusLanguageLocalizedName(const ID: string): String; begin @@ -201,26 +201,6 @@ begin TranslateUnitResourceStrings(ResUnitName,Format(BaseFilename,[Lang])); end; -procedure GetLanguageIDs(var Lang, FallbackLang: string); -begin - Lang := GetEnv('LC_ALL'); - FallbackLang:=''; - - if Length(Lang) = 0 then - begin - Lang := GetEnv('LC_MESSAGES'); - if Length(Lang) = 0 then - begin - Lang := GetEnv('LANG'); - if Length(Lang) = 0 then - exit; // no language defined via environment variables - end; - end; - - FallbackLang := Copy(Lang, 1, 2); - Lang := Copy(Lang, 1, 5); -end; - {------------------------------------------------------------------------------- TranslateResourceStrings diff --git a/ideintf/componenteditors.pas b/ideintf/componenteditors.pas index fa6d44418d..c61e1ddd40 100644 --- a/ideintf/componenteditors.pas +++ b/ideintf/componenteditors.pas @@ -624,7 +624,7 @@ begin OldIndex:=Notebook.PageIndex; if (OldIndex>=0) and (OldIndex