ScreenTranslator/src/languagecodes.h

34 lines
761 B
C
Raw Normal View History

2020-02-21 00:45:53 +07:00
#pragma once
#include <QString>
#include <optional>
#include <unordered_map>
using LanguageId = QString;
class LanguageCodes
{
public:
2020-03-25 01:38:05 +07:00
static LanguageId idForTesseract(const QString& tesseract);
static LanguageId idForName(const QString& name);
static QString iso639_1(const LanguageId& id);
static QString tesseract(const LanguageId& id);
static QString name(const LanguageId& id);
static std::vector<LanguageId> allIds();
private:
2020-02-21 00:45:53 +07:00
struct Bundle {
LanguageId id;
QString iso639_1;
QString tesseract;
2020-03-18 02:15:28 +07:00
const char* name;
2020-02-21 00:45:53 +07:00
};
2020-03-25 01:38:05 +07:00
LanguageCodes() = delete;
LanguageCodes(const LanguageCodes&) = delete;
LanguageCodes& operator=(const LanguageCodes&) = delete;
2020-02-21 00:45:53 +07:00
const static std::unordered_map<LanguageId, Bundle> codes_;
};