fGLForm.pas 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //---------------------------------------
  2. // This unit is part of the GLSViewer
  3. //---------------------------------------
  4. unit fGLForm;
  5. (* The fGLForm unit for TGLForm class as parent for all child forms of GLSViewer *)
  6. interface
  7. uses
  8. Winapi.Windows,
  9. System.SysUtils,
  10. System.IniFiles,
  11. Vcl.Forms,
  12. Vcl.Graphics,
  13. Vcl.Menus,
  14. Vcl.Actnlist,
  15. gnuGettext;
  16. type
  17. TGLForm = class(TForm)
  18. procedure FormCreate(Sender: TObject);
  19. private
  20. public
  21. IniFile : TIniFile;
  22. procedure ReadIniFile; virtual;
  23. procedure SetLanguage;
  24. end;
  25. var
  26. GLForm: TGLForm;
  27. LangID : Word;
  28. implementation
  29. {$R *.dfm}
  30. //Here goes the translation of all component strings
  31. //
  32. procedure TGLForm.FormCreate(Sender: TObject);
  33. begin
  34. SetLanguage;
  35. end;
  36. //----------------------------------------------------------
  37. procedure TGLForm.SetLanguage;
  38. var
  39. LocalePath : TFileName;
  40. IniFile : TIniFile;
  41. begin
  42. LocalePath := ExtractFileDir(ParamStr(0)); // Path to GLSViewer
  43. LocalePath := LocalePath + PathDelim + 'Locale' + PathDelim;
  44. ReadIniFile;
  45. if (LangID <> LANG_ENGLISH) then
  46. begin
  47. Textdomain('glsviewer');
  48. BindTextDomain ('glsviewer', LocalePath);
  49. AddDomainForResourceString('language');
  50. BindTextDomain ('language', LocalePath);
  51. //TP_GlobalIgnoreClass(TListBox);
  52. //TP_GlobalIgnoreClass(TStaticText);
  53. //TP_GlobalIgnoreClass(TGLLibMaterial);
  54. //TP_GlobalIgnoreClass(TGLMaterialLibrary);
  55. // TP_IgnoreClass(TFont);
  56. // TP_GlobalIgnoreClassProperty(TAction, 'Category');
  57. // Removing the upper line will cause long loading but Action.Category translation
  58. case LangID of
  59. LANG_RUSSIAN:
  60. begin
  61. UseLanguage('ru');
  62. // Help based on demos.htm
  63. Application.HelpFile := UpperCase(LocalePath + 'ru'+ PathDelim+'Demos.chm');
  64. end
  65. else
  66. begin
  67. UseLanguage('en');
  68. Application.HelpFile := UpperCase(LocalePath + 'en'+ PathDelim+'Demos.chm');
  69. end;
  70. end;
  71. end
  72. else
  73. begin
  74. UseLanguage('en');
  75. Application.HelpFile := UpperCase(LocalePath + 'en'+ PathDelim+'GLSViewer.chm');
  76. end;
  77. TranslateComponent(Self);
  78. end;
  79. procedure TGLForm.ReadIniFile;
  80. begin
  81. IniFile := TIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));
  82. with IniFile do
  83. try
  84. // use correct argument names
  85. LangID := ReadInteger('FormOptions', 'rgLanguage', 0);
  86. finally
  87. IniFile.Free;
  88. end;
  89. end;
  90. end.