Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja committed Nov 15, 2024
1 parent 54780fe commit 38ec0d8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 64 deletions.
22 changes: 9 additions & 13 deletions README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 0 additions & 25 deletions book/src/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,6 @@ initialization, different modes of persistent storage, and more.
[![docs.rs](https://img.shields.io/docsrs/leptos-fluent?logo=docs.rs)](https://docs.rs/leptos-fluent)
[![Crates.io downloads](https://img.shields.io/crates/d/leptos-fluent)](https://crates.io/crates/leptos-fluent)

## Alternatives

The unique alternative to **leptos-fluent** currently is [Leptos i18n], which
follows a different approach. The main differences are:

- `leptos-fluent` uses [Fluent] files and the Fluent syntax for translations,
while `leptos_i18n` uses JSON files and a custom syntax.
- `leptos-fluent` defines all the configuration in a macro and an optional
languages file, while `leptos_i18n` defines the configuration in a
`[package.metadata.leptos-i18n]` section in _Cargo.toml_.
- `leptos-fluent` allows to instantiate multiple internationalization contexts,
while `leptos_i18n` only allows one.
- `leptos-fluent` has a lot of strategies for activating the initial language
of the user at initialization and updating it when the user changes the
language, while `leptos_i18n` only follows the cookie strategy.
- `leptos-fluent` automatically builds language names and directions based on
language codes, while `leptos_i18n` don't.
- `leptos-fluent` has multiple side effects for updating the language in the
client, while `leptos_i18n` only has the `<html lang="...">` attribute
and is not configurable.

## Project goals

The main goals of **leptos-fluent** are:
Expand All @@ -40,9 +19,6 @@ The main goals of **leptos-fluent** are:
- Be the most fully featured internationalization framework in any language.
- Be the most performant internationalization framework available.

Defining the internationalization strategy using a macro allows to generate
the less code possible for each possible configuration.

## Help and support

<!-- markdownlint-disable MD013 -->
Expand All @@ -65,7 +41,6 @@ development environment and contribute to the project.
[discord-badge]: https://img.shields.io/badge/Discord-grey?logo=discord&logoColor=white
[Leptos]: https://leptos.dev
[Fluent]: https://projectfluent.org
[Leptos i18n]: https://github.com/Baptistemontan/leptos_i18n
[`#leptos-fluent` channel]: https://discord.com/channels/1031524867910148188/1251579884371705927
[Leptos Discord server]: https://discord.com/channels/1031524867910148188
[open a discussion]: https://github.com/mondeja/leptos-fluent/discussions/new
Expand Down
22 changes: 9 additions & 13 deletions leptos-fluent/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 11 additions & 13 deletions leptos-fluent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,17 @@
//!
//! // Client side options
//! // -------------------
//! // Synchronize `<html lang="...">` attribute with the
//! // Synchronize `<html lang="...">` attribute with
//! // current active language.
//! sync_html_tag_lang: true,
//! // Synchronize `<html dir="...">` attribute with `"ltr"`,
//! // `"rtl"` or `"auto"` depending on active language.
//! sync_html_tag_dir: true,
//! // Update language on URL parameter when changes.
//! set_language_to_url_param: true,
//! // Set initial language of the user from
//! // URL in local storage.
//! // Set initial language of user from URL in local storage.
//! initial_language_from_url_param_to_localstorage: true,
//! // Set initial language of the user from
//! // URL in a cookie.
//! // Set initial language of user from URL in a cookie.
//! initial_language_from_url_param_to_cookie: true,
//! // Key used to get and set the current language of the
//! // user on local storage. By default is `"lang"`.
Expand All @@ -129,14 +127,12 @@
//! // Get initial language from `navigator.languages`
//! // if not found in local storage.
//! initial_language_from_navigator: true,
//! // Set initial language of the user from
//! // the navigator to local storage.
//! // Set initial language of user from navigator to local storage.
//! initial_language_from_navigator_to_localstorage: true,
//! // Set initial language of the user from
//! // the navigator to a cookie.
//! // Set initial language of user from navigator to a cookie.
//! initial_language_from_navigator_to_cookie: true,
//! // Attributes to set for language cookie.
//! // By default is `""`.
//! // By default `""`.
//! cookie_attrs: "Secure; Path=/; Max-Age=600",
//! // Update language on cookie when the language changes.
//! set_language_to_cookie: true,
Expand All @@ -152,12 +148,12 @@
//! // Server and client side options
//! // ------------------------------
//! // Name of the cookie to get and set the current active
//! // language. By default, it is `"lf-lang"`.
//! // language. By default `"lf-lang"`.
//! cookie_name: "lang",
//! // Set initial language from cookie.
//! initial_language_from_cookie: true,
//! // URL parameter to use setting the language in the URL.
//! // By default is `"lang"`.
//! // By default `"lang"`.
//! url_param: "lang",
//! // Set initial language of the user from an URL parameter.
//! initial_language_from_url_param: true,
Expand All @@ -172,7 +168,7 @@
//! // Get 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"`.
//! // application. By default `"leptos-fluent"`.
//! data_file_key: "my-app",
//! // Set the language selected to a data file.
//! set_language_to_data_file: true,
Expand Down Expand Up @@ -443,6 +439,8 @@ impl I18n {
/// raise an error message.
///
/// ```rust,ignore
/// use leptos_fluent::leptos_fluent;
///
/// let i18n = leptos_fluent! {
/// // ...
/// provide_meta_context: true,
Expand Down

0 comments on commit 38ec0d8

Please sign in to comment.