mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-25 12:27:21 +00:00
3a0af2592f
There are several languages that aren't part of ISO 639-2 but are part of the 639-3 or 639-5. For those languages the legacy Matroska language elements cannot be set to the ISO 639 alpha 3 code of the BCP 47 language tag. However, there are a lot of such languages whose ISO 639 alpha 3 code is a valid extlang subtag of a BCP 47 tag. For example: the language "Yue Chinese" has an ISO 639 alpha 3 code of `yue` but isn't part of ISO 639-2. However, `yue` is also a valid extlang. As each extlang must have a prefix for which it is valid (in the case of `yue` it's `zh`) and as that prefix must in turn be an ISO 639 code itself, that prefix language's ISO 639-2 code is the closest representation. Part of the implementation of #3307.
44 lines
1.5 KiB
Ruby
Executable File
44 lines
1.5 KiB
Ruby
Executable File
#!/usr/bin/ruby -w
|
|
|
|
# T_734legacy_language_code_fallback_via_extlang_prefix
|
|
describe "mkvmerge, mkvpropedit / legacy language codes derived via falling back on extlang prefix"
|
|
|
|
test_merge "data/avi/v.avi", :args => "--language 0:bfi --language 1:yue", :keep_tmp => true
|
|
test "tracks actual language codes" do
|
|
languages = identify_json(tmp)["tracks"].map { |track| track["properties"]["language"] }
|
|
fail "unexpected legacy language codes" if languages != ["sgn", "chi"]
|
|
languages.join('+')
|
|
end
|
|
|
|
test_merge "data/avi/v.avi", :args => "--chapter-language yue --generate-chapters interval:10s", :keep_tmp => true
|
|
test "chapters actual language codes 1" do
|
|
language = extract(tmp, :mode => :chapters).
|
|
join('').
|
|
gsub(%r{[\r\n]+}, '').
|
|
gsub(%r{.*<ChapterLanguage>}, '').
|
|
gsub(%r{<.*}, '')
|
|
|
|
fail "unexpected legacy language code" if language != "chi"
|
|
"chi"
|
|
end
|
|
|
|
test_merge "data/avi/v.avi", :args => "--chapters data/chapters/chapters-yue.xml", :keep_tmp => true
|
|
test "chapters actual language codes 2" do
|
|
language = extract(tmp, :mode => :chapters).
|
|
join('').
|
|
gsub(%r{[\r\n]+}, '').
|
|
gsub(%r{.*<ChapterLanguage>}, '').
|
|
gsub(%r{<.*}, '')
|
|
|
|
fail "unexpected legacy language code" if language != "chi"
|
|
"chi"
|
|
end
|
|
|
|
test_merge "data/avi/v.avi", :keep_tmp => true
|
|
test "propedit actual language code" do
|
|
propedit tmp, "--edit track:1 --set language=yue"
|
|
languages = identify_json(tmp)["tracks"].map { |track| track["properties"]["language"] }
|
|
fail "unexpected legacy language codes" if languages != ["chi", "und"]
|
|
languages.join('+')
|
|
end
|