mirror of
https://github.com/kiwix/libkiwix.git
synced 2025-06-27 21:39:37 +00:00
Got rid of langMap in opds_dumper.cpp
Language code to human friendly name translation is now done with the help of the ICU library. It works if the line ``` -include $(LANGSRCDIR)/resfiles.mk ``` in the file `source/data/Makefile.in` of the icu4c dependency is not commented out. Currently, the said line is commented out (along with some other include's) by the `icu4c_custom_data.patch` patch of the `kiwix-build` tool.
This commit is contained in:
committed by
Matthieu Gautier
parent
8a4248e48e
commit
dd118df612
@ -84,22 +84,22 @@ BookData getBookData(const Library* library, const std::vector<std::string>& boo
|
||||
return bookData;
|
||||
}
|
||||
|
||||
struct LangInfo {
|
||||
std::string selfName, englishName;
|
||||
};
|
||||
|
||||
std::map<std::string, LangInfo> langMap = {
|
||||
{"eng", { "English", "English"} },
|
||||
{"fra", { "Français", "French"} },
|
||||
{"rus", { "Русский", "Russian"} },
|
||||
};
|
||||
|
||||
std::string getLanguageSelfName(const std::string& lang) {
|
||||
return langMap.at(lang).selfName;
|
||||
const icu::Locale locale(lang.c_str());
|
||||
icu::UnicodeString ustring;
|
||||
locale.getDisplayLanguage(locale, ustring);
|
||||
std::string result;
|
||||
ustring.toUTF8String(result);
|
||||
return result;
|
||||
};
|
||||
|
||||
std::string getLanguageEnglishName(const std::string& lang) {
|
||||
return langMap.at(lang).englishName;
|
||||
const icu::Locale locale(lang.c_str());
|
||||
icu::UnicodeString ustring;
|
||||
locale.getDisplayLanguage(icu::Locale("en"), ustring);
|
||||
std::string result;
|
||||
ustring.toUTF8String(result);
|
||||
return result;
|
||||
};
|
||||
|
||||
} // unnamed namespace
|
||||
|
Reference in New Issue
Block a user