OpenLexocad  27.1
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 <qmap.h>
22 
23 #include <QString>
24 #include <QLocale>
25 #include <map>
26 
27 //----------------------------------------------------------------------------
28 // DECLARATIONs
29 //----------------------------------------------------------------------------
30 
35 class LX_BASE_EXPORT CTranslator
36 {
37 public:
39  enum Language
40  {
41  ENGLISH,
42  GERMAN,
43  FRENCH,
44  SPANISH,
45  PORTUGUESE,
46  ROMANIAN,
47  HUNGARIAN,
48  RUSSIAN,
49  POLISH,
50  ITALIAN,
51  CZECH,
52  UKRAINE
53  };
54 
55  typedef QMap<QString, int> CustomTranslationsTable;
56 
57 public:
58  static QString get(int id, bool forceEnglish = false);
59  static QString getSpecial(int id, bool forceEnglish = false);
60 
61  /* convenience method, lookup for the english word, get the id and return the current translation */
62  static QString getByEnglish(QString eng);
63  static QStringList getInAllLanguages(int id);
64 
65  static void setLanguage(Language lang);
66  static Language getLanguage();
67  static QString getLanguageAsString();
68  static void setLanguageFromString(const QString& lang);
69 
70  static CustomTranslationsTable readCustomTranslationsTable(const QString& filename);
71  static QString translate(const CustomTranslationsTable& table, const QString& source, bool emptyIfNotInTable = false);
72 
73  static void showMessageId(bool onoff);
74 
75  static QString getCdwkStringFromLanguage(Language lang);
76  static Language getLanguageFromCdwkString(const QString& lang);
77 
78  static QLocale getQLocale();
79 
80  static QString getTranslatorDirPath();
81 
82 private:
84  static CTranslator* _instance;
85 
87  Language _lang;
88 
90  // QStringList _de;
91  std::map<int, QString> _de;
93  // QStringList _en;
94  std::map<int, QString> _en;
96  // QStringList _fr;
97  std::map<int, QString> _fr;
99  std::map<int, QString> _sp;
101  std::map<int, QString> _po;
103  std::map<int, QString> _ro;
105  std::map<int, QString> _hu;
107  std::map<int, QString> _ru;
109  std::map<int, QString> _pl;
111  std::map<int, QString> _it;
113  std::map<int, QString> _cz;
115  std::map<int, QString> _uk;
116  // Note: when adding new language, don't forget to modify getInAllLanguages(). -mh-
117 
118  // QStringList reverse_en;
119  std::map<QString, int> _reverse_en;
120 
121  struct Flags
122  {
123  bool html;
124  };
126  std::map<int, Flags> _flags;
127 
128  bool _showMessageId = false;
129 
130  // internal private methods
131  CTranslator();
132  ~CTranslator();
133 
134  void init();
135 
136  bool loadFile(Language lang);
137 
138  QString _getPathToTranslation(wchar_t* dllName);
139 };
140 
141 
142 #endif
Core::PropertyText filename
Definition: CoreDocument.h:176
constexpr get_t< Type... > get
Variable template for lists of observed components.
Definition: entt.hpp:6068