Update docs about trans

This commit is contained in:
Vincent Prouillet 2018-01-16 13:57:31 +01:00
parent b06f012be4
commit f3b1553a26
3 changed files with 17 additions and 2 deletions

View file

@ -6,6 +6,7 @@
- Change names of individual taxonomies to be plural (ie `tags/my-tag` instead of `tag/my-tag`)
- Front matter now uses TOML dates rather strings: remove quotes from your date value to fix it.
For example: `date = "2001-10-10"` becomes `date = 2001-10-10`
- `language_code` has been renamed `default_language` in preparations of i18n support
### Others
- Add `get_taxonomy_url` to retrieve the permalink of a tag/category
@ -16,6 +17,8 @@ For example: `date = "2001-10-10"` becomes `date = 2001-10-10`
- Add Prolog syntax highlighting and update all current syntaxes
- Live reloading now works on shortcode template changes
- `gutenberg serve` now reloads site on `config.toml` changes: you will need to F5 to see them though
- Add a `trans` global function that will get return the translation of the given key for the given lang, defaulting
to `config.default_language` if not given
## 0.2.2 (2017-11-01)

View file

@ -21,7 +21,8 @@ base_url = "mywebsite.com"
# Used in RSS by default
title = ""
description = ""
language_code = "en"
# the default language, used in RSS and coming i18n
default_language = "en"
# Theme name to use
theme = ""
@ -50,6 +51,9 @@ generate_categories_pages = false
# Whether to compile the Sass files found in the `sass` directory
compile_sass = false
# Optional translation object. The key if present should be a language code
[translations]
# You can put any kind of data in there and it
# will be accessible in all templates
[extra]

View file

@ -81,7 +81,7 @@ In the case of non-internal links, you can also add a cachebust of the format `?
by passing `cachebust=true` to the `get_url` function.
### ` get_taxonomy_url`
### `get_taxonomy_url`
Gets the permalink for the tag or category given.
```jinja2
@ -90,3 +90,11 @@ Gets the permalink for the tag or category given.
The `name` will almost come from a variable but in case you want to do it manually,
the value should be the same as the one in the front-matter, not the slugified version.
### `trans`
Gets the translation of the given `key`, for the `default_language` or the `language given
```jinja2
{{ trans(key="title") }}
{{ trans(key="title", lang="fr") }}
```