Skip to content

Commit

Permalink
Use files tracker API on nightly to track files (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja authored Jun 25, 2024
1 parent 1cd7025 commit 049d236
Show file tree
Hide file tree
Showing 23 changed files with 1,539 additions and 459 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Cargo.lock -diff
/README.md -diff
/leptos-fluent-macros/README.md -diff
/leptos-fluent/README.md -diff
book/mdbook-admonish.css -diff

# Don't export/archive these files
.github export-ignore
22 changes: 20 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ on:
workflow_dispatch:

jobs:
check-toolchain-is-stable:
name: Check toolchain is stable
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get toolchain
id: toolchain
uses: ./.github/actions/get-toolchain
- name: Check toolchain
run: |
if [ "${{ steps.toolchain.outputs.channel }}" != "stable" ]; then
echo 'Toolchain is not "stable", is "${{ steps.toolchain.outputs.channel }}". Check the file rust-toolchain.toml'
exit 1
fi
echo "channel=$channel" >> $GITHUB_OUTPUT
qa:
name: QA
runs-on: ubuntu-latest
Expand Down Expand Up @@ -82,12 +98,13 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install mdbook
run: cargo binstall -y mdbook
run: cargo binstall -y mdbook mdbook-admonish mdbook-toc
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build book
run: |
cd book
mdbook-admonish install .
mdbook build
unit-tests:
Expand Down Expand Up @@ -346,12 +363,13 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install mdbook
run: cargo binstall -y mdbook
run: cargo binstall -y mdbook mdbook-admonish mdbook-toc
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build book
run: |
cd book
mdbook-admonish install .
mdbook build
- name: Deploy book
uses: peaceiris/actions-gh-pages@v3
Expand Down
13 changes: 9 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# CHANGELOG

## Unreleased - [0.1.5]
## 2024-06-26 - [0.1.5]

### New features

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

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

### Enhancements

- Use files tracker API instead of `include_bytes!` quirk to track files
when `nightly` feature is enabled.

## 2024-06-25 - [0.1.4]

### New features
Expand Down Expand Up @@ -305,7 +310,7 @@ version to `0.1` during installation.

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

[0.1.5]: https://github.com/mondeja/leptos-fluent/compare/v0.1.4...master
[0.1.5]: https://github.com/mondeja/leptos-fluent/compare/v0.1.4...v0.1.5
[0.1.4]: https://github.com/mondeja/leptos-fluent/compare/v0.1.3...v0.1.4
[0.1.3]: https://github.com/mondeja/leptos-fluent/compare/v0.1.2...v0.1.3
[0.1.2]: https://github.com/mondeja/leptos-fluent/compare/v0.1.1...v0.1.2
Expand Down
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,21 @@ fn App() -> impl IntoView {
url_param: "lang",
// Discover the initial language of the user from an URL parameter.
initial_language_from_url_param: true,

// Desktop applications (feature `system`)
// ---------------------------------------
// Set the initial language from the system locale.
initial_language_from_system: true,
// Set the discovered initial language of the user from
// the system locale to a data file.
initial_language_from_system_to_data_file: true,
// Get the initial language from a data file.
initial_language_from_data_file: true,
// Key to use to name the data file. Should be unique per
// application. By default is `"leptos-fluent"`.
data_file_key: "my-app",
// Set the language selected to a data file.
set_language_to_data_file: true,
}};

view! {
Expand Down Expand Up @@ -188,9 +203,7 @@ fn TranslatableComponent() -> impl IntoView {

#[component]
fn LanguageSelector() -> impl IntoView {
// Use `expect_i18n()` to get the current i18n context:
let i18n = expect_i18n();

// `expect_i18n()` to get the i18n context
// `i18n.languages` is a static array with the available languages
// `i18n.language.get()` to get the current language
// `lang.activate()` to set the current language
Expand All @@ -199,7 +212,7 @@ fn LanguageSelector() -> impl IntoView {
view! {
<fieldset>
{
move || i18n.languages.iter().map(|lang| {
move || expect_i18n().languages.iter().map(|lang| {
view! {
<div>
<input
Expand Down Expand Up @@ -227,6 +240,7 @@ fn LanguageSelector() -> impl IntoView {
- **Actix Web integration**: `actix`
- **Axum integration**: `axum`
- **Nightly toolchain**: `nightly`
- **Desktop applications**: `system`
- **JSON languages file**: `json` (enabled by default)
- **YAML languages file**: `yaml`
- **JSON5 languages file**: `json5`
Expand All @@ -240,7 +254,7 @@ fn LanguageSelector() -> impl IntoView {

[leptos]: https://leptos.dev/
[fluent-templates]: https://github.com/XAMPPRocky/fluent-templates
[quickstart]: https://docs.rs/leptos-fluent/latest/leptos_fluent/macro.leptos_fluent.html
[quickstart]: https://mondeja.github.io/leptos-fluent/leptos_fluent.html
[examples]: https://github.com/mondeja/leptos-fluent/tree/master/examples
[book]: https://mondeja.github.io/leptos-fluent/
[documentation]: https://docs.rs/leptos-fluent
16 changes: 16 additions & 0 deletions book/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,23 @@ build-dir = "dist"
site-url = "/leptos-fluent/"
git-repository-url = "https://github.com/mondeja/leptos-fluent/tree/master/book"
edit-url-template = "https://github.com/mondeja/leptos-fluent/edit/master/book/{path}"
additional-css = ["./mdbook-admonish.css"]

[output.html.playground]
editable = true
line-numbers = true

[preprocessor.admonish]
on_failure = "bail"
command = "mdbook-admonish"
assets_version = "3.0.2" # do not edit: managed by `mdbook-admonish install`

[preprocessor.admonish.default]
collapsible = false

[preprocessor.admonish.renderer.test]
render_mode = "strip"

[preprocessor.toc]
command = "mdbook-toc"
renderer = ["html"]
Loading

0 comments on commit 049d236

Please sign in to comment.