Open Source Snapmatic picture and Savegame viewer/editor for GTA V https://gta5view.syping.de/

TranslationClass.h 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*****************************************************************************
  2. * gta5view Grand Theft Auto V Profile Viewer
  3. * Copyright (C) 2017 Syping
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *****************************************************************************/
  18. #ifndef TRANSLATIONCLASS_H
  19. #define TRANSLATIONCLASS_H
  20. #include <QApplication>
  21. #include <QTranslator>
  22. #include <QStringList>
  23. #include <QString>
  24. #include <QObject>
  25. #include <QLocale>
  26. class TranslationClass : public QObject
  27. {
  28. Q_OBJECT
  29. public:
  30. static TranslationClass* getInstance() { return &translationClassInstance; }
  31. static QString getCountryCode(QLocale::Country country);
  32. static QString getCountryCode(QLocale locale);
  33. void initUserLanguage();
  34. void loadTranslation(QApplication *app);
  35. void unloadTranslation(QApplication *app);
  36. static QStringList listTranslations(const QString &langPath);
  37. static QStringList listAreaTranslations();
  38. QString getCurrentAreaLanguage();
  39. QString getCurrentLanguage();
  40. bool isLanguageLoaded();
  41. private:
  42. static TranslationClass translationClassInstance;
  43. bool loadSystemTranslation_p(const QString &langPath, QTranslator *appTranslator);
  44. bool loadUserTranslation_p(const QString &langPath, QTranslator *appTranslator);
  45. bool loadQtTranslation_p(const QString &langPath, QTranslator *qtTranslator);
  46. bool isUserLanguageSystem_p();
  47. QTranslator exAppTranslator;
  48. QTranslator exQtTranslator;
  49. QTranslator inAppTranslator;
  50. QTranslator inQtTranslator;
  51. QString userAreaLanguage;
  52. QString currentLanguage;
  53. QString userLanguage;
  54. int currentLangIndex;
  55. bool isEnglishMode;
  56. bool isLangLoaded;
  57. };
  58. extern TranslationClass translationClass;
  59. #define Translator TranslationClass::getInstance()
  60. #endif // TRANSLATIONCLASS_H