OpenLexocad  27.0
Translator.h
Go to the documentation of this file.
1 
9 #ifndef TRANSLATOR__H
10 #define TRANSLATOR__H
11 
12 #pragma warning(disable : 4251)
13 
14 //----------------------------------------------------------------------------
15 // INCLUDEs
16 //----------------------------------------------------------------------------
17 #ifdef _WIN32
18 //#include <windows.h>
19 #endif
20 
21 #include <Base/base_defines.h>
22 #include <qmap.h>
23 
24 #include <QString>
25 #include <QLocale>
26 #include <map>
27 
28 //----------------------------------------------------------------------------
29 // DECLARATIONs
30 //----------------------------------------------------------------------------
31 
36 class BASE_EXPORT CTranslator
37 {
38 public:
40  enum Language
41  {
42  ENGLISH,
43  GERMAN,
44  FRENCH,
45  SPANISH,
46  PORTUGUESE,
47  ROMANIAN,
48  HUNGARIAN,
49  RUSSIAN,
50  POLISH,
51  ITALIAN,
52  CZECH,
53  UKRAINE
54  };
55 
56  typedef QMap<QString, int> CustomTranslationsTable;
57 
58 public:
59  static QString get(int id, bool forceEnglish = false);
60  static QString getSpecial(int id, bool forceEnglish = false);
61  static QStringList getInAllLanguages(int id);
62 
63  static void setLanguage(Language lang);
64  static Language getLanguage();
65  static QString getLanguageAsString();
66  static void setLanguageFromString(const QString& lang);
67 
68  static CustomTranslationsTable readCustomTranslationsTable(const QString& filename);
69  static QString translate(const CustomTranslationsTable& table, const QString& source, bool emptyIfNotInTable = false);
70 
71  static void showMessageId(bool onoff);
72  static void showCodeId(bool onoff);
73 
74  static QString getCdwkStringFromLanguage(Language lang);
75  static Language getLanguageFromCdwkString(const QString& lang);
76 
77  static QLocale getQLocale();
78 
79  static QString getTranslatorDirPath();
80 
81 private:
83  static CTranslator* _instance;
84 
86  Language _lang;
87 
89  // QStringList _de;
90  std::map<int, QString> _de;
92  // QStringList _en;
93  std::map<int, QString> _en;
95  // QStringList _fr;
96  std::map<int, QString> _fr;
98  std::map<int, QString> _sp;
100  std::map<int, QString> _po;
102  std::map<int, QString> _ro;
104  std::map<int, QString> _hu;
106  std::map<int, QString> _ru;
108  std::map<int, QString> _pl;
110  std::map<int, QString> _it;
112  std::map<int, QString> _cz;
114  std::map<int, QString> _uk;
115  // Note: when adding new language, don't forget to modify getInAllLanguages(). -mh-
116 
117  struct Flags
118  {
119  bool html;
120  QString code;
121  };
123  std::map<int, Flags> _flags;
124 
125  bool _showMessageId = false;
126  bool _showCodeId = false;
127 
128  // internal private methods
129  CTranslator();
130  ~CTranslator();
131 
132  void init();
133 
134  bool loadFile(Language lang);
135 
136  QString _getPathToTranslation(wchar_t* dllName);
137 };
138 
139 
140 #endif
#define BASE_EXPORT
Definition: base_defines.h:12
Core::PropertyText filename
Definition: CoreDocument.h:151
constexpr get_t< Type... > get
Variable template for lists of observed components.
Definition: entt.hpp:6068