translate Pile   version 0.0.1
This pile provides support for an application that
translang.h
1 
10 #ifndef GUARD_TRANSLANG_H_INCLUDE
11 #define GUARD_TRANSLANG_H_INCLUDE
12 
13 #include <translate/translate-config.h>
14 #include <QString>
15 #include <QMap>
16 #include <QTranslator>
17 
19 class TRANSLATE_EXPORT TransLang {
20 
21  friend class Translate;
22 
23 public:
24 
26  TransLang (
27  const QString & dir,
28  const QString & langfile,
29  const QString & name,
30  const QString & icon,
31  const QString & locale);
32 
34  TransLang ();
35 
37  virtual ~TransLang();
38 
39 
41  bool
42  isValid () const;
43 
45  const QString &
46  langDirectory () const {
47  return path_;
48  }
49 
51  const QString &
52  langFile () const {
53  return langfile_;
54  }
55 
57  QString
58  qtLangFile () const;
59 
61  const QString &
62  langName () const {
63  return name_;
64  }
65 
67  const QString &
68  localeName () const {
69  return locale_;
70  }
71 
73  const QString &
74  langIcon () const {
75  return icon_;
76  }
77 
79  const QMap<QString, QString> &
80  metadata () const {
81  return metadata_;
82  }
83 
84  bool
85  hasCachedTranslator () const {
86  return transl_ != NULL;
87  }
88 
89  bool
90  hasCachedQtTranslator () const {
91  return qttransl_ != NULL;
92  }
93 
94 protected:
95 
97  QTranslator *
98  translator ();
99 
101  QTranslator *
102  qtTranslator ();
103 
105  void
106  translatorDone ();
107 
109  void
110  addMetadata (
111  const QString & key,
112  const QString & value);
113 
114 
115 private:
116  QString path_;
117  QString langfile_;
118  QString name_;
119  QString icon_;
120  QString locale_;
121  QMap<QString, QString> metadata_;
122  QTranslator * transl_;
123  QTranslator * qttransl_;
124 };
125 
126 inline bool operator== (
127  const TransLang& lhs, const TransLang& rhs) {
128  return (lhs.langDirectory () == rhs.langDirectory ()) &&\
129  (lhs.langName () == rhs.langName ()) &&\
130  (lhs.langIcon () == rhs.langIcon ()) &&\
131  (lhs.langFile () == rhs.langFile ());
132 }
133 inline bool operator!= (
134  const TransLang& lhs, const TransLang& rhs) {
135  return !operator==(lhs, rhs);
136 }
137 
138 #endif // GUARD_TRANSLANG_H_INCLUDE
static QTranslator * qtTranslator(int i)
Create a Qt translator.
Definition: translate.cc:299
brief description
Definition: translang.h:19
const QString & langDirectory() const
Absolute paths towards language directory.
Definition: translang.h:46
const QString & langFile() const
Get the absolute path for the language file.
Definition: translang.h:52
const QString & langIcon() const
Get the icon of this language.
Definition: translang.h:74
static QTranslator * translator(int i)
Create a Qt translator.
Definition: translate.cc:287
const QString & localeName() const
Get the name of this locale.
Definition: translang.h:68
brief description
Definition: translate.h:18
const QString & langName() const
Get the name of this language.
Definition: translang.h:62
const QMap< QString, QString > & metadata() const
Get the icon of this language.
Definition: translang.h:80
static void translatorDone(int i)
Release cached translator.
Definition: translate.cc:311