Advertisement
Vsevolod

EsI18nManager usage

May 3rd, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1. //< In main project file
  2. extern "C" int FMXmain()
  3. {
  4.   try
  5.   {
  6.     Application->Initialize();
  7.  
  8.     static const UnicodeString sc_localePath =
  9.       IncludeTrailingPathDelimiter(
  10.         System::Ioutils::TPath::GetDocumentsPath()
  11.       );
  12.  
  13.     EsI18nManager::langFileLoad(
  14.       "ru",
  15.       sc_localePath
  16.     );
  17.  
  18.   // ...
  19.  
  20.  
  21. // Form header
  22. class TFrmMain : public TForm
  23. {
  24. private:  
  25.   class I18nHandler: public EsI18nSubscriberIntf
  26.   {
  27.   public:
  28.     I18nHandler(TFrmMain& owner);
  29.  
  30.     virtual void onLangChanged(const UnicodeString& lang);
  31.  
  32.   private:
  33.     TFrmMain& m_owner;
  34.   };
  35.   friend class I18nHandler;
  36.  
  37.   // ....
  38.  
  39.  
  40. // Form implementation
  41. //  
  42. TFrmMain::I18nHandler::I18nHandler(TFrmMain& owner):
  43. EsI18nSubscriberIntf(),
  44. m_owner(owner)
  45. {}
  46. //---------------------------------------------------------------------------
  47.  
  48. void TFrmMain::I18nHandler::onLangChanged(const UnicodeString& lang)
  49. {
  50.   m_owner.m_textUpdatePending = true;
  51.  
  52.   m_owner.actions_->langCodeSet(lang);
  53.   if( m_owner.Active )
  54.     m_owner.textUpdate();
  55. }
  56. //---------------------------------------------------------------------------
  57.  
  58. __fastcall TFrmMain::TFrmMain(TComponent* Owner) :
  59. TForm(Owner),
  60. m_i18n(*this),
  61. m_textUpdatePending(true)
  62. {
  63.   /// ....
  64.  
  65. void TFrmMain::textUpdate()
  66. {
  67.   if( !m_textUpdatePending )
  68.     return;
  69.  
  70.   m_textUpdatePending = false;
  71.  
  72.   grpMain_->Text = _("Main");
  73.  
  74.   itemCalc_->Text = _("Soap Calculator");
  75.   itemCalc_->ItemData->Detail = _("Create your own soap brew...");
  76.  
  77.   itemRecipes_->Text = _("Recipes");
  78.   itemRecipes_->ItemData->Detail = _("Browse soap recipes...");
  79.  
  80.   grpExtra_->Text = _("Extras");
  81.  
  82.   //...
  83.  
  84. void __fastcall TFrmMain::FormActivate(TObject *Sender)
  85. {
  86.   textUpdate();
  87.  
  88.   // ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement