Changeset 75 for trunk/Directories.pas
- Timestamp:
- Jan 15, 2017, 5:20:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Directories.pas
r64 r75 6 6 var 7 7 HomeDir, DataDir: string; 8 LocaleCode: string; 8 LocaleCode: string = ''; 9 LocaleCodeAuto: string = ''; 9 10 10 11 function LocalizedFilePath(const Path: string): string; … … 14 15 15 16 uses 16 LCLIntf, LCLType, SysUtils, FileUtil;17 FileUtil, LCLIntf, LCLType, LCLProc, LazUTF8, SysUtils; 17 18 18 19 var 19 20 AppDataDir: string; 20 21 src, dst: TSearchRec; 22 21 23 22 24 function DirectoryExists(path: string): boolean; … … 27 29 end; 28 30 31 function GetLocale: string; 32 var 33 Lang: string; 34 I: Integer; 35 T: string; 36 begin 37 // Win32 user may decide to override locale with LANG variable. 38 Lang := GetEnvironmentVariableUTF8('LANG'); 39 40 if Lang = '' then begin 41 for i := 1 to Paramcount - 1 do 42 if (ParamStrUTF8(i) = '--LANG') or (ParamStrUTF8(i) = '-l') or 43 (ParamStrUTF8(i) = '--lang') then 44 Lang := ParamStrUTF8(i + 1); 45 end; 46 if Lang = '' then begin 47 LazGetLanguageIDs(Lang, T); 48 Lang := Copy(Lang, 1, 2); 49 end; 50 51 Result := Lang; 52 end; 53 29 54 function LocalizedFilePath(const Path: string): string; 55 var 56 LocaleCodeDir: string; 30 57 begin 31 if LocaleCode <> '' then begin 32 Result := HomeDir + 'Localization' + DirectorySeparator + LocaleCode + DirectorySeparator + Path; 58 if LocaleCode = '' then begin 59 if LocaleCodeAuto = '' then LocaleCodeAuto := GetLocale; 60 LocaleCodeDir := LocaleCodeAuto; 61 end else LocaleCodeDir := LocaleCode; 62 63 if LocaleCode <> 'en' then begin 64 Result := HomeDir + 'Localization' + DirectorySeparator + LocaleCodeDir + DirectorySeparator + Path; 33 65 if not FileExists(Result) then 34 66 Result := HomeDir + Path;
Note:
See TracChangeset
for help on using the changeset viewer.