You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-18Lines changed: 22 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,9 @@
5
5
6
6
A robust internationalization solution for Rust featuring compile-time validation, ISO 639-1 compliance, and TOML-based translation management.
7
7
8
+
**This library prioritizes ergonomics over raw performance.**
9
+
Our goal is not to be *blazingly fast* but to provide the most user-friendly experience for implementing translations—whether you're a first-time user or an experienced developer. If you require maximum performance, consider alternative libraries, a custom implementation, or even hard-coded values on the stack.
10
+
8
11
## Table of Contents 📖
9
12
10
13
-[Features](#features-)
@@ -63,7 +66,7 @@ The translation files have three rules
63
66
The load configuration such as `seek_mode` and `overlap` is not relevant here, as previously
64
67
specified, these configuration values only get applied once by reversing the translations conveniently.
65
68
66
-
To load translations you make use of the `translatable::translation` macro, that macro requires two
69
+
To load translations you make use of the `translatable::translation` macro, that macro requires at least two
67
70
parameters to be passed.
68
71
69
72
The first parameter consists of the language which can be passed dynamically as a variable or an expression
@@ -74,15 +77,22 @@ The second parameter consists of the path, which can be passed dynamically as a
74
77
that resolves to an `impl Into<String>` with the format `path.to.translation`, or statically with the following
75
78
syntax `static path::to::translation`.
76
79
80
+
The rest of parameters are `meta-variable patterns` also known as `key = value` parameters or key-value pairs,
81
+
these are processed as replaces, *or format if the call is all-static*. When a template (`{}`) is found with
82
+
the name of a key inside it gets replaced for whatever is the `Display` implementation of the value. This meaning
83
+
that the value must always implement `Display`. Otherwise, if you want to have a `{}` inside your translation,
84
+
you can escape it the same way `format!` does, by using `{{}}`. Just like object construction works in rust, if
85
+
you have a parameter like `x = x`, you can shorten it to `x`.
86
+
77
87
Depending on whether the parameters are static or dynamic the macro will act different, differing whether
78
88
the checks are compile-time or run-time, the following table is a macro behavior matrix.
79
89
80
90
| Parameters | Compile-Time checks | Return type |
|`static language` + `static path` (most optimized) | Path existence, Language validity, \*Template validation|`&'static str` (stack) if there are no templates or `String` (heap) if there are. |
92
+
|`static language` + `static path` (most optimized) | Path existence, Language validity|`&'static str` (stack) if there are no templates or `String` (heap) if there are. |
0 commit comments