OpenLexocad  27.0
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 <Base/base_defines.h>
9 #include <qmap.h>
10 
11 #include <QString>
12 #include <map>
13 
14 //----------------------------------------------------------------------------
15 // DECLARATIONs
16 //----------------------------------------------------------------------------
17 
23 {
24 public:
25  typedef QMap<QString, int> CustomTranslationsTable;
26 
27  static QString get(int id, bool forceEnglish = false);
28  static QString getSpecial(int id, bool forceEnglish = false);
29  static QStringList getInAllLanguages(int id);
30 
31  static void setLanguage(CTranslator::Language lang);
32  static CTranslator::Language getLanguage();
33  static QString getLanguageAsString();
34  static void setLanguageFromString(const QString& lang);
35 
36  static CustomTranslationsTable readCustomTranslationsTable(const QString& filename);
37  static QString translate(const CustomTranslationsTable& table, const QString& source, bool emptyIfNotInTable = false);
38 
39  static void showMessageId(bool onoff);
40  static void showCodeId(bool onoff);
41 
42  static QString getCdwkStringFromLanguage(CTranslator::Language lang);
43  static CTranslator::Language getLanguageFromCdwkString(const QString& lang);
44 
45 private:
47  static PTranslator* _instance;
48 
50  CTranslator::Language _lang;
51 
53  std::map<int, QString> _de;
55  std::map<int, QString> _en;
57  std::map<int, QString> _fr;
59  std::map<int, QString> _sp;
61  std::map<int, QString> _po;
63  std::map<int, QString> _ro;
65  std::map<int, QString> _hu;
67  std::map<int, QString> _ru;
69  std::map<int, QString> _pl;
71  std::map<int, QString> _it;
73  std::map<int, QString> _cz;
75  std::map<int, QString> _uk;
76 
77  // Note: when adding new language, don't forget to modify getInAllLanguages(). -mh-
78 
79  struct Flags
80  {
81  bool html;
82  QString code;
83  };
84 
86  std::map<int, Flags> _flags;
87 
88  bool _showMessageId = false;
89  bool _showCodeId = false;
90 
91  // internal private methods
92  PTranslator();
93  ~PTranslator();
94 
95  void init();
96 
97  bool loadFile(CTranslator::Language lang) const;
98 
99  QString _getPathToTranslation(wchar_t* dllName) const;
100 };
QMap< QString, int > CustomTranslationsTable
Definition: TranslatorPython.h:25
Definition: TranslatorPython.h:22
#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