Changeset 75 for trunk


Ignore:
Timestamp:
Jan 15, 2017, 5:20:33 PM (8 years ago)
Author:
chronos
Message:
  • Added: By default interface language should be selected according system language.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Directories.pas

    r64 r75  
    66var
    77  HomeDir, DataDir: string;
    8   LocaleCode: string;
     8  LocaleCode: string = '';
     9  LocaleCodeAuto: string = '';
    910
    1011function LocalizedFilePath(const Path: string): string;
     
    1415
    1516uses
    16   LCLIntf, LCLType, SysUtils, FileUtil;
     17  FileUtil, LCLIntf, LCLType, LCLProc, LazUTF8, SysUtils;
    1718
    1819var
    1920  AppDataDir: string;
    2021  src, dst: TSearchRec;
     22
    2123
    2224function DirectoryExists(path: string): boolean;
     
    2729end;
    2830
     31function GetLocale: string;
     32var
     33  Lang: string;
     34  I: Integer;
     35  T: string;
     36begin
     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;
     52end;
     53
    2954function LocalizedFilePath(const Path: string): string;
     55var
     56  LocaleCodeDir: string;
    3057begin
    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;
    3365    if not FileExists(Result) then
    3466      Result := HomeDir + Path;
  • trunk/Locale.pas

    r65 r75  
    8888
    8989  Languages := TLanguages.Create;
    90   Languages.AddItem('', 'English');
     90  Languages.AddItem('', 'System');
    9191  Languages.AddItem('cs', 'Czech');
    9292  Languages.AddItem('de', 'Deutch');
     93  Languages.AddItem('en', 'English');
    9394
    9495  OKBtn.Caption := Phrases.Lookup('BTN_OK');
Note: See TracChangeset for help on using the changeset viewer.