fGLForm.pas 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 WriteIniFile; virtual;
  24. procedure SetLanguage;
  25. end;
  26. var
  27. GLForm: TGLForm;
  28. LangID : Word;
  29. implementation
  30. {$R *.dfm}
  31. //Here goes the translation of all component strings
  32. //
  33. procedure TGLForm.FormCreate(Sender: TObject);
  34. begin
  35. inherited;
  36. SetLanguage;
  37. TranslateComponent(Self);
  38. end;
  39. procedure TGLForm.SetLanguage;
  40. var
  41. LocalePath : TFileName;
  42. IniFile : TIniFile;
  43. begin
  44. LocalePath := ExtractFileDir(ParamStr(0)); // Path to GLSViewer
  45. LocalePath := LocalePath + PathDelim + 'Locale' + PathDelim;
  46. Textdomain('glsviewer');
  47. BindTextDomain ('glsviewer', LocalePath);
  48. ReadIniFile;
  49. if (LangID <> LANG_ENGLISH) then
  50. begin
  51. case LangID of
  52. LANG_RUSSIAN:
  53. begin
  54. UseLanguage('ru');
  55. Application.HelpFile := UpperCase(LocalePath + 'ru'+ PathDelim+'GLSViewer.chm');
  56. end;
  57. LANG_SPANISH:
  58. begin
  59. UseLanguage('es');
  60. Application.HelpFile := UpperCase(LocalePath + 'es'+ PathDelim+'GLSViewer.chm');
  61. end;
  62. LANG_GERMAN:
  63. begin
  64. UseLanguage('de');
  65. Application.HelpFile := UpperCase(LocalePath + 'de'+ PathDelim+'GLSViewer.chm');
  66. end;
  67. LANG_FRENCH:
  68. begin
  69. UseLanguage('fr');
  70. Application.HelpFile := UpperCase(LocalePath + 'fr'+ PathDelim+'GLSViewer.chm');
  71. end
  72. else
  73. begin
  74. UseLanguage('en');
  75. Application.HelpFile := UpperCase(LocalePath + 'en'+ PathDelim+'GLSViewer.chm');
  76. end;
  77. end;
  78. end
  79. else
  80. begin
  81. UseLanguage('en');
  82. Application.HelpFile := UpperCase(LocalePath + 'en'+ PathDelim+'GLSViewer.chm');
  83. end;
  84. TP_IgnoreClass(TFont);
  85. TranslateComponent(Self);
  86. //TP_GlobalIgnoreClass(TGLLibMaterial);
  87. //TP_GlobalIgnoreClass(TGLMaterialLibrary);
  88. //TP_GlobalIgnoreClass(TListBox);
  89. //TP_GlobalIgnoreClassProperty(TAction, 'Category');
  90. //LoadNewResourceModule(Language);//when using ITE, ENU for English USA
  91. end;
  92. procedure TGLForm.ReadIniFile;
  93. begin
  94. IniFile := TIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));
  95. with IniFile do
  96. try
  97. LangID := ReadInteger('GLOptions', 'RadioGroupLanguage', 0);
  98. finally
  99. IniFile.Free;
  100. end;
  101. end;
  102. procedure TGLForm.WriteIniFile;
  103. begin
  104. //
  105. end;
  106. end.