OpenLexocad  27.1
TranslatorPython.h
Go to the documentation of this file.
1 #pragma once
2 #pragma warning(disable : 4251)
3 
4 //----------------------------------------------------------------------------
5 // INCLUDEs
6 //----------------------------------------------------------------------------
7 #include <Base/Translator.h>
8 #include <qmap.h>
9 
10 #include <QString>
11 #include <map>
12 
13 //----------------------------------------------------------------------------
14 // DECLARATIONs
15 //----------------------------------------------------------------------------
16 
21 class LX_BASE_EXPORT PTranslator
22 {
23 public:
24  typedef QMap<QString, int> CustomTranslationsTable;
25 
26  static QString get(int id, bool forceEnglish = false);
27  static QString getSpecial(int id, bool forceEnglish = false);
28  static QStringList getInAllLanguages(int id);
29 
30  static void setLanguage(CTranslator::Language lang);
31  static CTranslator::Language getLanguage();
32  static QString getLanguageAsString();
33  static void setLanguageFromString(const QString& lang);
34 
35  static CustomTranslationsTable readCustomTranslationsTable(const QString& filename);
36  static QString translate(const CustomTranslationsTable& table, const QString& source, bool emptyIfNotInTable = false);
37 
38  static void showMessageId(bool onoff);
39  static void showCodeId(bool onoff);
40 
41  static QString getCdwkStringFromLanguage(CTranslator::Language lang);
42  static CTranslator::Language getLanguageFromCdwkString(const QString& lang);
43 
44 private:
46  static PTranslator* _instance;
47 
49  CTranslator::Language _lang;
50 
52  std::map<int, QString> _de;
54  std::map<int, QString> _en;
56  std::map<int, QString> _fr;
58  std::map<int, QString> _sp;
60  std::map<int, QString> _po;
62  std::map<int, QString> _ro;
64  std::map<int, QString> _hu;
66  std::map<int, QString> _ru;
68  std::map<int, QString> _pl;
70  std::map<int, QString> _it;
72  std::map<int, QString> _cz;
74  std::map<int, QString> _uk;
75 
76  // Note: when adding new language, don't forget to modify getInAllLanguages(). -mh-
77 
78  struct Flags
79  {
80  bool html;
81  QString code;
82  };
83 
85  std::map<int, Flags> _flags;
86 
87  bool _showMessageId = false;
88  bool _showCodeId = false;
89 
90  // internal private methods
91  PTranslator();
92  ~PTranslator();
93 
94  void init();
95 
96  bool loadFile(CTranslator::Language lang) const;
97 
98  QString _getPathToTranslation(wchar_t* dllName) const;
99 };
QMap< QString, int > CustomTranslationsTable
Definition: TranslatorPython.h:24
Definition: TranslatorPython.h:21
Core::PropertyText filename
Definition: CoreDocument.h:176
constexpr get_t< Type... > get
Variable template for lists of observed components.
Definition: entt.hpp:6068