-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from Baptistemontan/json5
Support for JSON5 file format
- Loading branch information
Showing
18 changed files
with
456 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Cargo.lock | ||
target | ||
!.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"recommendations": [ | ||
"lokalise.i18n-ally", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
languageIds: | ||
- rust | ||
|
||
usageMatchRegex: | ||
- "[^\\w\\d]t!\\(\\s*[\\w.:]*,\\s*([\\w.]*)" | ||
- "[^\\w\\d]td!\\(\\s*[\\w.:]*,\\s*([\\w.]*)" | ||
- "[^\\w\\d]td_string!\\(\\s*[\\w.:]*,\\s*([\\w.]*)" | ||
- "[^\\w\\d]td_display!\\(\\s*[\\w.:]*,\\s*([\\w.]*)" | ||
|
||
monopoly: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"i18n-ally.keystyle": "nested", | ||
"i18n-ally.localesPaths": "locales" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
name = "json5" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
leptos = { version = "0.7.0-gamma2", features = ["ssr"] } | ||
tests_common = { path = "../common" } | ||
leptos_i18n = { path = "../../leptos_i18n", default-features = false, features = [ | ||
"json5_files", | ||
"icu_compiled_data", | ||
"track_locale_files", | ||
] } | ||
|
||
|
||
[package.metadata.leptos-i18n] | ||
default = "en" | ||
locales = ["en", "fr"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# YAML files format tests | ||
|
||
Test 2 things: | ||
|
||
- Everything compile fine | ||
- Check if the output is correct | ||
|
||
Disclaimer: the yaml files are slightly tweaked "JSON to YAML" outputs, if it looks ugly it's because it's only 3.14% hand made. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
click_to_change_lang: "Click to change language", | ||
click_count: "You clicked {{ count }} times", | ||
click_to_inc: "Click to increment the counter", | ||
f32_range: [ | ||
"f32", | ||
["You are broke", 0.0], | ||
["You owe money", "..0.0"], | ||
["You have {{ count }}€"], | ||
], | ||
u32_range: ["u32", [0, 0], ["1..", "1.."]], | ||
OR_range: [ | ||
"u8", | ||
["0 or 5", "0", 5], | ||
["1..5 | 6..10", "1..5", "6..10"], | ||
["10..15 | 20", "10..15", 20], | ||
["fallback with no count"], | ||
], | ||
f32_OR_range: [ | ||
"f32", | ||
["0 or 5", 0, 5], | ||
["1..5 | 6..10", "1..5", "6..10"], | ||
["10..15 | 20", "10..15", 20], | ||
["fallback with no count"], | ||
], | ||
subkeys: { | ||
subkey_1: "subkey_1", | ||
subkey_2: "<b>subkey_2</b>", | ||
subkey_3: [ | ||
["zero", 0], | ||
["one", 1], | ||
["{{ count }}", "_"], | ||
], | ||
}, | ||
defaulted_string: "this string is declared in locale en", | ||
defaulted_interpolation: "this interpolation is declared in locale {{ locale }}", | ||
defaulted_ranges: [ | ||
["zero", 0], | ||
["this range is declared in locale {{ locale }}"], | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
click_to_change_lang: "Cliquez pour changez de langue", | ||
click_count: "Vous avez cliqué {{ count }} fois", | ||
click_to_inc: "Cliquez pour incrémenter le compteur", | ||
f32_range: [ | ||
"f32", | ||
["Vous êtes pauvre", 0.0], | ||
["Vous devez de l'argent", "..0.0"], | ||
["Vous avez {{ count }}€"], | ||
], | ||
u32_range: ["u32", [0, 0], ["1..", "1.."]], | ||
OR_range: [ | ||
"u8", | ||
["0 or 5", "0", 5], | ||
["1..5 | 6..10", "1..5", "6..10"], | ||
["10..15 | 20", "10..15", 20], | ||
["fallback sans count"], | ||
], | ||
f32_OR_range: [ | ||
"f32", | ||
["0 or 5", 0, 5], | ||
["1..5 | 6..10", "1..5", "6..10"], | ||
["10..15 | 20", "10..15", 20], | ||
["fallback avec tuple vide", []], | ||
], | ||
subkeys: { | ||
subkey_1: "subkey_1", | ||
subkey_2: "<b>subkey_2</b>", | ||
subkey_3: [ | ||
["0", 0], | ||
["{{ count }}", "_"], | ||
], | ||
}, | ||
defaulted_string: null, | ||
defaulted_interpolation: null, | ||
defaulted_ranges: null, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::i18n::*; | ||
use tests_common::*; | ||
|
||
#[test] | ||
fn defaulted_string() { | ||
let en = td!(Locale::en, defaulted_string); | ||
assert_eq_rendered!(en, "this string is declared in locale en"); | ||
let fr = td!(Locale::fr, defaulted_string); | ||
assert_eq_rendered!(fr, "this string is declared in locale en"); | ||
} | ||
|
||
#[test] | ||
fn defaulted_interpolation() { | ||
let en = td!(Locale::en, defaulted_interpolation, locale = "en"); | ||
assert_eq_rendered!(en, "this interpolation is declared in locale en"); | ||
let fr = td!(Locale::fr, defaulted_interpolation, locale = "en"); | ||
assert_eq_rendered!(fr, "this interpolation is declared in locale en"); | ||
} | ||
|
||
#[test] | ||
fn defaulted_ranges() { | ||
let count = || 0; | ||
let en = td!(Locale::en, defaulted_ranges, locale = "en", count = count); | ||
assert_eq_rendered!(en, "zero"); | ||
let fr = td!(Locale::fr, defaulted_ranges, locale = "en", count = count); | ||
assert_eq_rendered!(fr, "zero"); | ||
|
||
for i in [-3, 5, 12] { | ||
let count = move || i; | ||
let en = td!(Locale::en, defaulted_ranges, locale = "en", count = count); | ||
assert_eq_rendered!(en, "this range is declared in locale en"); | ||
let fr = td!(Locale::fr, defaulted_ranges, locale = "en", count = count); | ||
assert_eq_rendered!(fr, "this range is declared in locale en"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#![deny(warnings)] | ||
leptos_i18n::load_locales!(); | ||
|
||
#[cfg(test)] | ||
mod ranges; | ||
|
||
#[cfg(test)] | ||
mod subkeys; | ||
|
||
#[cfg(test)] | ||
mod tests; | ||
|
||
#[cfg(test)] | ||
mod defaulted; |
Oops, something went wrong.