Skip to content

Commit 1fcd24f

Browse files
committed
rust/language.rs: add full BCP 47 compliant pipeline
- Removes custom, incomplete language mapping tables - Adds validation for the BCP 47-defined format - Compares all components separately instead of treating them as the same entity - Adds canonicalization support for ISO 639-{1,2t,2b,3} It is not overly strict in validation to preserve compatibility with "custom" tags. If the language can be parsed and normalized, this will be used; otherwise, it falls back to direct string comparison. For BCP 47 components, all mismatches are penalized equally, with 1000 points deducted per mismatch. This value can be adjusted if needed. This commit should greatly improve support for matching language tags consisting of more than just the primary language and region.
1 parent c2a73f1 commit 1fcd24f

21 files changed

+498
-386
lines changed

.pre-commit-config.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ repos:
1919
hooks:
2020
- id: codespell
2121
args: ["--ignore-words-list", "datas,DNE,enew,HDA,numer,ontop,optionA,Paeth,pathc,inout"]
22-
exclude: ^misc/language.c$

meson.build

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ project('mpv',
1111
'cpp_std=c++20',
1212
'cpp_eh=default',
1313
'warning_level=2',
14+
'rust_std=2021',
15+
'build.rust_std=2021',
1416
]
1517
)
1618

@@ -140,7 +142,6 @@ sources = files(
140142
'misc/dispatch.c',
141143
'misc/io_utils.c',
142144
'misc/json.c',
143-
'misc/language.c',
144145
'misc/natural_sort.c',
145146
'misc/node.c',
146147
'misc/path_utils.c',
@@ -1764,6 +1765,8 @@ major = client_h_define.split('|')[0].split('<<')[0].strip('() ')
17641765
minor = client_h_define.split('|')[1].strip('() ')
17651766
client_api_version = major + '.' + minor + '.0'
17661767

1768+
subdir('rust')
1769+
17671770
libmpv = library('mpv', sources, dependencies: dependencies, gnu_symbol_visibility: 'hidden',
17681771
include_directories: incdir_public,
17691772
link_args: cc.get_supported_link_arguments(['-Wl,-Bsymbolic']),

0 commit comments

Comments
 (0)