| 1 | // For license of this file, see <project-root-folder>/LICENSE.md. |
| 2 | |
| 3 | #ifndef LOCALIZATION_H |
| 4 | #define LOCALIZATION_H |
| 5 | |
| 6 | #include <QLocale> |
| 7 | #include <QObject> |
| 8 | #include <QString> |
| 9 | |
| 10 | struct Language { |
| 11 | QString m_name; |
| 12 | QString m_code; |
| 13 | }; |
| 14 | |
| 15 | class RSSGUARD_DLLSPEC Localization : public QObject { |
| 16 | Q_OBJECT |
| 17 | |
| 18 | public: |
| 19 | // Constructor. |
| 20 | explicit Localization(QObject* parent = nullptr); |
| 21 | |
| 22 | // Destructor. |
| 23 | virtual ~Localization(); |
| 24 | |
| 25 | // Returns code of language that should |
| 26 | // be loaded according to settings. |
| 27 | QString desiredLanguage() const; |
| 28 | |
| 29 | // Loads currently active language. |
| 30 | void loadActiveLanguage(); |
| 31 | |
| 32 | // Returns list of installed application localizations. |
| 33 | // This list is used ie. in settings dialog. |
| 34 | QList<Language> installedLanguages() const; |
| 35 | |
| 36 | // Returns empty string or loaded language |
| 37 | // name if it is really loaded. |
| 38 | QString loadedLanguage() const; |
| 39 | |
| 40 | // Returns loaded locale. |
| 41 | QLocale loadedLocale() const; |
| 42 | |
| 43 | private: |
| 44 | QString m_loadedLanguage; |
| 45 | QLocale m_loadedLocale; |
| 46 | }; |
| 47 | |
| 48 | inline QString Localization::loadedLanguage() const { |
| 49 | return m_loadedLanguage; |
| 50 | } |
| 51 | |
| 52 | inline QLocale Localization::loadedLocale() const { |
| 53 | return m_loadedLocale; |
| 54 | } |
| 55 | |
| 56 | #endif // LOCALIZATION_H |