[librsvg: 1/4] Update language-tags
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/4] Update language-tags
- Date: Mon, 26 Apr 2021 22:18:12 +0000 (UTC)
commit bfd765e0030f18dc545b2fd589c00498b512239d
Author: Bastien Orivel <eijebong bananium fr>
Date: Wed Apr 21 19:15:18 2021 +0200
Update language-tags
The only code change here is that we have to trim the language string
we're passing to it because they stopped accepting string starting with
a whitespace.
Cargo.lock | 4 ++--
Cargo.toml | 2 +-
src/cond.rs | 41 ++++++++++++++++++++++-------------------
3 files changed, 25 insertions(+), 22 deletions(-)
---
diff --git a/Cargo.lock b/Cargo.lock
index 89297db5..13aaab43 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -881,9 +881,9 @@ dependencies = [
[[package]]
name = "language-tags"
-version = "0.2.2"
+version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a"
+checksum = "f11dc871dd28acc3ac816c5bbe2c5c7e60c4a41f82ce79699a0a44a8fdbc2c7c"
[[package]]
name = "lazy_static"
diff --git a/Cargo.toml b/Cargo.toml
index 344fb957..719f21fb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -52,7 +52,7 @@ glib = "0.10.3"
glib-sys = { version="0.10.1", features=["v2_50"] }
gobject-sys = "0.10.0"
itertools = "0.9.0"
-language-tags = "0.2.2"
+language-tags = "0.3.1"
libc = "0.2"
locale_config = "*" # recommended explicitly by locale_config's README.md
markup5ever = "0.10"
diff --git a/src/cond.rs b/src/cond.rs
index f3edcc2c..b29039a3 100644
--- a/src/cond.rs
+++ b/src/cond.rs
@@ -86,26 +86,29 @@ impl SystemLanguage {
/// [`systemLanguage`]:
https://www.w3.org/TR/SVG/struct.html#ConditionalProcessingSystemLanguageAttribute
/// [BCP47]: http://www.ietf.org/rfc/bcp/bcp47.txt
pub fn from_attribute(s: &str, locale: &Locale) -> Result<SystemLanguage, ValueErrorKind> {
- s.split(',').map(LanguageTag::from_str).try_fold(
- // start with no match
- SystemLanguage(false),
- // The accumulator is Result<SystemLanguage, ValueErrorKind>
- |acc, tag_result| match tag_result {
- Ok(language_tag) => {
- let have_match = acc.0;
- if have_match {
- Ok(SystemLanguage(have_match))
- } else {
- locale_accepts_language_tag(locale, &language_tag).map(SystemLanguage)
+ s.split(',')
+ .map(str::trim)
+ .map(LanguageTag::from_str)
+ .try_fold(
+ // start with no match
+ SystemLanguage(false),
+ // The accumulator is Result<SystemLanguage, ValueErrorKind>
+ |acc, tag_result| match tag_result {
+ Ok(language_tag) => {
+ let have_match = acc.0;
+ if have_match {
+ Ok(SystemLanguage(have_match))
+ } else {
+ locale_accepts_language_tag(locale, &language_tag).map(SystemLanguage)
+ }
}
- }
-
- Err(e) => Err(ValueErrorKind::parse_error(&format!(
- "invalid language tag: \"{}\"",
- e
- ))),
- },
- )
+
+ Err(e) => Err(ValueErrorKind::parse_error(&format!(
+ "invalid language tag: \"{}\"",
+ e
+ ))),
+ },
+ )
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]