From f3b1553a2692298e21815a812b81b4e097423aa5 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Tue, 16 Jan 2018 13:57:31 +0100 Subject: [PATCH] Update docs about trans --- CHANGELOG.md | 3 +++ .../documentation/getting-started/configuration.md | 6 +++++- docs/content/documentation/templates/overview.md | 10 +++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3b4c6ad..152704ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/docs/content/documentation/getting-started/configuration.md b/docs/content/documentation/getting-started/configuration.md index 1fafebbe..f7966d51 100644 --- a/docs/content/documentation/getting-started/configuration.md +++ b/docs/content/documentation/getting-started/configuration.md @@ -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] diff --git a/docs/content/documentation/templates/overview.md b/docs/content/documentation/templates/overview.md index e8b3accb..03f77ecf 100644 --- a/docs/content/documentation/templates/overview.md +++ b/docs/content/documentation/templates/overview.md @@ -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") }} +```