Skip to content

Commit 664a0a7

Browse files
committed
Use unic-langid 0.4
1 parent b69ef7d commit 664a0a7

File tree

10 files changed

+30
-28
lines changed

10 files changed

+30
-28
lines changed

fluent-bundle/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ fluent-locale = { git = "https://github.com/projectfluent/fluent-locale-rs", bra
2222
fluent-syntax = "0.9"
2323
failure = "0.1"
2424
failure_derive = "0.1"
25-
intl_pluralrules = { git = "https://github.com/zbraniecki/pluralrules", branch = "master" }
25+
intl_pluralrules = "2.0"
2626
rental = "0.5.4"
2727
smallvec = "0.6.10"
28-
unic-langid = { git = "https://github.com/zbraniecki/unic-locale", branch = "master" }
28+
unic-langid = { version = "0.4", features = ["macros"] }
29+
unic-langid-impl = "0.4"
2930

3031
[dev-dependencies]
3132
criterion = "0.2"

fluent-bundle/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ Usage
2323

2424
```rust
2525
use fluent_bundle::{FluentBundle, FluentResource};
26-
use unic_langid::LanguageIdentifier;
26+
use unic_langid::langid;
2727

2828
fn main() {
2929
let ftl_string = "hello-world = Hello, world!".to_owned();
3030
let res = FluentResource::try_new(ftl_string)
3131
.expect("Could not parse an FTL string.");
3232

33-
let langid_en = "en".parse().expect("Parsing failed.");
33+
let langid_en = langid!("en");
3434
let mut bundle = FluentBundle::new(&[langid_en]);
3535

3636
bundle.add_resource(&res)

fluent-bundle/examples/external_arguments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use fluent_bundle::{FluentBundle, FluentResource, FluentValue};
22
use std::collections::HashMap;
3-
use unic_langid::LanguageIdentifier;
3+
use unic_langid::langid;
44

55
fn main() {
66
let ftl_string = String::from(
@@ -15,7 +15,7 @@ unread-emails =
1515
",
1616
);
1717
let res = FluentResource::try_new(ftl_string).expect("Could not parse an FTL string.");
18-
let langid_en: LanguageIdentifier = "en".parse().expect("Parsing failed.");
18+
let langid_en = langid!("en");
1919
let mut bundle = FluentBundle::new(&[langid_en]);
2020
bundle
2121
.add_resource(res)

fluent-bundle/examples/functions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use fluent_bundle::{FluentBundle, FluentResource, FluentValue};
2-
use unic_langid::LanguageIdentifier;
2+
use unic_langid::langid;
33

44
fn main() {
55
// We define the resources here so that they outlive
@@ -11,7 +11,7 @@ fn main() {
1111
let res2 = FluentResource::try_new(ftl_string2).expect("Could not parse an FTL string.");
1212
let res3 = FluentResource::try_new(ftl_string3).expect("Could not parse an FTL string.");
1313

14-
let langid_en_us: LanguageIdentifier = "en-US".parse().expect("Parsing failed.");
14+
let langid_en_us = langid!("en-US");
1515
let mut bundle = FluentBundle::new(&[langid_en_us]);
1616

1717
// Test for a simple function that returns a string

fluent-bundle/examples/simple-app.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use std::fs::File;
2626
use std::io;
2727
use std::io::prelude::*;
2828
use std::str::FromStr;
29-
use unic_langid::LanguageIdentifier;
29+
use unic_langid::{langid, LanguageIdentifier};
3030

3131
/// We need a generic file read helper function to
3232
/// read the localization resource file.
@@ -82,7 +82,7 @@ fn main() {
8282
});
8383

8484
// 4. Negotiate it against the available ones
85-
let default_locale: LanguageIdentifier = "en-US".parse().expect("Parsing failed.");
85+
let default_locale = langid!("en-US");
8686
let available = get_available_locales().expect("Retrieving available locales failed.");
8787
let resolved_locales = negotiate_languages(
8888
&requested,

fluent-bundle/src/bundle.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use fluent_locale::{negotiate_languages, NegotiationStrategy};
1313
use fluent_syntax::ast;
1414
use intl_pluralrules::{IntlPluralRules, PluralRuleType};
1515
use unic_langid::LanguageIdentifier;
16+
use unic_langid::langid;
1617

1718
use crate::entry::Entry;
1819
use crate::entry::GetEntry;
@@ -35,13 +36,13 @@ pub struct FluentMessage<'m> {
3536
/// ```
3637
/// use fluent_bundle::{FluentBundle, FluentResource, FluentValue};
3738
/// use std::collections::HashMap;
38-
/// use unic_langid::LanguageIdentifier;
39+
/// use unic_langid::langid;
3940
///
4041
/// let ftl_string = String::from("intro = Welcome, { $name }.");
4142
/// let resource = FluentResource::try_new(ftl_string)
4243
/// .expect("Could not parse an FTL string.");
4344
///
44-
/// let langid_en: LanguageIdentifier = "en-US".parse().expect("Parsing failed.");
45+
/// let langid_en = langid!("en-US");
4546
/// let mut bundle = FluentBundle::new(&[langid_en]);
4647
/// bundle.add_resource(&resource)
4748
/// .expect("Failed to add FTL resources to the bundle.");
@@ -107,9 +108,9 @@ impl<R> FluentBundle<R> {
107108
/// ```
108109
/// use fluent_bundle::FluentBundle;
109110
/// use fluent_bundle::FluentResource;
110-
/// use unic_langid::LanguageIdentifier;
111+
/// use unic_langid::langid;
111112
///
112-
/// let langid_en: LanguageIdentifier = "en-US".parse().expect("Parsing failed.");
113+
/// let langid_en = langid!("en-US");
113114
/// let mut bundle: FluentBundle<FluentResource> = FluentBundle::new(&[langid_en]);
114115
/// ```
115116
///
@@ -123,7 +124,7 @@ impl<R> FluentBundle<R> {
123124
.into_iter()
124125
.map(|s| s.clone().into())
125126
.collect::<Vec<_>>();
126-
let default_langid = "en".parse().expect("Parsing failed.");
127+
let default_langid = langid!("en");
127128
let pr_locale = negotiate_languages(
128129
&locales,
129130
&IntlPluralRules::get_locales(PluralRuleType::CARDINAL),
@@ -158,15 +159,15 @@ impl<R> FluentBundle<R> {
158159
///
159160
/// ```
160161
/// use fluent_bundle::{FluentBundle, FluentResource};
161-
/// use unic_langid::LanguageIdentifier;
162+
/// use unic_langid::langid;
162163
///
163164
/// let ftl_string = String::from("
164165
/// hello = Hi!
165166
/// goodbye = Bye!
166167
/// ");
167168
/// let resource = FluentResource::try_new(ftl_string)
168169
/// .expect("Could not parse an FTL string.");
169-
/// let langid_en: LanguageIdentifier = "en-US".parse().expect("Parsing failed.");
170+
/// let langid_en = langid!("en-US");
170171
/// let mut bundle = FluentBundle::new(&[langid_en]);
171172
/// bundle.add_resource(resource)
172173
/// .expect("Failed to add FTL resources to the bundle.");
@@ -241,12 +242,12 @@ impl<R> FluentBundle<R> {
241242
///
242243
/// ```
243244
/// use fluent_bundle::{FluentBundle, FluentResource};
244-
/// use unic_langid::LanguageIdentifier;
245+
/// use unic_langid::langid;
245246
///
246247
/// let ftl_string = String::from("hello = Hi!");
247248
/// let resource = FluentResource::try_new(ftl_string)
248249
/// .expect("Failed to parse an FTL string.");
249-
/// let langid_en: LanguageIdentifier = "en-US".parse().expect("Parsing failed.");
250+
/// let langid_en = langid!("en-US");
250251
/// let mut bundle = FluentBundle::new(&[langid_en]);
251252
/// bundle.add_resource(&resource)
252253
/// .expect("Failed to add FTL resources to the bundle.");
@@ -308,12 +309,12 @@ impl<R> FluentBundle<R> {
308309
///
309310
/// ```
310311
/// use fluent_bundle::{FluentBundle, FluentResource, FluentValue};
311-
/// use unic_langid::LanguageIdentifier;
312+
/// use unic_langid::langid;
312313
///
313314
/// let ftl_string = String::from("length = { STRLEN(\"12345\") }");
314315
/// let resource = FluentResource::try_new(ftl_string)
315316
/// .expect("Could not parse an FTL string.");
316-
/// let langid_en: LanguageIdentifier = "en-US".parse().expect("Parsing failed.");
317+
/// let langid_en = langid!("en-US");
317318
/// let mut bundle = FluentBundle::new(&[langid_en]);
318319
/// bundle.add_resource(&resource)
319320
/// .expect("Failed to add FTL resources to the bundle.");
@@ -353,7 +354,7 @@ impl<R> FluentBundle<R> {
353354

354355
impl<R> Default for FluentBundle<R> {
355356
fn default() -> Self {
356-
let pr_langid: LanguageIdentifier = "en".parse().expect("Parsing failed.");
357+
let pr_langid = langid!("en");
357358
let langid = LanguageIdentifier::default();
358359

359360
let pr = IntlPluralRules::create(pr_langid, PluralRuleType::CARDINAL)

fluent-bundle/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! ```
1414
//! use fluent_bundle::{FluentBundle, FluentValue, FluentResource};
1515
//! use std::collections::HashMap;
16-
//! use unic_langid::LanguageIdentifier;
16+
//! use unic_langid::langid;
1717
//!
1818
//! let ftl_string = String::from("
1919
//! hello-world = Hello, world!
@@ -22,7 +22,7 @@
2222
//! let res = FluentResource::try_new(ftl_string)
2323
//! .expect("Could not parse an FTL string.");
2424
//!
25-
//! let langid_en: LanguageIdentifier = "en-US".parse().expect("Parsing failed.");
25+
//! let langid_en = langid!("en-US");
2626
//! let mut bundle = FluentBundle::new(&[langid_en]);
2727
//!
2828
//! bundle

fluent-bundle/tests/types_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use fluent_bundle::resolve::Scope;
22
use fluent_bundle::types::FluentValue;
33
use fluent_bundle::FluentBundle;
44
use fluent_bundle::FluentResource;
5-
use unic_langid::LanguageIdentifier;
5+
use unic_langid::langid;
66

77
#[test]
88
fn fluent_value_number() {
@@ -14,7 +14,7 @@ fn fluent_value_number() {
1414
fn fluent_value_matches() {
1515
// We'll use `ars` locale since it happens to have all
1616
// plural rules categories.
17-
let langid_ars: LanguageIdentifier = "ars".parse().expect("Parsing failed.");
17+
let langid_ars = langid!("ars");
1818
let bundle: FluentBundle<FluentResource> = FluentBundle::new(&[langid_ars]);
1919
let scope = Scope::new(&bundle, None);
2020

fluent-fallback/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ reiterate = "0.1.3"
2424

2525
[dev-dependencies]
2626
elsa = "1.3.2"
27-
unic-langid = { git = "https://github.com/zbraniecki/unic-locale", branch = "master" }
27+
unic-langid = "0.4"

fluent-resmgr/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ categories = ["localization", "internationalization"]
1919
[dependencies]
2020
fluent-bundle = { path = "../fluent-bundle" }
2121
fluent-locale = { git = "https://github.com/projectfluent/fluent-locale-rs", branch = "master" }
22-
unic-langid = { git = "https://github.com/zbraniecki/unic-locale", branch = "master" }
22+
unic-langid = "0.4"
2323
fluent-fallback = { path = "../fluent-fallback" }
2424
elsa = "1.3.2"

0 commit comments

Comments
 (0)