You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constLOCALE:Locale=locale!("ja"); // let's try some other language
117
117
@@ -157,7 +157,7 @@ The way `ICU4X` handles data is one of its novelties, aimed at making the data m
157
157
158
158
`ICU4X` by default contains data for a a wide range of CLDR locales[^1], meaning that for most languages, the constructors can be considered infallible and you can `expect` or `unwrap` them, as we did above.
159
159
160
-
However, shipping the library with all locales will have a size impact on your binary. It also requires you to update your binary whenever CLDR data changes, which happens twice a year. To learn how to solve these problems, see our [data management](/2_0_beta/tutorials/data-management) tutorial.
160
+
However, shipping the library with all locales will have a size impact on your binary. It also requires you to update your binary whenever CLDR data changes, which happens twice a year. To learn how to solve these problems, see our [data management](/2_0/tutorials/data-management) tutorial.
161
161
162
162
[^1]: All locales with coverage level `basic`, `moderate`, or `modern` in [`CLDR`](https://github.com/unicode-org/cldr-json/blob/main/cldr-json/cldr-core/coverageLevels.json)
163
163
@@ -167,7 +167,7 @@ This concludes this introduction tutorial. With the help of `DateTimeFormat`, `L
167
167
168
168
Internationalization is a broad domain and there are many more components in `ICU4X`.
169
169
170
-
Next, learn how to [generate optimized data for your binary](/2_0_beta/tutorials/data-management), [configure your Cargo.toml file](/2_0_beta/tutorials/cargo), or continue exploring by reading [the docs](https://docs.rs/icu/2.0.0-beta2/).
170
+
Next, learn how to [generate optimized data for your binary](/2_0/tutorials/data-management), [configure your Cargo.toml file](/2_0/tutorials/cargo), or continue exploring by reading [the docs](https://docs.rs/icu/2.0.0/).
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/main/tutorials/./crates/custom_compiled)
32
+
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/release%2F2.0/tutorials/./crates/custom_compiled)
33
33
34
34
## Cargo.toml with experimental modules
35
35
36
36
Experimental modules are published in a separate `icu_experimental` crate:
37
37
38
38
```toml
39
39
[dependencies]
40
-
icu = { version = "2.0.0-dev", features = ["experimental"] }
40
+
icu = { version = "2.0.0", features = ["experimental"] }
41
41
```
42
42
43
43
In your main.rs, you can now use e.g. the `icu_experimental::displaynames` module.
44
44
45
-
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/main/tutorials/./crates/experimental)
45
+
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/release%2F2.0/tutorials/./crates/experimental)
46
46
47
47
## Cargo.toml with Buffer Provider
48
48
49
49
If you wish to generate your own data in blob format and pass it into ICU4X, enable the "serde" Cargo feature as follows:
50
50
51
51
```toml
52
52
[dependencies]
53
-
icu = { version = "2.0.0-dev", features = ["serde"] }
54
-
icu_provider_blob = {version = "2.0.0-dev", features = ["alloc"] }
53
+
icu = { version = "2.0.0", features = ["serde"] }
54
+
icu_provider_blob = {version = "2.0.0", features = ["alloc"] }
55
55
```
56
56
57
-
To learn about building ICU4X data, including whether to check in the data blob file to your repository, see [data-management.md](/2_0_beta/tutorials/data-management).
57
+
To learn about building ICU4X data, including whether to check in the data blob file to your repository, see [data-management.md](/2_0/tutorials/data-management).
58
58
59
-
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/main/tutorials/./crates/buffer)
59
+
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/release%2F2.0/tutorials/./crates/buffer)
60
60
61
61
## Cargo.toml with `Sync`
62
62
63
63
If you wish to share ICU4X objects between threads, you must enable the `"sync"` Cargo feature:
64
64
65
65
```toml
66
66
[dependencies]
67
-
icu = { version = "2.0.0-dev", features = ["sync"] }
67
+
icu = { version = "2.0.0", features = ["sync"] }
68
68
```
69
69
70
70
You can now use most ICU4X types when `Send + Sync` are required, such as when sharing across threads.
71
71
72
-
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/main/tutorials/./crates/sync)
72
+
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/release%2F2.0/tutorials/./crates/sync)
73
73
74
74
## Cargo.toml with `build.rs` data generation
75
75
76
76
If you wish to use data generation in a `build.rs` script, you need to manually include the data and any dependencies (the `ICU4X_DATA_DIR` variable won't work as ICU4X cannot access your build script output).
77
77
78
78
```toml
79
79
[dependencies]
80
-
icu = { version = "2.0.0-dev", default-features = false } # turn off compiled_data
81
-
icu_provider = "2.0.0-dev"# for databake
82
-
icu_provider_baked = "2.0.0-dev"# for databake
80
+
icu = { version = "2.0.0", default-features = false } # turn off compiled_data
81
+
icu_provider = "2.0.0"# for databake
82
+
icu_provider_baked = "2.0.0"# for databake
83
83
zerovec = "0.9"# for databake
84
84
85
85
# for build.rs:
86
86
[build-dependencies]
87
-
icu = "2.0.0-dev"
88
-
icu_provider_export = "2.0.0-dev"
89
-
icu_provider_source = "2.0.0-dev"
87
+
icu = "2.0.0"
88
+
icu_provider_export = "2.0.0"
89
+
icu_provider_source = "2.0.0"
90
90
```
91
91
92
92
This example has an additional section for auto-generating the data in build.rs. In your build.rs, invoke the ICU4X Datagen API with the set of markers you require. Don't worry; if using databake, you will get a compiler error if you don't specify enough markers.
93
93
94
94
The build.rs approach has several downsides and should only be used if Cargo is the only build system you can use, and you cannot check in your data:
95
95
* The build script with the whole of `icu_provider_source` in it is slow to build
96
96
* If you're using networking features of `icu_provider_source` (behind the `networking` Cargo feature), the build script will access the network
97
-
* Using the data requires ICU4X's [`_unstable`](https://docs.rs/icu_provider/2.0.0-beta2/icu_provider/constructors/index.html) APIs with a custom data provider, and that `icu_provider_source` is the same *minor* version as the `icu` crate.
97
+
* Using the data requires ICU4X's [`_unstable`](https://docs.rs/icu_provider/2.0.0/icu_provider/constructors/index.html) APIs with a custom data provider, and that `icu_provider_source` is the same *minor* version as the `icu` crate.
98
98
*`build.rs` output is not written to the console so it will appear that the build is hanging
99
99
100
-
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/main/tutorials/./crates/baked)
100
+
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/release%2F2.0/tutorials/./crates/baked)
Copy file name to clipboardExpand all lines: src/content/docs/2_0/tutorials/data-management.md
+12-8Lines changed: 12 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ If you're happy shipping your app with the recommended set of locales included i
10
10
11
11
## 1. Prerequisites
12
12
13
-
This tutorial assumes you have finished the [introductory tutorial](/2_0_beta/quickstart) and continues where that tutorial left off. In particular, you should still have the latest version of code for `myapp`.
13
+
This tutorial assumes you have finished the [introductory tutorial](/2_0/quickstart) and continues where that tutorial left off. In particular, you should still have the latest version of code for `myapp`.
14
14
15
15
## 2. Generating data
16
16
@@ -100,7 +100,7 @@ We can include the generate code with the `include!` macro. The `impl_data_provi
100
100
externcrate alloc; // required as my-data is written for #[no_std]
@@ -149,14 +153,14 @@ This will generate a `my_data_blob.postcard` file containing the serialized data
149
153
150
154
Unlike `BakedDataProvider`, `BlobDataProvider` (and `FsDataProvider`) does not perform locale fallbacking. For example, if `en-US` is requested but only `en` data is available, then the data request will fail. To enable fallback, we can wrap the provider in a `LocaleFallbackProvider`.
151
155
152
-
Note that fallback comes at a cost, as fallbacking code and data has to be included and executed on every request. If you don't need fallback (disclaimer: you probably do), you can use the `BlobDataProvider` directly (for baked data, see [`Options::skip_internal_fallback`](https://docs.rs/icu_provider_baked/2.0.0-beta2/icu_provider_baked/export/struct.Options.html)).
156
+
Note that fallback comes at a cost, as fallbacking code and data has to be included and executed on every request. If you don't need fallback (disclaimer: you probably do), you can use the `BlobDataProvider` directly (for baked data, see [`Options::skip_internal_fallback`](https://docs.rs/icu_provider_baked/2.0.0/icu_provider_baked/export/struct.Options.html)).
@@ -256,4 +260,4 @@ We have learned how to generate data and load it into our programs, optimize dat
256
260
257
261
For a deeper dive into configuring your data providers in code, see [data-provider-runtime.md].
258
262
259
-
You can learn more about datagen, including the Rust API which we have not used in this tutorial, by reading [the docs](https://docs.rs/icu_provider_export/2.0.0-beta2/).
263
+
You can learn more about datagen, including the Rust API which we have not used in this tutorial, by reading [the docs](https://docs.rs/icu_provider_export/2.0.0/).
letlocale=icu::locale::Locale::default(); // to make this example compile
153
+
letlocale=icu::locale::Locale::UNKNOWN; // to make this example compile
154
154
155
155
/// Helper function to create an ICU4X DateTime for the current local time:
156
156
fnget_current_date() ->Date<Iso> {
@@ -228,7 +228,7 @@ Now we would also like to format the current time.
228
228
229
229
### Rust Part 4
230
230
231
-
Use the API documentation for [`icu::time::DateTime`](https://docs.rs/icu/2.0.0-beta2/icu/timezone/struct.DateTime.html) and [`icu::datetime::DateTimeFormatter`](https://docs.rs/icu/2.0.0-beta2/icu/datetime/struct.DateTimeFormatter.html) to expand your app to format both date and time.
231
+
Use the API documentation for [`icu::time::DateTime`](https://docs.rs/icu/2.0.0/icu/timezone/struct.DateTime.html) and [`icu::datetime::DateTimeFormatter`](https://docs.rs/icu/2.0.0/icu/datetime/struct.DateTimeFormatter.html) to expand your app to format both date and time.
232
232
233
233
Hint: You can use `Default::default()` for the `DateTimeFormatterOptions` argument.
Copy file name to clipboardExpand all lines: src/content/docs/2_0/tutorials/using-from-cpp.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ ICU4X's core functionality is completely available from C++, with headers genera
8
8
9
9
Typically C++ users can build ICU4X by building the `icu_capi` Rust crate, and linking the resultant static library to their C++ application. This crate contains all of the relevant [Diplomat]-generated `extern "C"` declarations, as well as an idiomatic C++ wrapper using these functions.
10
10
11
-
Using ICU4X in C++ is best demonstrated via the [examples](https://github.com/unicode-org/icu4x/tree/main/tutorials/cpp). For example, [here's an example showing off decimal formatting in ICU4X](https://github.com/unicode-org/icu4x/tree/main/tutorials/cpp/fixeddecimal.cpp), built with [this Makefile](https://github.com/unicode-org/icu4x/tree/main/tutorials/cpp/Makefile).
11
+
Using ICU4X in C++ is best demonstrated via the [examples](https://github.com/unicode-org/icu4x/tree/release%2F2.0/tutorials/cpp). For example, [here's an example showing off decimal formatting in ICU4X](https://github.com/unicode-org/icu4x/tree/release%2F2.0/tutorials/cpp/fixeddecimal.cpp), built with [this Makefile](https://github.com/unicode-org/icu4x/tree/release%2F2.0/tutorials/cpp/Makefile).
12
12
13
13
_We are still working on improving the user experience of using ICU4X from other languages. As such, this tutorial may be a bit sparse, but we are happy to answer questions on our [discussions forum] and help you out_
14
14
@@ -30,7 +30,7 @@ resolver = "2"
30
30
path = "unused"
31
31
32
32
[dependencies]
33
-
icu_capi = { version = "2.0.0-dev", default-features = false, features = [] }
33
+
icu_capi = { version = "2.0.0", default-features = false, features = [] }
34
34
```
35
35
36
36
Some of the keys are required by the parser, but won't be used by us.
@@ -47,7 +47,7 @@ Some of the keys are required by the parser, but won't be used by us.
47
47
You can now set features by updating the `features` key in `Cargo.toml`:
48
48
49
49
```toml
50
-
icu_capi = { version = "2.0.0-dev", default-features = false, features = ["default", "buffer_provider"] }
50
+
icu_capi = { version = "2.0.0", default-features = false, features = ["default", "buffer_provider"] }
51
51
52
52
```
53
53
@@ -124,7 +124,7 @@ C++ versions beyond C++17 are supported, as are other C++ compilers.
124
124
Users wishing to use ICU4X on a `no_std` platform will need to provide an allocator and a panic hook in order to build a linkable library. The `icu_capi` crate can provide a looping panic handler, and a `malloc`-backed allocator, under the `looping_panic_handler` and `libc_alloc` features, respectively.
125
125
126
126
```toml
127
-
icu_capi = { version = "2.0.0-dev", default-features = false, features = ["default_components", "buffer_provider", "looping_panic_handler", "libc_alloc"] }
127
+
icu_capi = { version = "2.0.0", default-features = false, features = ["default_components", "buffer_provider", "looping_panic_handler", "libc_alloc"] }
0 commit comments