mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-24 11:54:01 +00:00
BCP 47: add ISO 639-3 languages (only those of type "living")
Part of the implementation of #3007.
This commit is contained in:
parent
c9884c3e77
commit
6a5b4b97db
@ -1,14 +1,36 @@
|
||||
def create_iso639_language_list_file
|
||||
cpp_file_name = "src/common/iso639_language_list.cpp"
|
||||
iso639_2 = JSON.parse(IO.readlines("/usr/share/iso-codes/json/iso_639-2.json").join(''))
|
||||
rows = iso639_2["639-2"].
|
||||
iso639_2 = JSON.parse(IO.readlines("/usr/share/iso-codes/json/iso_639-2.json").join('')) \
|
||||
["639-2"].
|
||||
reject { |entry| %r{^qaa}.match(entry["alpha_3"]) }.
|
||||
map do |entry|
|
||||
entry["has_639_2"] = true
|
||||
entry["alpha_3_to_use"] = entry["bibliographic"] || entry["alpha_3"]
|
||||
entry
|
||||
end
|
||||
|
||||
used_codes = Hash[ *iso639_2.map { |entry| [ entry["alpha_3"], true, entry["bibliographic"], true ] }.flatten ]
|
||||
|
||||
JSON.parse(IO.readlines("/usr/share/iso-codes/json/iso_639-3.json").join('')) \
|
||||
["639-3"].
|
||||
reject { |entry| entry["type"] != "L" }.
|
||||
reject { |entry| used_codes.include?(entry["alpha_3"]) }.
|
||||
each do |entry|
|
||||
iso639_2 << {
|
||||
"name" => entry["name"],
|
||||
"alpha_3" => entry["alpha_3"],
|
||||
"alpha_3_to_use" => entry["alpha_3"],
|
||||
"has_639_2" => false,
|
||||
}
|
||||
end
|
||||
|
||||
rows = iso639_2.
|
||||
map do |entry|
|
||||
[ entry["name"].to_u8_cpp_string,
|
||||
(entry["bibliographic"] || entry["alpha_3"]).to_cpp_string,
|
||||
entry["alpha_3_to_use"].to_cpp_string,
|
||||
(entry["alpha_2"] || '').to_cpp_string,
|
||||
entry["bibliographic"] ? entry["alpha_3"].to_cpp_string : '""s',
|
||||
'true ',
|
||||
entry["has_639_2"].to_s,
|
||||
]
|
||||
end
|
||||
|
||||
|
@ -46,6 +46,16 @@ language_c::has_valid_iso639_code()
|
||||
return m_valid && !m_language.empty();
|
||||
}
|
||||
|
||||
bool
|
||||
language_c::has_valid_iso639_2_code()
|
||||
const noexcept {
|
||||
if (!m_valid || m_language.empty())
|
||||
return false;
|
||||
|
||||
auto language_opt = mtx::iso639::look_up(get_language());
|
||||
return language_opt && language_opt->is_part_of_iso639_2;
|
||||
}
|
||||
|
||||
std::string const &
|
||||
language_c::get_error()
|
||||
const noexcept {
|
||||
@ -305,8 +315,14 @@ language_c::get_iso639_alpha_3_code()
|
||||
std::string
|
||||
language_c::get_iso639_2_alpha_3_code_or(std::string const &value_if_invalid)
|
||||
const noexcept {
|
||||
auto code = get_iso639_alpha_3_code();
|
||||
return !code.empty() ? code : value_if_invalid;
|
||||
if (!m_valid || m_language.empty())
|
||||
return value_if_invalid;
|
||||
|
||||
auto language = mtx::iso639::look_up(m_language);
|
||||
if (language && language->is_part_of_iso639_2)
|
||||
return language->alpha_3_code;
|
||||
|
||||
return value_if_invalid;
|
||||
}
|
||||
|
||||
language_c &
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
void clear() noexcept;
|
||||
|
||||
bool has_valid_iso639_code() const noexcept;
|
||||
bool has_valid_iso639_2_code() const noexcept;
|
||||
std::string get_iso639_alpha_3_code() const noexcept;
|
||||
std::string get_iso639_2_alpha_3_code_or(std::string const &value_if_invalid) const noexcept;
|
||||
|
||||
|
@ -1212,7 +1212,7 @@ set_languages_in_display(libmatroska::KaxChapterDisplay &display,
|
||||
|
||||
GetChild<libmatroska::KaxChapLanguageIETF>(display).SetValue(parsed_language.format());
|
||||
|
||||
if (parsed_language.has_valid_iso639_code())
|
||||
if (parsed_language.has_valid_iso639_2_code())
|
||||
GetChild<libmatroska::KaxChapterLanguage>(display).SetValue(parsed_language.get_iso639_alpha_3_code());
|
||||
}
|
||||
|
||||
|
@ -40,10 +40,10 @@ std::unordered_map<std::string, std::string> s_deprecated_1_and_2_codes{
|
||||
void
|
||||
list_languages() {
|
||||
mtx::string::table_formatter_c formatter;
|
||||
formatter.set_header({ Y("English language name"), Y("ISO 639-2 code"), Y("ISO 639-1 code") });
|
||||
formatter.set_header({ Y("English language name"), Y("ISO 639-3 code"), Y("ISO 639-2 code"), Y("ISO 639-1 code") });
|
||||
|
||||
for (auto &lang : g_languages)
|
||||
formatter.add_row({ gettext(lang.english_name.c_str()), lang.alpha_3_code, lang.alpha_2_code });
|
||||
formatter.add_row({ gettext(lang.english_name.c_str()), lang.alpha_3_code, lang.is_part_of_iso639_2 ? lang.alpha_3_code : ""s, lang.alpha_2_code });
|
||||
|
||||
mxinfo(formatter.format());
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -284,7 +284,7 @@ set_simple(KaxTag &tag,
|
||||
if (!language.is_valid())
|
||||
return;
|
||||
|
||||
if (language.has_valid_iso639_code())
|
||||
if (language.has_valid_iso639_2_code())
|
||||
GetChild<KaxTagLangue>(k_simple_tag).SetValue(language.get_iso639_alpha_3_code());
|
||||
|
||||
GetChild<KaxTagLanguageIETF>(k_simple_tag).SetValue(language.format());
|
||||
|
@ -158,7 +158,7 @@ ebml_chapters_converter_c::fix_display(KaxChapterDisplay &display)
|
||||
if (clanguage_ietf)
|
||||
clanguage_ietf->SetValue(parsed_language.format());
|
||||
|
||||
if (parsed_language.has_valid_iso639_code()) {
|
||||
if (parsed_language.has_valid_iso639_2_code()) {
|
||||
if (!clanguage) {
|
||||
clanguage = new KaxChapterLanguage;
|
||||
display.PushElement(*clanguage);
|
||||
@ -169,7 +169,7 @@ ebml_chapters_converter_c::fix_display(KaxChapterDisplay &display)
|
||||
} else if (clanguage) {
|
||||
auto language_opt = mtx::iso639::look_up(clanguage->GetValue());
|
||||
|
||||
if (!language_opt)
|
||||
if (!language_opt || !language_opt->is_part_of_iso639_2)
|
||||
throw conversion_x{fmt::format(Y("'{0}' is not a valid ISO 639-2 language code."), clanguage->GetValue())};
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ ebml_tags_converter_c::fix_tag(KaxTag &tag)
|
||||
if (tlanguage_ietf)
|
||||
tlanguage_ietf->SetValue(parsed_language.format());
|
||||
|
||||
if (parsed_language.has_valid_iso639_code()) {
|
||||
if (parsed_language.has_valid_iso639_2_code()) {
|
||||
if (!tlanguage) {
|
||||
tlanguage = new KaxTagLangue;
|
||||
simple->PushElement(*tlanguage);
|
||||
@ -132,7 +132,7 @@ ebml_tags_converter_c::fix_tag(KaxTag &tag)
|
||||
} else if (tlanguage) {
|
||||
auto language_opt = mtx::iso639::look_up(tlanguage->GetValue());
|
||||
|
||||
if (!language_opt)
|
||||
if (!language_opt || !language_opt->is_part_of_iso639_2)
|
||||
throw conversion_x{fmt::format(Y("'{0}' is not a valid ISO 639-2 language code."), tlanguage->GetValue())};
|
||||
}
|
||||
}
|
||||
|
@ -687,7 +687,7 @@ generic_packetizer_c::set_language(mtx::bcp47::language_c const &language) {
|
||||
if (!m_track_entry || !language.is_valid())
|
||||
return;
|
||||
|
||||
if (language.has_valid_iso639_code())
|
||||
if (language.has_valid_iso639_2_code())
|
||||
GetChild<KaxTrackLanguage>(m_track_entry).SetValue(language.get_iso639_alpha_3_code());
|
||||
if (!mtx::bcp47::language_c::is_disabled())
|
||||
GetChild<KaxLanguageIETF>(m_track_entry).SetValue(language.format());
|
||||
@ -1070,7 +1070,7 @@ generic_packetizer_c::set_headers() {
|
||||
else if (g_default_tracks[idx] == m_hserialno)
|
||||
g_default_tracks[idx] = 0;
|
||||
|
||||
auto iso639_alpha_3_code = m_ti.m_language.has_valid_iso639_code() ? m_ti.m_language.get_iso639_alpha_3_code() : g_default_language.get_iso639_alpha_3_code();
|
||||
auto iso639_alpha_3_code = m_ti.m_language.has_valid_iso639_2_code() ? m_ti.m_language.get_iso639_alpha_3_code() : g_default_language.has_valid_iso639_2_code() ? g_default_language.get_iso639_alpha_3_code() : "und"s;
|
||||
auto language = m_ti.m_language.is_valid() ? m_ti.m_language : g_default_language;
|
||||
GetChild<KaxTrackLanguage>(m_track_entry).SetValue(iso639_alpha_3_code);
|
||||
if (!mtx::bcp47::language_c::is_disabled())
|
||||
|
@ -63,9 +63,9 @@ class LanguageDialogPrivate {
|
||||
std::unique_ptr<Ui::LanguageDialog> ui{new Ui::LanguageDialog};
|
||||
QVector<QVector<QWidget *>> componentWidgets;
|
||||
|
||||
QString initialISO639_2Code;
|
||||
QStringList additionalISO639_2Codes;
|
||||
QSet<QString> previousAllAdditionalISO639_2Codes;
|
||||
QString initialISO639Code;
|
||||
QStringList additionalISO639Codes;
|
||||
QSet<QString> previousAllAdditionalISO639Codes;
|
||||
};
|
||||
|
||||
LanguageDialog::LanguageDialog(QWidget *parent)
|
||||
@ -156,21 +156,21 @@ void
|
||||
LanguageDialog::reinitializeLanguageComboBox() {
|
||||
auto &p = *p_func();
|
||||
|
||||
auto additionalItems = p.additionalISO639_2Codes;
|
||||
auto additionalItems = p.additionalISO639Codes;
|
||||
auto tag = mtx::bcp47::language_c::parse(to_utf8(p.ui->leFreeForm->text()));
|
||||
|
||||
if (!p.initialISO639_2Code.isEmpty())
|
||||
additionalItems << p.initialISO639_2Code;
|
||||
if (!p.initialISO639Code.isEmpty())
|
||||
additionalItems << p.initialISO639Code;
|
||||
|
||||
if (tag.is_valid() && tag.has_valid_iso639_code())
|
||||
additionalItems << Q(tag.get_iso639_alpha_3_code());
|
||||
|
||||
auto uniqueItems = qListToSet(additionalItems);
|
||||
|
||||
if (uniqueItems == p.previousAllAdditionalISO639_2Codes)
|
||||
if (uniqueItems == p.previousAllAdditionalISO639Codes)
|
||||
return;
|
||||
|
||||
p.previousAllAdditionalISO639_2Codes = uniqueItems;
|
||||
p.previousAllAdditionalISO639Codes = uniqueItems;
|
||||
|
||||
p.ui->cbLanguage
|
||||
->setAdditionalItems(qSetToList(uniqueItems))
|
||||
@ -181,13 +181,13 @@ void
|
||||
LanguageDialog::setAdditionalLanguages(QStringList const &additionalLanguages) {
|
||||
auto &p = *p_func();
|
||||
|
||||
p.additionalISO639_2Codes.clear();
|
||||
p.additionalISO639Codes.clear();
|
||||
|
||||
for (auto const &language : additionalLanguages) {
|
||||
auto parsedLanguage = mtx::bcp47::language_c::parse(to_utf8(language));
|
||||
|
||||
if (parsedLanguage.is_valid() && parsedLanguage.has_valid_iso639_code())
|
||||
p.additionalISO639_2Codes << Q(parsedLanguage.get_iso639_alpha_3_code());
|
||||
p.additionalISO639Codes << Q(parsedLanguage.get_iso639_alpha_3_code());
|
||||
}
|
||||
|
||||
reinitializeLanguageComboBox();
|
||||
@ -198,7 +198,7 @@ LanguageDialog::setLanguage(mtx::bcp47::language_c const &language) {
|
||||
auto &p = *p_func();
|
||||
|
||||
if (language.is_valid() && language.has_valid_iso639_code()) {
|
||||
p.initialISO639_2Code = Q(language.get_iso639_alpha_3_code());
|
||||
p.initialISO639Code = Q(language.get_iso639_alpha_3_code());
|
||||
reinitializeLanguageComboBox();
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ T_365qtmp4_constant_sample_size:2b19b954e0bddbf2d188d4e61f376be6-f8bbf000f58d3ae
|
||||
T_366srt_with_space_in_timecode_arrow:b1a3af7e800ae1c49617607f098584cd:passed:20120801-132204:0.121731174
|
||||
T_367vob_80ms_delay_by_b_frames:589d619bdd72be348e30667629f7f2df-fd78b3a5bc5e113bbc543c9c2d7cec86:passed:20120801-182507:0.106468603
|
||||
T_368alac:f42e21836e36d062ade14cbf3cd497a4-3dd932c6054ba27922c4525daa311e96-a7bc31e9d45b2c78f92d4ae1ed9064b9-036d95bb14166dfec825591a0a540c8b:passed:20120805-160128:0.596006157
|
||||
T_369mpeg_ts_timecode_overflow:08216e4ce763ed9962eebc0b7029e941:passed:20120807-120810:5.138361997
|
||||
T_369mpeg_ts_timecode_overflow:7dbd1472f390eee08e4917c24dd9127f:passed:20120807-120810:5.138361997
|
||||
T_370propedit_attachments:9f35b4156047c5a63e06cece5bbd10ae-9f35b4156047c5a63e06cece5bbd10ae-0262e5ebae28dee05b92889efa6542d7-9f35b4156047c5a63e06cece5bbd10ae-0262e5ebae28dee05b92889efa6542d7-9f35b4156047c5a63e06cece5bbd10ae-0262e5ebae28dee05b92889efa6542d7-9f35b4156047c5a63e06cece5bbd10ae-43c64ace26ad02d736c40bab7dc8c08d-9f35b4156047c5a63e06cece5bbd10ae-36a31b63064372559efffb2215316b09-9f35b4156047c5a63e06cece5bbd10ae-b11adc5eb2ebdbb72beefc9d29eb065c-9f35b4156047c5a63e06cece5bbd10ae-7c97eba9f18677c436797628bc0b1670-9f35b4156047c5a63e06cece5bbd10ae-33990f5af6c893721382f3fcabd2121a-9f35b4156047c5a63e06cece5bbd10ae-a498ea3442e36f846c55526c7fbd67b9-9f35b4156047c5a63e06cece5bbd10ae-3fe616f18cf7eaa96fb9b91b9966c9a0-9f35b4156047c5a63e06cece5bbd10ae-3fe616f18cf7eaa96fb9b91b9966c9a0-9f35b4156047c5a63e06cece5bbd10ae-166ea7a4daca3bc9b003d5ab0c6971c2-9f35b4156047c5a63e06cece5bbd10ae-861a8ae27bc2c51387052dac4342a773-9f35b4156047c5a63e06cece5bbd10ae-7864e46add08a3b54a5d2792d556a4af-9f35b4156047c5a63e06cece5bbd10ae-7864e46add08a3b54a5d2792d556a4af-9f35b4156047c5a63e06cece5bbd10ae-86ebb22b98ad1efde4e05d556cd1f739-9f35b4156047c5a63e06cece5bbd10ae-5e04060a178fa4266930a1dbc3ccf956-9f35b4156047c5a63e06cece5bbd10ae-4d3ada3b44a7f0903a21ca7ca2af81b9-9f35b4156047c5a63e06cece5bbd10ae-91d5013720b132d2248121801a10e535-9f35b4156047c5a63e06cece5bbd10ae-17d1e1e9ed09f555b6fd4b1ab65519bd-9f35b4156047c5a63e06cece5bbd10ae-7e6c664ce870ea964686aacc4ceb050c-9f35b4156047c5a63e06cece5bbd10ae-0c4c34cc10e87dccbd0dd319123b48eb-9f35b4156047c5a63e06cece5bbd10ae-5758425fddc914c7d2180a21ef2255f0:passed:20120902-110003:0.573238036
|
||||
T_371doc_and_read_version:4+2-4+2-4+2-4+2-4+2-4+1-4+1-4+1:passed:20120927-110447:1.294617251
|
||||
T_372ui_locale_eu_ES:cd0927f0c4248d14b97336097ee36c2e-8ef1b15c1dcfa5a888fab14cdeec0cda:passed:20120930-150340:0.096365772
|
||||
@ -290,7 +290,7 @@ T_441mkvmerge_mp4_big_endian_pcm:e4e904555f909d5e8652a91e8fdf31c1:passed:2014110
|
||||
T_442ui_locale_ca_ES:e799c32fad802af9eb581be621be42e1-efc218c7d73104f27e852a4d6b66412e:passed:20141105-201811:0.070000034
|
||||
T_443hevc_keep_user_data:11bf45554d796d68853e357f169469b6:passed:20141105-202533:1.308417598
|
||||
T_444pcm_statistics_from_packaged_sources:2c94e06d494670d292d39b9da89c2b75-2c94e06d494670d292d39b9da89c2b75-29b472bea47d3f332a2f048fe49d9b8e-29b472bea47d3f332a2f048fe49d9b8e-+++:passed:20141205-220805:0.604375231
|
||||
T_445teletext_subs_missing_second_line:df287750a10ba3e65358f4dbd1385b65:passed:20141210-224823:5.420908642
|
||||
T_445teletext_subs_missing_second_line:99b00375db1a198b3065ee2e7e916d9e:passed:20141210-224823:5.420908642
|
||||
T_446mkvinfo_output:0d3e722b42c84e874de08d652e7bf461-fd71f8de53cd8f56acde1c5831458cfc-03e16fe6fbf7c07c7ad4363a1f89f670-7a01d6443aeb4c2b47f7e5d7e84dec93-a2250dc824941b190f24018d5a46acff-95c2024673fa1dc6522f04e2a250e679-8c946e47abf15c27aeb4eea86eb92c59-131db4e7dbfa080f36bc53c48d2da664-30ac7510ac5bcf6447df352d86862768-b931a048f3844a4527400c1971d540f5-c65f13ddad04fefa09e3c1bdc6b3d863-ac5293a69a3e6b20d968ec58d87df5ae-2c2d1b776762d338bee20e9061da87d3-5bee165f21e6275d31fc9953a4d18b5c-2a8c3fead596f9b92d3265d3a2628117-b6e946c3229627d31f75246559875bcc-775bc7eecc1585bb4f4138a32a8d6dbd-eb9d1a0f16c5f9d6dc895f6edae287a4-b4a1f55ed7340e4a3f0734724333050e-84a0de136c7956183120eabacbcd0917-21795d7ac3bfa3584cd9256751e8d23a-2b223ce13a45cef99354d6fb64a428b6-f1cb0361a5d41e71dd73b4605e3b259f-b4928d1b6883924051bac4bbe8687c4e:passed:20141216-165433:1.564089101
|
||||
T_447mkvinfo_rounded_timecodes:89d88674688a2307b4820ed69b6585c6-3ae00f30fa7122c199c2dbccf3fde84d-4256f941f7636605b3dd6e4e3b1f280f:passed:20141216-172642:1.712081143
|
||||
T_448mpeg_ts_with_hevc:b3e7d64890dfd0a2c510c14786863f1f:passed:20141216-181650:1.133097273
|
||||
@ -357,7 +357,7 @@ T_508splitting_by_parts_with_segment_linking:existence0-true-true-true-existence
|
||||
T_509rerender_track_headers_chapters_attachments:87781ec915fa6907bfb6f2e6f0fe33b4:passed:20151115-230226:0.287840782
|
||||
T_510propedit_add_attachments_without_meta_seek_present:770103c238a0f502c9ec55f0599d8544:passed:20151121-101043:0.070892905
|
||||
T_511propedit_ensure_seek_head_exists_at_front:20f53afd94e39f5bbf3f1091eefbe31d:passed:20151129-194025:0.152563199
|
||||
T_512json_identification:ca389d7ad7ae1cefc1c333dc40e25e12+ok-d6bc41ba31b316b0b8b58200ae3a835a+ok-5a8356fd848b743bf68002660d212f31+ok-02e3092da95838f1b748dc71e452b082+ok-b19b174f01a91e1ceb49fad22ea49c43+ok-7ce51ac3ee42b52793b012595947a26b+ok-f773927e8b1958b281902bfd6af0b2ee+ok-fbc959d0617b3fe7787a0f14f8534103+ok-80f113c2508c846ed87a53cd0d0ec40f+ok-f28b00b14769d78e8cf4a54f17634b12+ok-8882963e9d459221b48c0cc246c880ee+ok-95a078142585dd2f790f2e33d2f3ae03+ok-7e55beb396e9da2b4e7dc40f0feaa9c6+ok-b396e0a31cc986cedccbdfc3e81efc25+ok-63b90823a5846240cb838d2c4c85d9d6+ok-100d3563880ec3050601c14ce8b38ac7+ok-4785ed8330c2f251e91ad987c5355909+ok:passed:20151207-223859:1.325386646
|
||||
T_512json_identification:ca389d7ad7ae1cefc1c333dc40e25e12+ok-d6bc41ba31b316b0b8b58200ae3a835a+ok-5a8356fd848b743bf68002660d212f31+ok-02e3092da95838f1b748dc71e452b082+ok-30e1db3cd174a87829c67c498c57c253+ok-7ce51ac3ee42b52793b012595947a26b+ok-f773927e8b1958b281902bfd6af0b2ee+ok-fbc959d0617b3fe7787a0f14f8534103+ok-80f113c2508c846ed87a53cd0d0ec40f+ok-f28b00b14769d78e8cf4a54f17634b12+ok-8882963e9d459221b48c0cc246c880ee+ok-95a078142585dd2f790f2e33d2f3ae03+ok-7e55beb396e9da2b4e7dc40f0feaa9c6+ok-b396e0a31cc986cedccbdfc3e81efc25+ok-63b90823a5846240cb838d2c4c85d9d6+ok-100d3563880ec3050601c14ce8b38ac7+ok-4785ed8330c2f251e91ad987c5355909+ok:passed:20151207-223859:1.325386646
|
||||
T_513vp9_10bit_key_frame_detection:fbde62ac54dee50c626f97bfa5735b0e:passed:20151208-224613:0.267556245
|
||||
T_514remove_track_statistics_tags_during_remux:246f137d77ea2c2fad2e0a9451e49936-950d8682f4579d7e90a7e30dfb1659f7-2906a498c2e4fb853748979f93151db3:passed:20151215-134129:1.426290351
|
||||
T_515aac_sampling_frequency_8000_is_not_sbr:44627c1712aa5888472e0c1bf0b0502d:passed:20151219-130357:0.066237884
|
||||
|
@ -27,7 +27,7 @@ TEST(BCP47LanguageTags, ParsingValidUNM49) {
|
||||
}
|
||||
|
||||
TEST(BCP47LanguageTags, ParsingInvalid) {
|
||||
EXPECT_FALSE(mtx::bcp47::language_c::parse("muh-Latn-CH-x-weeee").is_valid()); // invalid (muh not ISO 639 code).is_valid())
|
||||
EXPECT_FALSE(mtx::bcp47::language_c::parse("zyx-Latn-CH-x-weeee").is_valid()); // invalid (zyx not ISO 639 code).is_valid())
|
||||
EXPECT_FALSE(mtx::bcp47::language_c::parse("ger-muku-CH-x-weeee").is_valid()); // invalid (muku not a script).is_valid())
|
||||
EXPECT_FALSE(mtx::bcp47::language_c::parse("ger-777").is_valid()); // invalid (777 not a region code).is_valid())
|
||||
EXPECT_FALSE(mtx::bcp47::language_c::parse("zh-min").is_valid()); // invalid (min not allowed with zh).is_valid())
|
||||
@ -96,12 +96,12 @@ TEST(BCP47LanguageTags, CodeConversion) {
|
||||
EXPECT_EQ("ger"s, mtx::bcp47::language_c::parse("ger").get_iso639_alpha_3_code());
|
||||
|
||||
mtx::bcp47::language_c l;
|
||||
l.set_language("muh");
|
||||
l.set_language("zyx");
|
||||
EXPECT_EQ(""s, l.get_iso639_alpha_3_code());
|
||||
|
||||
EXPECT_FALSE(mtx::bcp47::language_c{}.has_valid_iso639_code());
|
||||
EXPECT_FALSE(mtx::bcp47::language_c::parse("muh").has_valid_iso639_code());
|
||||
EXPECT_FALSE(mtx::bcp47::language_c::parse("x-muh").has_valid_iso639_code());
|
||||
EXPECT_FALSE(mtx::bcp47::language_c::parse("zyx").has_valid_iso639_code());
|
||||
EXPECT_FALSE(mtx::bcp47::language_c::parse("x-zyx").has_valid_iso639_code());
|
||||
|
||||
EXPECT_TRUE(mtx::bcp47::language_c::parse("de").has_valid_iso639_code());
|
||||
EXPECT_TRUE(mtx::bcp47::language_c::parse("deu").has_valid_iso639_code());
|
||||
@ -165,4 +165,12 @@ TEST(BCP47LanguageTags, EqualityOperators) {
|
||||
EXPECT_TRUE(mtx::bcp47::language_c::parse("de") != mtx::bcp47::language_c::parse("eng"));
|
||||
}
|
||||
|
||||
TEST(BCP47LanguageTags, DifferenceBetweenISO639_2And639_3) {
|
||||
EXPECT_TRUE(mtx::bcp47::language_c::parse("de").has_valid_iso639_code());
|
||||
EXPECT_TRUE(mtx::bcp47::language_c::parse("de").has_valid_iso639_2_code());
|
||||
|
||||
EXPECT_TRUE(mtx::bcp47::language_c::parse("cmn").has_valid_iso639_code());
|
||||
EXPECT_FALSE(mtx::bcp47::language_c::parse("cmn").has_valid_iso639_2_code());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user