fGLForm.pas 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. end;
  38. //----------------------------------------------------------
  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. ReadIniFile;
  47. if (LangID <> LANG_ENGLISH) then
  48. begin
  49. Textdomain('glsviewer');
  50. BindTextDomain ('glsviewer', LocalePath);
  51. AddDomainForResourceString('language');
  52. BindTextDomain ('language', LocalePath);
  53. //TP_GlobalIgnoreClass(TTable);
  54. //TP_GlobalIgnoreClass(TFields);
  55. //TP_GlobalIgnoreClass(TFont);
  56. //TP_GlobalIgnoreClass(TListBox);
  57. //TP_GlobalIgnoreClass(TStaticText);
  58. //TP_GlobalIgnoreClass(TGLLibMaterial);
  59. //TP_GlobalIgnoreClass(TGLMaterialLibrary);
  60. TP_IgnoreClass(TFont);
  61. TP_GlobalIgnoreClassProperty(TAction, 'Category');
  62. // Removing the upper line will cause long loading but Action.Category translation
  63. case LangID of
  64. LANG_RUSSIAN:
  65. begin
  66. UseLanguage('ru');
  67. Application.HelpFile := UpperCase(LocalePath + 'ru'+ PathDelim+'GLSViewer.chm');
  68. end;
  69. LANG_SPANISH:
  70. begin
  71. UseLanguage('es');
  72. Application.HelpFile := UpperCase(LocalePath + 'es'+ PathDelim+'GLSViewer.chm');
  73. end;
  74. LANG_GERMAN:
  75. begin
  76. UseLanguage('de');
  77. Application.HelpFile := UpperCase(LocalePath + 'de'+ PathDelim+'GLSViewer.chm');
  78. end;
  79. LANG_FRENCH:
  80. begin
  81. UseLanguage('fr');
  82. Application.HelpFile := UpperCase(LocalePath + 'fr'+ PathDelim+'GLSViewer.chm');
  83. end
  84. else
  85. begin
  86. UseLanguage('en');
  87. Application.HelpFile := UpperCase(LocalePath + 'en'+ PathDelim+'GLSViewer.chm');
  88. end;
  89. end;
  90. end
  91. else
  92. begin
  93. UseLanguage('en');
  94. Application.HelpFile := UpperCase(LocalePath + 'en'+ PathDelim+'GLSViewer.chm');
  95. end;
  96. TranslateComponent(Self);
  97. //TP_GlobalIgnoreClass(TGLLibMaterial);
  98. //TP_GlobalIgnoreClass(TGLMaterialLibrary);
  99. //TP_GlobalIgnoreClass(TListBox);
  100. //TP_GlobalIgnoreClassProperty(TAction, 'Category');
  101. end;
  102. procedure TGLForm.ReadIniFile;
  103. begin
  104. IniFile := TIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));
  105. with IniFile do
  106. try
  107. LangID := ReadInteger('GLOptions', 'RadioGroupLanguage', 0);
  108. finally
  109. IniFile.Free;
  110. end;
  111. end;
  112. procedure TGLForm.WriteIniFile;
  113. begin
  114. //
  115. end;
  116. end.