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`) - 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. - 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` For example: `date = "2001-10-10"` becomes `date = 2001-10-10`
- `language_code` has been renamed `default_language` in preparations of i18n support
### Others ### Others
- Add `get_taxonomy_url` to retrieve the permalink of a tag/category - 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 - Add Prolog syntax highlighting and update all current syntaxes
- Live reloading now works on shortcode template changes - 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 - `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) ## 0.2.2 (2017-11-01)

View file

@ -21,7 +21,8 @@ base_url = "mywebsite.com"
# Used in RSS by default # Used in RSS by default
title = "" title = ""
description = "" description = ""
language_code = "en" # the default language, used in RSS and coming i18n
default_language = "en"
# Theme name to use # Theme name to use
theme = "" theme = ""
@ -50,6 +51,9 @@ generate_categories_pages = false
# Whether to compile the Sass files found in the `sass` directory # Whether to compile the Sass files found in the `sass` directory
compile_sass = false 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 # You can put any kind of data in there and it
# will be accessible in all templates # will be accessible in all templates
[extra] [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. by passing `cachebust=true` to the `get_url` function.
### ` get_taxonomy_url` ### `get_taxonomy_url`
Gets the permalink for the tag or category given. Gets the permalink for the tag or category given.
```jinja2 ```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 `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. 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") }}
```