Skip to content

Commit 8b4efcf

Browse files
author
Zibi Braniecki
committed
Switch to use unic-locale
1 parent 7c3e2ad commit 8b4efcf

File tree

13 files changed

+47
-628
lines changed

13 files changed

+47
-628
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ license = "Apache-2.0"
1010
repository = "https://github.com/projectfluent/fluent-locale-rs"
1111
readme = "README.md"
1212
categories = ["internationalization", "localization"]
13+
edition = "2018"
1314

1415
[badges]
1516
travis-ci = { repository = "projectfluent/fluent-locale-rs" }
@@ -18,6 +19,7 @@ coveralls = { repository = "projectfluent/fluent-locale-rs", branch = "master",
1819
maintenance = { status = "actively-developed" }
1920

2021
[dependencies]
22+
unic-locale = { path = "../unic-locale" }
2123

2224
[dev-dependencies]
2325
serde = "1.0"

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Introduction
1111

1212
This is a Rust implementation of fluent-locale library which is a part of Project Fluent.
1313

14-
The library allows for parsing language tags into `Locale` objects, operating on them
15-
and serializing the result back to language tag strings.
14+
The library allows for parsing of unicode locale identifiers into `Locale` objects, operating on them
15+
and serializing the result back to locale identifier strings.
1616

1717
On top of that, it allows for simple operations like comparing `Locale` objects and
1818
negotiating between lists of language tags.
@@ -67,11 +67,17 @@ add more tests and ensure that bad input is correctly handled.
6767
Compatibility
6868
-------------
6969

70-
The API is based on [BCP47][] definition of Language Tags and is aiming to
71-
parse and serialize all language tags according to that definition.
70+
The API is based on [UTS 35][] definition of [Unicode Locale Identifier][] and is aiming to
71+
parse and serialize all locale identifiers according to that definition.
7272

73-
Parsed language tags are stored as `Locale` objects compatible with
74-
ECMA402's [Intl.Locale][] and allow for operations on language tag subtags and
73+
*Note*: Unicode Locale Identifier is similar, but different, from what [BCP47][] specifies under
74+
the name Language Tag.
75+
For most locale management and negotiation needs, the Unicode Locale Identifier used in this crate is likely a better choice,
76+
but in some case, like HTTP Accepted Headers, you may need the complete BCP47 Language Tag implementation which
77+
this crate does not provide.
78+
79+
Parsed locale identifiers are stored as `Locale` objects compatible with
80+
ECMA402's [Intl.Locale][] and allow for operations on locale identifier subtags and
7581
unicode extension keys as defined by [RFC6067][] and Unicode [UTS35][]
7682

7783
Language negotiation algorithms are custom Project Fluent solutions,
@@ -84,7 +90,7 @@ API access to them when operating on the `Locale` object.
8490
The language negotiation strategies aim to replicate the best-effort matches with
8591
the most limited amount of data. The algorithm returns reasonable
8692
results without any database, but the results can be improved with either limited
87-
or full [CLDR likely-subtags] database.
93+
or full [CLDR likely-subtags][] database.
8894

8995
The result is a balance chosen for Project Fluent and may differ from other
9096
implementations of language negotiation algorithms which may choose different

benches/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ extern crate fluent_locale;
44
extern crate test;
55

66
use fluent_locale::negotiate_languages;
7-
use fluent_locale::Locale;
7+
use unic_locale::Locale;
88
use test::Bencher;
99

1010
#[bench]
@@ -16,7 +16,7 @@ fn bench_locale(b: &mut Bencher) {
1616

1717
b.iter(|| {
1818
for locale in &locales {
19-
let _ = Locale::new(*locale, None);
19+
let _ = Locale::from_str(*locale);
2020
}
2121
});
2222
}

examples/locale.rs

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
//! language tags and for language negotiation.
1717
1818
pub mod accepted_languages;
19-
pub mod locale;
2019
pub mod negotiate;
2120

2221
pub use accepted_languages::parse as parse_accepted_languages;
23-
pub use locale::Locale;
2422
pub use negotiate::negotiate_languages;
2523
pub use negotiate::NegotiationStrategy;

0 commit comments

Comments
 (0)