Skip to content

Commit 9a5ea3a

Browse files
committed
Update to unic-locale 0.7
1 parent fcde6d0 commit 9a5ea3a

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ coveralls = { repository = "projectfluent/fluent-locale-rs", branch = "master",
1919
maintenance = { status = "actively-developed" }
2020

2121
[dependencies]
22-
unic-langid = "0.6"
22+
unic-langid = "0.7"
2323

2424
[dev-dependencies]
2525
serde = { version = "1.0", features = ["derive"] }
2626
serde_json = "1.0"
27-
unic-langid = { version = "0.6", features = ["macros"] }
28-
unic-locale = { version = "0.6", features = ["macros"] }
27+
unic-langid = { version = "0.7", features = ["macros"] }
28+
unic-locale = { version = "0.7", features = ["macros"] }
2929
criterion = "0.3"
3030

3131
[[bench]]

src/negotiate/likely_subtags.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,25 @@ impl MockLikelySubtags for LanguageIdentifier {
2323

2424
for subtag in REGION_MATCHING_KEYS {
2525
if lang == *subtag {
26-
self.set_region(Some(subtag)).unwrap();
26+
self.set_region(subtag).unwrap();
2727
return true;
2828
}
2929
}
3030
return false;
3131
}
3232
};
3333
let langid: LanguageIdentifier = extended.parse().expect("Failed to parse langid.");
34-
self.set_language(Some(langid.get_language())).unwrap();
35-
self.set_script(langid.get_script()).unwrap();
36-
self.set_region(langid.get_region()).unwrap();
34+
self.set_language(langid.get_language()).unwrap();
35+
if let Some(subtag) = langid.get_script() {
36+
self.set_script(subtag).unwrap();
37+
} else {
38+
self.clear_script();
39+
}
40+
if let Some(subtag) = langid.get_region() {
41+
self.set_region(subtag).unwrap();
42+
} else {
43+
self.clear_region();
44+
}
3745
return true;
3846
}
3947
}

src/negotiate/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ pub fn filter_matches<'a, R: 'a + AsRef<LanguageIdentifier>, A: 'a + AsRef<Langu
230230
};
231231

232232
// 4) Try to match against a variant as a range
233-
req.set_variants(&[]).unwrap();
233+
req.clear_variants();
234234
av_map.retain(|key, value| {
235235
if strategy != NegotiationStrategy::Filtering && match_found {
236236
return true;
@@ -255,7 +255,7 @@ pub fn filter_matches<'a, R: 'a + AsRef<LanguageIdentifier>, A: 'a + AsRef<Langu
255255
match_found = false;
256256

257257
// 5) Try to match against the likely subtag without region
258-
req.set_region(None).unwrap();
258+
req.clear_region();
259259
if req.add_likely_subtags() {
260260
av_map.retain(|key, value| {
261261
if strategy != NegotiationStrategy::Filtering && match_found {
@@ -282,7 +282,7 @@ pub fn filter_matches<'a, R: 'a + AsRef<LanguageIdentifier>, A: 'a + AsRef<Langu
282282
}
283283

284284
// 6) Try to match against a region as a range
285-
req.set_region(None).unwrap();
285+
req.clear_region();
286286
av_map.retain(|key, value| {
287287
if strategy != NegotiationStrategy::Filtering && match_found {
288288
return true;

0 commit comments

Comments
 (0)