Skip to content

Commit 049d236

Browse files
authored
Use files tracker API on nightly to track files (#165)
1 parent 1cd7025 commit 049d236

23 files changed

+1539
-459
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Cargo.lock -diff
55
/README.md -diff
66
/leptos-fluent-macros/README.md -diff
77
/leptos-fluent/README.md -diff
8+
book/mdbook-admonish.css -diff
89

910
# Don't export/archive these files
1011
.github export-ignore

.github/workflows/ci.yml

+20-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@ on:
1010
workflow_dispatch:
1111

1212
jobs:
13+
check-toolchain-is-stable:
14+
name: Check toolchain is stable
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Get toolchain
19+
id: toolchain
20+
uses: ./.github/actions/get-toolchain
21+
- name: Check toolchain
22+
run: |
23+
if [ "${{ steps.toolchain.outputs.channel }}" != "stable" ]; then
24+
echo 'Toolchain is not "stable", is "${{ steps.toolchain.outputs.channel }}". Check the file rust-toolchain.toml'
25+
exit 1
26+
fi
27+
echo "channel=$channel" >> $GITHUB_OUTPUT
28+
1329
qa:
1430
name: QA
1531
runs-on: ubuntu-latest
@@ -82,12 +98,13 @@ jobs:
8298
env:
8399
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84100
- name: Install mdbook
85-
run: cargo binstall -y mdbook
101+
run: cargo binstall -y mdbook mdbook-admonish mdbook-toc
86102
env:
87103
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88104
- name: Build book
89105
run: |
90106
cd book
107+
mdbook-admonish install .
91108
mdbook build
92109
93110
unit-tests:
@@ -346,12 +363,13 @@ jobs:
346363
env:
347364
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
348365
- name: Install mdbook
349-
run: cargo binstall -y mdbook
366+
run: cargo binstall -y mdbook mdbook-admonish mdbook-toc
350367
env:
351368
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
352369
- name: Build book
353370
run: |
354371
cd book
372+
mdbook-admonish install .
355373
mdbook build
356374
- name: Deploy book
357375
uses: peaceiris/actions-gh-pages@v3

CHANGELOG.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# CHANGELOG
22

3-
## Unreleased - [0.1.5]
3+
## 2024-06-26 - [0.1.5]
44

55
### New features
66

7+
- Add `leptos_fluent::SsrHtmlTag` component to render it on SSR to sync
8+
global attributes of `<html>` tag with the current language.
79
- Add new feature `system` to enable functionalities that require system
810
information. Useful on non wasm targets like desktop applications.
911
See [GTK example].
1012
- Add `initial_language_from_system` parameter to `leptos_fluent!` macro to set
1113
the initial language from the system language. Useful for desktop
1214
applications. Must be enabled the new feature `system` to use it.
13-
- Add `leptos_fluent::SsrHtmlTag` component to render it on SSR to sync
14-
global attribute of `<html>` tag with the current language.
1515
- Add `initial_language_from_data_file` parameter to `leptos_fluent!` macro to
1616
set the initial language from a data file when using `system` feature.
1717
- Add `set_language_to_data_file` parameter to `leptos_fluent!` macro to set
@@ -24,6 +24,11 @@
2424

2525
[GTK example]: https://github.com/mondeja/leptos-fluent/tree/master/examples/system-gtk
2626

27+
### Enhancements
28+
29+
- Use files tracker API instead of `include_bytes!` quirk to track files
30+
when `nightly` feature is enabled.
31+
2732
## 2024-06-25 - [0.1.4]
2833

2934
### New features
@@ -305,7 +310,7 @@ version to `0.1` during installation.
305310

306311
- Added all ISO-639-1 and ISO-639-2 languages.
307312

308-
[0.1.5]: https://github.com/mondeja/leptos-fluent/compare/v0.1.4...master
313+
[0.1.5]: https://github.com/mondeja/leptos-fluent/compare/v0.1.4...v0.1.5
309314
[0.1.4]: https://github.com/mondeja/leptos-fluent/compare/v0.1.3...v0.1.4
310315
[0.1.3]: https://github.com/mondeja/leptos-fluent/compare/v0.1.2...v0.1.3
311316
[0.1.2]: https://github.com/mondeja/leptos-fluent/compare/v0.1.1...v0.1.2

README.md

+19-5
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,21 @@ fn App() -> impl IntoView {
161161
url_param: "lang",
162162
// Discover the initial language of the user from an URL parameter.
163163
initial_language_from_url_param: true,
164+
165+
// Desktop applications (feature `system`)
166+
// ---------------------------------------
167+
// Set the initial language from the system locale.
168+
initial_language_from_system: true,
169+
// Set the discovered initial language of the user from
170+
// the system locale to a data file.
171+
initial_language_from_system_to_data_file: true,
172+
// Get the initial language from a data file.
173+
initial_language_from_data_file: true,
174+
// Key to use to name the data file. Should be unique per
175+
// application. By default is `"leptos-fluent"`.
176+
data_file_key: "my-app",
177+
// Set the language selected to a data file.
178+
set_language_to_data_file: true,
164179
}};
165180

