From aef8d1a8a90127c71897d8fb6e7ce03f55069386 Mon Sep 17 00:00:00 2001 From: Ryan Southgate Date: Fri, 7 Apr 2017 18:17:58 +0100 Subject: [PATCH] docs(tattribute): alias configuration * Corrected help about registering aliases for [t] Changed the help to correctly explain how to successfully register aliases for the "t" attribute. fixes #206 --- doc/article/en-US/i18n-with-aurelia.md | 31 ++++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/doc/article/en-US/i18n-with-aurelia.md b/doc/article/en-US/i18n-with-aurelia.md index ff7a04f5..0a6fd132 100644 --- a/doc/article/en-US/i18n-with-aurelia.md +++ b/doc/article/en-US/i18n-with-aurelia.md @@ -171,8 +171,12 @@ be slight differences. The following listings show the configuration for first t .standardConfiguration() .developmentLogging() .plugin('aurelia-i18n', (instance) => { + let aliases = ['t', 'i18n']; + // add aliases for 't' attribute + TCustomAttribute.configureAliases(aliases); + // register backend plugin - instance.i18next.use(Backend.with(aurelia.loader)); + instance.i18next.use(Backend.with(aurelia.loader)); // adapt options to your needs (see http://i18next.com/docs/options/) // make sure to return the promise of the setup method, in order to guarantee proper loading @@ -180,8 +184,8 @@ be slight differences. The following listings show the configuration for first t backend: { // <-- configure backend settings loadPath: './locales/{{lng}}/{{ns}}.json', // <-- XHR settings for where to get the files from }, + attributes: aliases, lng : 'de', - attributes : ['t','i18n'], fallbackLng : 'en', debug : false }); @@ -207,6 +211,10 @@ be slight differences. The following listings show the configuration for first t .standardConfiguration() .developmentLogging() .plugin('aurelia-i18n', (instance) => { + let aliases = ['t', 'i18n']; + // add aliases for 't' attribute + TCustomAttribute.configureAliases(aliases); + // register backend plugin instance.i18next.use(Backend); @@ -216,8 +224,8 @@ be slight differences. The following listings show the configuration for first t backend: { // <-- configure backend settings loadPath: './locales/{{lng}}/{{ns}}.json', // <-- XHR settings for where to get the files from }, + attributes: aliases, lng : 'de', - attributes : ['t','i18n'], fallbackLng : 'en', debug : false }); @@ -361,18 +369,27 @@ Translating stuff via code works by using the method `tr`. You pass in the `key` ### Translating via html attributes Translation in html can be done alternatively using attributes. By default the plugin is configured to use the `t` and `i18n` attributes. -This can be configured during the plugin registration using the `attributes` property. +This can be configured during the plugin registration using the `TCustomAttribute.configureAliases` function and also the `attributes` +property plugin `instance.setup` function parameter. - + ... - instance.setup({ + .plugin("aurelia-i18n", (instance) => { + ... + let aliases = ['t','i18n']; + TCustomAttribute.configureAliases(aliases); ... - attributes : ['t','i18n'], + instance.setup({ + ... + attributes : aliases, + ... + }); ... }); ... +