fGLForm.pas 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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(TTable);
  52. //TP_GlobalIgnoreClass(TFields);
  53. //TP_GlobalIgnoreClass(TFont);
  54. //TP_GlobalIgnoreClass(TListBox);
  55. //TP_GlobalIgnoreClass(TStaticText);
  56. //TP_GlobalIgnoreClass(TGLLibMaterial);
  57. //TP_GlobalIgnoreClass(TGLMaterialLibrary);
  58. TP_IgnoreClass(TFont);
  59. TP_GlobalIgnoreClassProperty(TAction, 'Category');
  60. // Removing the upper line will cause long loading but Action.Category translation
  61. case LangID of
  62. LANG_RUSSIAN:
  63. begin
  64. UseLanguage('ru');
  65. Application.HelpFile := UpperCase(LocalePath + 'ru'+ PathDelim+'GLSViewer.chm');
  66. end;
  67. LANG_SPANISH:
  68. begin
  69. UseLanguage('es');
  70. Application.HelpFile := UpperCase(LocalePath + 'es'+ PathDelim+'GLSViewer.chm');
  71. end;
  72. LANG_PORTUGUESE:
  73. begin
  74. UseLanguage('it');
  75. Application.HelpFile := UpperCase(LocalePath + 'it'+ PathDelim+'GLSViewer.chm');
  76. end
  77. else
  78. begin
  79. UseLanguage('en');
  80. Application.HelpFile := UpperCase(LocalePath + 'en'+ PathDelim+'GLSViewer.chm');
  81. end;
  82. end;
  83. end
  84. else
  85. begin
  86. UseLanguage('en');
  87. Application.HelpFile := UpperCase(LocalePath + 'en'+ PathDelim+'GLSViewer.chm');
  88. end;
  89. TranslateComponent(Self);
  90. //TP_GlobalIgnoreClass(TGLLibMaterial);
  91. //TP_GlobalIgnoreClass(TGLMaterialLibrary);
  92. //TP_GlobalIgnoreClass(TListBox);
  93. //TP_GlobalIgnoreClassProperty(TAction, 'Category');
  94. end;
  95. procedure TGLForm.ReadIniFile;
  96. begin
  97. IniFile := TIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));
  98. with IniFile do
  99. try
  100. LangID := ReadInteger('FormOptions', 'RadioGroupLanguage', 0);
  101. finally
  102. IniFile.Free;
  103. end;
  104. end;
  105. end.