166181
view! {
@@ -188,9 +203,7 @@ fn TranslatableComponent() -> impl IntoView {
188203

189204
#[component]
190205
fn LanguageSelector() -> impl IntoView {
191-
// Use `expect_i18n()` to get the current i18n context:
192-
let i18n = expect_i18n();
193-
206+
// `expect_i18n()` to get the i18n context
194207
// `i18n.languages` is a static array with the available languages
195208
// `i18n.language.get()` to get the current language
196209
// `lang.activate()` to set the current language
@@ -199,7 +212,7 @@ fn LanguageSelector() -> impl IntoView {
199212
view! {
200213
<fieldset>
201214
{
202-
move || i18n.languages.iter().map(|lang| {
215+
move || expect_i18n().languages.iter().map(|lang| {
203216
view! {
204217
<div>
205218
<input
@@ -227,6 +240,7 @@ fn LanguageSelector() -> impl IntoView {
227240
- **Actix Web integration**: `actix`
228241
- **Axum integration**: `axum`
229242
- **Nightly toolchain**: `nightly`
243+
- **Desktop applications**: `system`
230244
- **JSON languages file**: `json` (enabled by default)
231245
- **YAML languages file**: `yaml`
232246
- **JSON5 languages file**: `json5`
@@ -240,7 +254,7 @@ fn LanguageSelector() -> impl IntoView {
240254

241255
[leptos]: https://leptos.dev/
242256
[fluent-templates]: https://github.com/XAMPPRocky/fluent-templates
243-
[quickstart]: https://docs.rs/leptos-fluent/latest/leptos_fluent/macro.leptos_fluent.html
257+
[quickstart]: https://mondeja.github.io/leptos-fluent/leptos_fluent.html
244258
[examples]: https://github.com/mondeja/leptos-fluent/tree/master/examples
245259
[book]: https://mondeja.github.io/leptos-fluent/
246260
[documentation]: https://docs.rs/leptos-fluent

book/book.toml

+16
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,23 @@ build-dir = "dist"
1717
site-url = "/leptos-fluent/"
1818
git-repository-url = "https://github.com/mondeja/leptos-fluent/tree/master/book"
1919
edit-url-template = "https://github.com/mondeja/leptos-fluent/edit/master/book/{path}"
20+
additional-css = ["./mdbook-admonish.css"]
2021

2122
[output.html.playground]
2223
editable = true
2324
line-numbers = true
25+
26+
[preprocessor.admonish]
27+
on_failure = "bail"
28+
command = "mdbook-admonish"
29+
assets_version = "3.0.2" # do not edit: managed by `mdbook-admonish install`
30+
31+
[preprocessor.admonish.default]
32+
collapsible = false
33+
34+
[preprocessor.admonish.renderer.test]
35+
render_mode = "strip"
36+
37+
[preprocessor.toc]
38+
command = "mdbook-toc"
39+
renderer = ["html"]

0 commit comments

Comments
 (0)