3#include <c++utilities/conversion/stringconversion.h>
5#include <unordered_map>
7using namespace std::literals;
12static const auto &languageNames_ISO_639_2_b()
14#include "resources/iso_language_codes.h"
15 return languageNames_iso_639_2_b;
22inline static bool isLanguageDefined_ISO_639_2(
const std::string &languageSpecification)
24 return !languageSpecification.empty() && languageSpecification !=
"und" && languageSpecification !=
"XXX";
31static const std::string &languageName_ISO_639_2(
const std::string &isoCode)
33 static const std::string empty;
34 if (!isLanguageDefined_ISO_639_2(isoCode)) {
37 const auto &mapping = languageNames_ISO_639_2_b();
38 const auto i = mapping.find(isoCode);
39 if (i == mapping.cend()) {
64 for (
const auto &detail : *
this) {
65 if (!detail.empty() && detail.format == format && isLanguageDefined_ISO_639_2(detail)) {
89 for (
const auto &detail : *
this) {
91 &&
static_cast<std::underlying_type_t<LocaleFormat>
>(detail.format) >=
static_cast<std::underlying_type_t<LocaleFormat>
>(format)) {
92 if (detail.format == preferredFormat) {
95 format = detail.format;
96 mostRelevantDetail = &detail;
99 if (!mostRelevantDetail || !isLanguageDefined_ISO_639_2(*mostRelevantDetail)) {
102 return *mostRelevantDetail;
112 for (
const auto &detail : *
this) {
114 return languageName_ISO_639_2(detail);
126 if (
const auto &name =
fullName(); !name.empty()) {
Contains all classes and functions of the TagInfo library.
LocaleFormat
The LocaleFormat enum class specifies the format used by a LocaleDetail.
The LocaleDetail struct specifies a language and/or country.
static const LocaleDetail & getEmpty()
Returns an empty LocaleDetail.
LocaleDetail()
Constructs an empty LocaleDetail.
const LocaleDetail & abbreviatedName(LocaleFormat format) const
Returns the abbreviated name of the specified format.
const std::string & fullOrSomeAbbreviatedName() const
Returns the full name if possible and otherwise falls back to the abbreviated name.
std::string toString() const
Returns all details as comma-separated string.
const std::string & fullName() const
const LocaleDetail & someAbbreviatedName(LocaleFormat preferredFormat=LocaleFormat::BCP_47) const
Returns some abbreviated name, preferably of the specified preferredFormat.