Skip to content

Commit d670986

Browse files
committed
fix: Fallback to language portion of locale if locale region not found
1 parent 84e82e3 commit d670986

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "freedesktop-desktop-entry"
3-
version = "0.3.2"
3+
version = "0.3.3"
44
authors = ["Michael Aaron Murphy <[email protected]>"]
55
edition = "2018"
66
homepage = "https://codeberg.org/mmstick/freedesktop-desktop-entry"

src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,16 @@ impl<'a> DesktopEntry<'a> {
180180
) -> Option<&'a str> {
181181
group.and_then(|group| group.get(key)).and_then(|key| {
182182
locale
183-
.and_then(|locale| key.1.get(locale).cloned())
183+
.and_then(|locale| match key.1.get(locale) {
184+
Some(value) => Some(*value),
185+
None => {
186+
if let Some(pos) = locale.find('_') {
187+
key.1.get(&locale[..pos]).cloned()
188+
} else {
189+
None
190+
}
191+
}
192+
})
184193
.or(Some(key.0))
185194
})
186195
}

0 commit comments

Comments
 (0)