File indexing completed on 2024-11-24 04:16:54

0001 /*
0002   SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org>
0003 
0004   SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "texttranslator_export.h"
0010 #include <QString>
0011 
0012 class QComboBox;
0013 
0014 namespace TextTranslator
0015 {
0016 class TEXTTRANSLATOR_EXPORT TranslatorUtil
0017 {
0018 public:
0019     TranslatorUtil();
0020 
0021     struct TranslatorSettings {
0022         QString engine;
0023         QString from;
0024         QString to;
0025     };
0026 
0027     enum Language : int {
0028         automatic = 0,
0029         en,
0030         bs,
0031         hmong,
0032         zh,
0033         zt,
0034         nl,
0035         fr,
0036         de,
0037         el,
0038         it,
0039         ja,
0040         ko,
0041         pt,
0042         ru,
0043         es,
0044         af,
0045         sq,
0046         ar,
0047         hy,
0048         az,
0049         eu,
0050         be,
0051         bg,
0052         ca,
0053         hr,
0054         cs,
0055         da,
0056         et,
0057         tl,
0058         fi,
0059         gl,
0060         ka,
0061         ht,
0062         iw,
0063         hi,
0064         hu,
0065         is,
0066         id,
0067         ga,
0068         lv,
0069         lt,
0070         mk,
0071         ms,
0072         mt,
0073         no,
0074         fa,
0075         pl,
0076         ro,
0077         sr,
0078         sk,
0079         sl,
0080         sw,
0081         sv,
0082         th,
0083         tr,
0084         uk,
0085         ur,
0086         vi,
0087         cy,
0088         yi,
0089         lastLanguage = yi
0090     };
0091     void addItemToFromComboBox(QComboBox *combo, const QString &languageCode, const QString &translatedStr);
0092 
0093     // Only for test
0094     [[nodiscard]] static QMap<TranslatorUtil::Language, QString> translatedLanguages();
0095 
0096     [[nodiscard]] static QString loadEngine();
0097     static void saveEngineSettings(const QString &engineName);
0098     [[nodiscard]] static QString groupTranslateName();
0099     [[nodiscard]] static QString engineTranslateName();
0100     [[nodiscard]] static QString defaultEngineName();
0101     [[nodiscard]] static QString translatedLanguage(TranslatorUtil::Language lang);
0102     [[nodiscard]] static QString languageCode(TranslatorUtil::Language lang);
0103     [[nodiscard]] static QString searchI18nFromLanguage(const QString &langCode);
0104     [[nodiscard]] static TranslatorUtil::Language stringToLanguage(const QString &str);
0105 };
0106 }