Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Derive i18n support #844

Open
wants to merge 90 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
f8af562
added language files for tests
89Q12 Jun 16, 2022
e9b1be5
added htmls files to test translation
89Q12 Jun 16, 2022
9877915
added tests
89Q12 Jun 16, 2022
2eb0fdf
added parser for localize(foo, bar: baz)
89Q12 Jun 16, 2022
7d11fd2
added tests for the localize parser
89Q12 Jun 16, 2022
8336929
added visit_localize, arm: Expr::Localize, field:localized_messages
89Q12 Jun 16, 2022
72dda5e
added extraction for the locale field and localizer field
89Q12 Jun 16, 2022
858ea69
added locale attribute
89Q12 Jun 16, 2022
465483d
corrected locale attribute
89Q12 Jun 16, 2022
39a1370
added feature localization
89Q12 Jun 16, 2022
47cbb51
added #[cfg(feature = "localization")]
89Q12 Jun 16, 2022
1874729
Fixed errors and added comment
89Q12 Jun 16, 2022
98ff019
fix cargo files
89Q12 Jun 16, 2022
07db0e7
fix test: test_parse_nested_localize
89Q12 Jun 16, 2022
8bd252e
added #![cfg(feature = "localization")] to i18n tests
89Q12 Jun 16, 2022
c96ada6
added askama::Local struct with impl
89Q12 Jun 17, 2022
d1a46fe
changed tests to use askama::Local
89Q12 Jun 17, 2022
cdbc7d0
removed init_translation macro since its not needed anymore
89Q12 Jun 17, 2022
4c7300c
refactored no args test adn its template
89Q12 Jun 17, 2022
7e1f5e6
Merge branch 'main' of https://github.com/11Tuvork28/askama into i18n
89Q12 Jun 17, 2022
17f95e7
removed last todos
89Q12 Jun 17, 2022
2c827f2
Added test for invalid tags with no fallack language
89Q12 Jun 17, 2022
c3f5684
fixed lint error from Lint workflow
89Q12 Jun 17, 2022
2658da3
Fixed typo th -> the
89Q12 Jun 17, 2022
7b89872
fixed test I messed up
89Q12 Jun 17, 2022
5ce38a3
Added fn quoted_ident to support only localize("foo", bar:baz) and
89Q12 Jun 17, 2022
7a11db6
Updated test templates -> quoted all messages
89Q12 Jun 17, 2022
355163a
Added cut() to localze function
89Q12 Jun 17, 2022
62027c8
Revert "Added cut() to localze function" because expr_any uses alt wh…
89Q12 Jun 17, 2022
bbe5991
HashMap<String, ...> to HashMap<&str, ...>
89Q12 Jun 17, 2022
f3ec8c7
removed .to_string()
89Q12 Jun 17, 2022
cc01d9b
removed "dep:" from toml files and removed println
89Q12 Jun 17, 2022
afbc64f
A bunch of changes
Kijewski Jun 17, 2022
b3714f4
Merge pull request #1 from Kijewski/i18n
89Q12 Jun 18, 2022
569a79b
Remove unnecessary feature guard
89Q12 Jun 19, 2022
db5c3e2
Corrected comment
89Q12 Jun 19, 2022
129786d
Validate localization at compile time
Kijewski Jun 19, 2022
ba50d10
Merge pull request #2 from Kijewski/br-i18n-with-compile-time-checks
89Q12 Jun 19, 2022
ca2ca74
Fixed various Clippy complaints
89Q12 Jun 19, 2022
da0319b
added feature guards to make the compiler happy and fix errors
89Q12 Jun 19, 2022
da9f506
changed forbid(unsafe) to forbid(unsafe_code)
89Q12 Jun 19, 2022
96c63c5
Created typ alias PathResources for Vec<(PathBuf, Resource<String>
89Q12 Jun 19, 2022
7663bf8
Fix "all" the clippy warnings
Kijewski Jun 19, 2022
03b4979
Merge pull request #3 from Kijewski/br-i18n-with-compile-time-checks
89Q12 Jun 19, 2022
08d34bd
Merge branch 'djc:main' into i18n
89Q12 Jul 12, 2022
39b0c4a
Merge branch 'main' into i18n
89Q12 Jul 28, 2022
6872a72
Fix lint job
89Q12 Sep 5, 2022
92fadc9
fix: Remove commented out i18n tests
LeoniePhiline Oct 10, 2022
98a4777
fix: Add trailing newline to i18n test templates
LeoniePhiline Oct 10, 2022
63ed5c9
fix: `cargo fmt`, remove trailing whitespace
LeoniePhiline Oct 10, 2022
073e92a
fix: Rename feature `localization` to `i18n`
LeoniePhiline Oct 10, 2022
f944c86
opinionated: Rename initialization macro `localization!` to `i18n_load!`
LeoniePhiline Oct 10, 2022
c32b22d
style: Change wording "have to" to "need to"
LeoniePhiline Oct 10, 2022
426575e
refactor: Confine i18n code inside i18n modules
LeoniePhiline Oct 10, 2022
81cce1a
fix: Hide dependency `fluent_templates` from library users
LeoniePhiline Oct 10, 2022
1c315d6
fix(deps): Update dependency `fluent-templates` to `0.8.0`
LeoniePhiline Oct 10, 2022
6384ae2
docs: Add initial i18n module documentation
LeoniePhiline Oct 10, 2022
7f82494
Merge pull request #4 from LeoniePhiline/i18n
89Q12 Oct 11, 2022
3f002ef
docs: Rename example template struct
LeoniePhiline Oct 11, 2022
925d1b5
Merge branch 'djc:main' into i18n
89Q12 Oct 11, 2022
8f30ba5
Merge pull request #5 from LeoniePhiline/i18n
89Q12 Oct 11, 2022
b52aaf3
fix: Implement missing recursive `is_cachable()` for `Expr::Localize`
LeoniePhiline Oct 11, 2022
9909c36
fix(style): Name localization message identifier as in Fluent Project
LeoniePhiline Oct 11, 2022
6cda9f5
fix(style): Normalize test names, prefix all with `test_`
LeoniePhiline Oct 11, 2022
9e1f326
Merge pull request #6 from LeoniePhiline/i18n
89Q12 Oct 11, 2022
7c15904
fix: Add missing trailing newline
LeoniePhiline Oct 11, 2022
5c35e12
Merge branch '11Tuvork28:i18n' into i18n
LeoniePhiline Oct 11, 2022
2bbba70
fix: Compilation without feature `i18n` failed
LeoniePhiline Oct 11, 2022
b5dda4c
Merge pull request #7 from LeoniePhiline/i18n
89Q12 Oct 11, 2022
f9dfa60
Merge branch 'djc:main' into i18n
89Q12 Jan 12, 2023
70dca43
Move i18n to seperated parser files
TTWNO Apr 17, 2023
47b7c6c
Fix toml/basic-toml dependency mismatch
TTWNO Apr 17, 2023
e1b66c8
Use path function instead of field
TTWNO Apr 17, 2023
b21ba00
Update spelling of 'cacheable', and actually use expr_localized
TTWNO Apr 17, 2023
4a3b1d0
Fix conflict
TTWNO Jul 16, 2023
7a79974
Cargo format
TTWNO Jul 17, 2023
2db3abe
Add fundementals for i18n in a new module
TTWNO Jul 30, 2023
cf707c9
Add i18n support to generator: visit_localize
TTWNO Jul 30, 2023
a0821b3
Add localizer to input
TTWNO Jul 30, 2023
3ad39b4
Add localization expression type
TTWNO Jul 30, 2023
e70e93d
Cargo format
TTWNO Jul 30, 2023
986ef3e
Add parsing tests for localization
TTWNO Jul 30, 2023
4f1e5c7
Remove use of Unlazy
TTWNO Jul 30, 2023
94f6a09
Merge conflicted files from main
TTWNO Dec 10, 2023
21202a2
Fix derive cargo
TTWNO Dec 10, 2023
de05a6b
Fix compile errors with expr
TTWNO Dec 10, 2023
22e72fe
Fix clippy warning about workspace Cargo.toml
TTWNO Dec 11, 2023
68a77b0
Merge with main
TTWNO Dec 27, 2023
15149ce
Add askama derive cachable localizer
TTWNO Dec 27, 2023
6703c24
Cargo format
TTWNO Jan 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Hide dependency fluent_templates from library users
LeoniePhiline committed Oct 10, 2022
commit 81cce1a395c81342aacbab2db687ec3ba6ea57e7
10 changes: 5 additions & 5 deletions askama_derive/src/i18n.rs
Original file line number Diff line number Diff line change
@@ -260,19 +260,19 @@ pub(crate) fn load(input: TokenStream) -> Result<TokenStream, CompileError> {
let ts = quote_spanned! {
span =>
#vis static #name:
::fluent_templates::once_cell::sync::Lazy::<
::fluent_templates::StaticLoader
> = ::fluent_templates::once_cell::sync::Lazy::new(|| {
::askama::i18n::fluent_templates::once_cell::sync::Lazy::<
::askama::i18n::fluent_templates::StaticLoader
> = ::askama::i18n::fluent_templates::once_cell::sync::Lazy::new(|| {
mod fluent_templates {
// RATIONALE: the user might not use fluent_templates directly.
pub use ::fluent_templates::*;
pub use ::askama::i18n::fluent_templates::*;
pub mod once_cell {
pub mod sync {
pub use ::askama::i18n::Unlazy as Lazy;
}
}
}
::fluent_templates::static_loader! {
::askama::i18n::fluent_templates::static_loader! {
pub static LOCALES = {
locales: #assets_dir,
fallback_language: #fallback,
3 changes: 1 addition & 2 deletions testing/Cargo.toml
Original file line number Diff line number Diff line change
@@ -8,14 +8,13 @@ publish = false

[features]
default = ["serde-json", "markdown", "i18n"]
i18n = ["askama/i18n", "fluent-templates"]
i18n = ["askama/i18n"]
markdown = ["comrak", "askama/markdown"]
serde-json = ["serde_json", "askama/serde-json"]

[dependencies]
askama = { path = "../askama", version = "0.11.0-beta.1" }
comrak = { version = "0.14", default-features = false, optional = true }
fluent-templates = { version = "0.7.1", optional = true, default-features = false }
serde_json = { version = "1.0", optional = true }

[dev-dependencies]