Simplify fn translations in light of #10868

- Reverted overly complex fn translations from #10810
- Updated guidelines so it's clear that fn translations need to remain
simple. They shouldn't be so complex that they fail for edge cases
- Updated catch so we are aware when translations fail
This commit is contained in:
Gabriel Horner
2024-01-18 10:18:23 -05:00
committed by Tienson Qin
parent c4341c1884
commit 283d084de2
4 changed files with 16 additions and 19 deletions

View File

@@ -84,7 +84,10 @@ Almost all translations are small. The only exceptions to this are the keys `:tu
* Some translations may include punctuation like `:` or `!`. When translating them, please use the punctuation that makes the most sense for your language as you don't have to follow the English ones.
* Some translations may include arguments/interpolations e.g. `{1}`. If you see them in a translation, be sure to include them. These arguments are substituted in the string and are usually used for something the app needs to calculate e.g. a number. See [these docs](https://github.com/tonsky/tongue#interpolation) for more examples.
* Rarely, a translation may need to translate formatted text by returning [hiccup-style HTML](https://github.com/weavejester/hiccup#syntax). In this case, a Clojure function is the recommended approach. For example, a function translation would look like `(fn [] [:div "FOO"])`. See `:on-boarding/main-title` for an example.
* Rarely, a translation is a function that calls code and look like `(fn ... )`
* The logic for these fns must be simple and can only use the following fns: `str`, `when`, `if` and `=`.
* These fn translations are usually used to handle pluralization or handle formatted text by returning [hiccup-style HTML](https://github.com/weavejester/hiccup#syntax). For example, a hiccup style translation would look like `(fn [] [:div "FOO"])`. See `:on-boarding/main-title` for more examples.
## Fix Mistakes
There is a lint command to catch common translation mistakes - `bb

View File

@@ -90,8 +90,7 @@ translations here are some things to keep in mind:
fn translation. Hiccup vectors are needed when word order matters for a
translation and formatting is involved. See [this 3 word Turkish
example](https://github.com/logseq/logseq/commit/1d932f07c4a0aad44606da6df03a432fe8421480#r118971415).
* Translations can have arguments for interpolating strings. When they do, be
sure translators are using them correctly.
* Translations can be anonymous fns with arguments for interpolating strings. Fns should be simple and only include the following fns: `str`, `when`, `if` and `=`.
### Spell Checker