mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-14 04:16:13 +00:00
Describe lang.Translate fallback behavior
This commit is contained in:
1 parent
a6d9c362c0
commit
b3b1df75d6
2 files changed
+22
-1
No files matched your search
+4
-1
@@ -7,8 +7,10 @@
|
|||||||
"flagWords": [
|
"flagWords": [
|
||||||
"alot",
|
"alot",
|
||||||
"hte",
|
"hte",
|
||||||
|
"langauge",
|
||||||
"reccommend",
|
"reccommend",
|
||||||
"seperate"
|
"seperate",
|
||||||
|
"teh"
|
||||||
],
|
],
|
||||||
"ignorePaths": [
|
"ignorePaths": [
|
||||||
"**/emojis.md",
|
"**/emojis.md",
|
||||||
@@ -69,6 +71,7 @@
|
|||||||
"transpile",
|
"transpile",
|
||||||
"transpiles",
|
"transpiles",
|
||||||
"unmarshal",
|
"unmarshal",
|
||||||
|
"unmarshals",
|
||||||
"unmarshaling",
|
"unmarshaling",
|
||||||
"# ----------------------------------------------------------------------",
|
"# ----------------------------------------------------------------------",
|
||||||
"# cspell: ignore foreign language words",
|
"# cspell: ignore foreign language words",
|
||||||
|
|||||||
@@ -8,9 +8,27 @@ action:
|
|||||||
related: []
|
related: []
|
||||||
returnType: string
|
returnType: string
|
||||||
signatures: ['lang.Translate KEY [CONTEXT]']
|
signatures: ['lang.Translate KEY [CONTEXT]']
|
||||||
|
toc: true
|
||||||
aliases: [/functions/i18n]
|
aliases: [/functions/i18n]
|
||||||
---
|
---
|
||||||
|
|
||||||
|
The `lang.Translate` function returns the value associated with given key as defined in the translation table for the current language.
|
||||||
|
|
||||||
|
If the key is not found in the translation table for the current language, the `lang.Translate` function falls back to the translation table for the [`defaultContentLanguage`].
|
||||||
|
|
||||||
|
If the key is not found in the translation table for the `defaultContentLanguage`, the `lang.Translate` function returns an empty string.
|
||||||
|
|
||||||
|
[`defaultContentLanguage`]: /getting-started/configuration/#defaultcontentlanguage
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
To list missing and fallback translations, use the `--printI18nWarnings` flag when building your site.
|
||||||
|
|
||||||
|
To render placeholders for missing and fallback translations, set
|
||||||
|
[`enableMissingTranslationPlaceholders`] to `true` in your site configuration.
|
||||||
|
|
||||||
|
[`enableMissingTranslationPlaceholders`]: /getting-started/configuration/#enablemissingtranslationplaceholders
|
||||||
|
{{% /note %}}
|
||||||
|
|
||||||
Let's say your multilingual site supports two languages, English and Polish. Create a translation table for each language in the `i18n` directory.
|
Let's say your multilingual site supports two languages, English and Polish. Create a translation table for each language in the `i18n` directory.
|
||||||
|
|
||||||
```text
|
```text
|
||||||
|
|||||||
Reference in new issue
Block a user