Changeset 34 for trunk/Components/CoolTranslator
- Timestamp:
- Nov 25, 2017, 12:27:33 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 3 3 backup 4 4 tunneler.exe 5 tunneler.dbg 6 tunneler.lps 5 7 heaptrclog.trc 6 tunneler.lps 8 Components/Common/Languages/*.mo 9 Components/CoolTranslator/Demo/lib
-
- Property svn:ignore
-
trunk/Components/CoolTranslator/Demo/Languages/TranslatorDemo.cs.po
r30 r34 10 10 "Content-Transfer-Encoding: 8bit\n" 11 11 12 #: TFORM1.FORM1.CAPTION12 #: tform1.form1.caption 13 13 msgctxt "TFORM1.FORM1.CAPTION" 14 14 msgid "Translator Demo" 15 15 msgstr "Ukázka Translatoru" 16 16 17 #: TMAINFORM.BUTTON1.CAPTION17 #: tmainform.button1.caption 18 18 msgid "Show MainForm.Name" 19 19 msgstr "Ukázat MainForm.Name" 20 20 21 #: TMAINFORM.CAPTION21 #: tmainform.caption 22 22 msgctxt "TMAINFORM.CAPTION" 23 23 msgid "Translator Demo" 24 24 msgstr "Ukázka Translatoru" 25 25 26 #: TMAINFORM.LABEL1.CAPTION26 #: tmainform.label1.caption 27 27 msgid "MainForm" 28 28 msgstr "HlavnÃFormuláÅ" 29 29 30 #: TMAINFORM.LABEL2.CAPTION30 #: tmainform.label2.caption 31 31 msgid "Form name as label caption:" 32 32 msgstr "Jméno formuláÅe jako titulek textu:" 33 33 34 #: TMAINFORM.LABEL3.CAPTION34 #: tmainform.label3.caption 35 35 msgid "Language list:" 36 36 msgstr "" 37 37 38 #: TMAINFORM.LABEL4.CAPTION38 #: tmainform.label4.caption 39 39 msgid "Excludes:" 40 40 msgstr "" -
trunk/Components/CoolTranslator/Demo/Languages/TranslatorDemo.de.po
r30 r34 2 2 msgstr "Content-Type: text/plain; charset=UTF-8" 3 3 4 #: TFORM1.FORM1.CAPTION4 #: tform1.form1.caption 5 5 msgctxt "TFORM1.FORM1.CAPTION" 6 6 msgid "Translator Demo" 7 7 msgstr "" 8 8 9 #: TMAINFORM.BUTTON1.CAPTION9 #: tmainform.button1.caption 10 10 msgid "Show MainForm.Name" 11 11 msgstr "" 12 12 13 #: TMAINFORM.CAPTION13 #: tmainform.caption 14 14 msgctxt "TMAINFORM.CAPTION" 15 15 msgid "Translator Demo" 16 16 msgstr "" 17 17 18 #: TMAINFORM.LABEL1.CAPTION18 #: tmainform.label1.caption 19 19 msgid "MainForm" 20 20 msgstr "" 21 21 22 #: TMAINFORM.LABEL2.CAPTION22 #: tmainform.label2.caption 23 23 msgid "Form name as label caption:" 24 24 msgstr "" 25 25 26 #: TMAINFORM.LABEL3.CAPTION26 #: tmainform.label3.caption 27 27 msgid "Language list:" 28 28 msgstr "" 29 29 30 #: TMAINFORM.LABEL4.CAPTION30 #: tmainform.label4.caption 31 31 msgid "Excludes:" 32 32 msgstr "" -
trunk/Components/CoolTranslator/Demo/Languages/TranslatorDemo.po
r30 r34 2 2 msgstr "Content-Type: text/plain; charset=UTF-8" 3 3 4 #: TFORM1.FORM1.CAPTION4 #: tform1.form1.caption 5 5 msgctxt "TFORM1.FORM1.CAPTION" 6 6 msgid "Translator Demo" 7 7 msgstr "" 8 8 9 #: TMAINFORM.BUTTON1.CAPTION9 #: tmainform.button1.caption 10 10 msgid "Show MainForm.Name" 11 11 msgstr "" 12 12 13 #: TMAINFORM.CAPTION13 #: tmainform.caption 14 14 msgctxt "TMAINFORM.CAPTION" 15 15 msgid "Translator Demo" 16 16 msgstr "" 17 17 18 #: TMAINFORM.LABEL1.CAPTION18 #: tmainform.label1.caption 19 19 msgid "MainForm" 20 20 msgstr "" 21 21 22 #: TMAINFORM.LABEL2.CAPTION22 #: tmainform.label2.caption 23 23 msgid "Form name as label caption:" 24 24 msgstr "" 25 25 26 #: TMAINFORM.LABEL3.CAPTION26 #: tmainform.label3.caption 27 27 msgid "Language list:" 28 28 msgstr "" 29 29 30 #: TMAINFORM.LABEL4.CAPTION30 #: tmainform.label4.caption 31 31 msgid "Excludes:" 32 32 msgstr "" -
trunk/Components/CoolTranslator/Demo/TranslatorDemo.lpi
r30 r34 51 51 <IsPartOfProject Value="True"/> 52 52 <ComponentName Value="MainForm"/> 53 <HasResources Value="True"/> 53 54 <ResourceBaseClass Value="Form"/> 54 55 <UnitName Value="UMainForm"/> 56 <IsVisibleTab Value="True"/> 55 57 <EditorIndex Value="0"/> 56 58 <WindowIndex Value="0"/> … … 79 81 <Filename Value="..\UCoolTranslator.pas"/> 80 82 <UnitName Value="UCoolTranslator"/> 81 <IsVisibleTab Value="True"/>82 83 <EditorIndex Value="1"/> 83 84 <WindowIndex Value="0"/> 84 85 <TopLine Value="274"/> 85 <CursorPos X=" 1" Y="286"/>86 <CursorPos X="33" Y="288"/> 86 87 <UsageCount Value="11"/> 87 88 <Loaded Value="True"/> … … 265 266 </ProjectOptions> 266 267 <CompilerOptions> 267 <Version Value="1 0"/>268 <Version Value="11"/> 268 269 <PathDelim Value="\"/> 269 270 <Target> … … 275 276 </SearchPaths> 276 277 <Linking> 277 <Debugging>278 <GenerateDebugInfo Value="True"/>279 <DebugInfoType Value="dsAuto"/>280 </Debugging>281 278 <Options> 282 279 <Win32> … … 305 302 </Exceptions> 306 303 </Debugging> 304 <EditorMacros Count="0"/> 307 305 </CONFIG> -
trunk/Components/CoolTranslator/Demo/UMainForm.lfm
r30 r34 8 8 ClientWidth = 466 9 9 OnCreate = FormCreate 10 LCLVersion = ' 0.9.31'10 LCLVersion = '1.1' 11 11 object ListBox1: TListBox 12 12 Left = 171 … … 29 29 object Label1: TLabel 30 30 Left = 10 31 Height = 1 431 Height = 13 32 32 Top = 24 33 Width = 4 733 Width = 46 34 34 Caption = 'MainForm' 35 35 ParentColor = False … … 37 37 object Label2: TLabel 38 38 Left = 10 39 Height = 1 439 Height = 13 40 40 Top = 6 41 Width = 13 541 Width = 134 42 42 Caption = 'Form name as label caption:' 43 43 ParentColor = False … … 45 45 object Label3: TLabel 46 46 Left = 171 47 Height = 1 447 Height = 13 48 48 Top = 8 49 Width = 6 849 Width = 67 50 50 Caption = 'Language list:' 51 51 ParentColor = False … … 61 61 object Label4: TLabel 62 62 Left = 321 63 Height = 1 463 Height = 13 64 64 Top = 10 65 Width = 4 765 Width = 46 66 66 Caption = 'Excludes:' 67 67 ParentColor = False … … 69 69 object CoolTranslator1: TCoolTranslator 70 70 POFilesFolder = 'Languages' 71 left = 6472 top = 4071 left = 72 72 top = 72 73 73 end 74 74 end -
trunk/Components/CoolTranslator/UCoolTranslator.pas
r30 r34 6 6 7 7 uses 8 Classes, SysUtils, Forms, StdCtrls, ExtCtrls, StrUtils, Controls, Contnrs,8 Classes, SysUtils, Forms, ExtCtrls, Controls, Contnrs, LazFileUtils, LazUTF8, 9 9 Translations, TypInfo, Dialogs, FileUtil, LCLProc, ULanguages, LCLType; 10 10 … … 46 46 procedure TranslateProperty(Component: TPersistent; PropInfo: PPropInfo); 47 47 function IsExcluded(Component: TPersistent; PropertyName: string): Boolean; 48 function GetLangFileDir: string; 48 49 public 49 50 ComponentExcludes: TComponentExcludesList; … … 150 151 I: Integer; 151 152 LocaleShort: string; 153 SearchMask: string; 152 154 begin 153 155 FPOFiles.Clear; … … 157 159 //ShowMessage(ExtractFileDir(Application.ExeName) + 158 160 // DirectorySeparator + 'Languages' + ' ' + '*.' + LocaleShort + '.po'); 159 FileList := FindAllFiles(ExtractFileDir(UTF8Encode(Application.ExeName)) + 160 DirectorySeparator + FPOFilesFolder, '*.' + LocaleShort + '.po'); 161 SearchMask := '*'; 162 if LocaleShort <> '' then SearchMask := SearchMask + '.' + LocaleShort; 163 SearchMask := SearchMask + '.po'; 164 FileList := FindAllFiles(GetLangFileDir, SearchMask); 161 165 for I := 0 to FileList.Count - 1 do begin 162 166 FileName := FileList[I]; 163 167 //FileName := FindLocaleFileName('.po'); 164 if FileExistsUTF8(FileName) then FPOFiles.Add(TPOFile.Create(FileName)); 168 if FileExists(FileName) and ( 169 ((LocaleShort = '') and (Pos('.', FileName) = Pos('.po', FileName))) or 170 (LocaleShort <> '')) then FPOFiles.Add(TPOFile.Create(FileName)); 165 171 end; 166 172 finally … … 174 180 FPoFilesFolder := AValue; 175 181 ReloadFiles; 182 CheckLanguageFiles; 176 183 end; 177 184 … … 223 230 var 224 231 PropType: PTypeInfo; 225 Parent: TObject;226 232 Obj: TObject; 227 233 I: Integer; … … 285 291 end; 286 292 293 function TCoolTranslator.GetLangFileDir: string; 294 begin 295 Result := FPOFilesFolder; 296 if Copy(Result, 1, 1) <> DirectorySeparator then 297 Result := ExtractFileDir(UTF8Encode(Application.ExeName)) + 298 DirectorySeparator + Result; 299 end; 300 287 301 procedure TCoolTranslator.LanguageListToStrings(Strings: TStrings); 288 302 var … … 317 331 I: Integer; 318 332 begin 333 Result := ''; 319 334 if Text <> '' then begin 320 335 for I := 0 to FPoFiles.Count - 1 do begin … … 343 358 var 344 359 I: Integer; 345 begin 360 LangDir: string; 361 begin 362 LangDir := GetLangFileDir; 346 363 TLanguage(Languages[0]).Available := True; // Automatic 347 364 348 365 for I := 1 to Languages.Count - 1 do 349 366 with TLanguage(Languages[I]) do begin 350 Available := FileExists UTF8(POFilesFolder + DirectorySeparator + ExtractFileNameOnly(Application.ExeName) +367 Available := FileExists(LangDir + DirectorySeparator + ExtractFileNameOnly(Application.ExeName) + 351 368 '.' + Code + ExtensionSeparator + 'po') or (Code = 'en'); 352 369 end; … … 383 400 begin 384 401 // Win32 user may decide to override locale with LANG variable. 385 Lang := GetEnvironmentVariable UTF8('LANG');402 Lang := GetEnvironmentVariable('LANG'); 386 403 387 404 // Use user selected language … … 391 408 if Lang = '' then begin 392 409 for i := 1 to Paramcount - 1 do 393 if (ParamStr UTF8(i) = '--LANG') or (ParamStrUTF8(i) = '-l') or394 (ParamStr UTF8(i) = '--lang') then395 Lang := ParamStr UTF8(i + 1);410 if (ParamStr(i) = '--LANG') or (ParamStr(i) = '-l') or 411 (ParamStr(i) = '--lang') then 412 Lang := ParamStr(i + 1); 396 413 end; 397 414 if Lang = '' then 398 L CLGetLanguageIDs(Lang, T);415 LazGetLanguageIDs(Lang, T); 399 416 400 417 if Assigned(Language) and (Language.Code = '') and Assigned(FOnAutomaticLanguage) then begin … … 402 419 end; 403 420 404 if Lang = 'en' then Lang := ''; // English files are without en code405 406 421 Result := Lang; 407 422 end; … … 415 430 var 416 431 T: string; 417 I: Integer;418 432 Lang: string; 419 433 begin … … 425 439 Exit; 426 440 427 Result := ChangeFileExt(ParamStr UTF8(0), LCExt);441 Result := ChangeFileExt(ParamStr(0), LCExt); 428 442 if FileExistsUTF8(Result) then 429 443 Exit;
Note:
See TracChangeset
for help on using the changeset viewer.