extra.missing_translations for configuring fallback
This commit is contained in:
parent
4b82a0aafb
commit
d989b0953c
10
README.md
10
README.md
|
@ -98,10 +98,18 @@ Example: use `home_section = "blog"` to feature the blog/ section on the homepag
|
||||||
If your website sources are published somewhere, you can display a URL (currently only in the footer) to each page's source, by configuring a `[extra.forge]` block in the config file. This block should contain a single `browse` field containing the baseURL to which the page/section path will be added to form the entire link to the source. As trailing slashes are trimmed in the template itself, the URL may end with a `/`. For example:
|
If your website sources are published somewhere, you can display a URL (currently only in the footer) to each page's source, by configuring a `[extra.forge]` block in the config file. This block should contain a single `browse` field containing the baseURL to which the page/section path will be added to form the entire link to the source. As trailing slashes are trimmed in the template itself, the URL may end with a `/`. For example:
|
||||||
|
|
||||||
```
|
```
|
||||||
[forge]
|
[extra.forge]
|
||||||
browse = "https://lab.example/foo/bar/src/branch/main"
|
browse = "https://lab.example/foo/bar/src/branch/main"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Missing translations
|
||||||
|
|
||||||
|
The `extra.missing_translations` setting configures what to do when a translation string is missing. It can have the following values:
|
||||||
|
|
||||||
|
- `error` (default) will fail the build with an error message, as is default zola behavior
|
||||||
|
- `placeholder` will output the requested translation key (eg. `source`) instead of an actual translation
|
||||||
|
- any other value is interpreted as a fallback language to query translations from when a specific string is missing
|
||||||
|
|
||||||
# Customization
|
# Customization
|
||||||
|
|
||||||
## Extending templates
|
## Extending templates
|
||||||
|
|
|
@ -135,5 +135,7 @@ Separate entries with a thematic break:
|
||||||
up a key in the config.extra.translations.lang. These translation
|
up a key in the config.extra.translations.lang. These translation
|
||||||
strings extend (and potentially replace) those of the theme. #}
|
strings extend (and potentially replace) those of the theme. #}
|
||||||
{%- macro t(key) -%}
|
{%- macro t(key) -%}
|
||||||
{{ config.extra.translations[lang][key] }}
|
{%- if config.extra.missing_translations|default(value="error") == "error" -%}{{ config.extra.translations[lang][key] }}
|
||||||
|
{%- elif config.extra.missing_translations == "placeholder" -%}{{ config.extra.translations[lang][key]|default(value=key) }}
|
||||||
|
{%- else -%}{{ config.extra.translations[lang][key]|default(value=config.extra.translations[config.extra.missing_translations][key]) }}{%- endif -%}
|
||||||
{%- endmacro t -%}
|
{%- endmacro t -%}
|
||||||
|
|
Loading…
Reference in New Issue