Skip to content

Commit

Permalink
docs(tattribute): alias configuration
Browse files Browse the repository at this point in the history
* Corrected help about registering aliases for [t]

Changed the help to correctly explain how to successfully register aliases for the "t" attribute.

fixes #206
  • Loading branch information
ry8806 authored and zewa666 committed Apr 7, 2017
1 parent 605f81f commit aef8d1a
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions doc/article/en-US/i18n-with-aurelia.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,21 @@ 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
return instance.setup({
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
});
Expand All @@ -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);

Expand All @@ -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
});
Expand Down Expand Up @@ -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.

<code-listing heading="Configuring translation attributes">
<source-code lang="ES 2015">

...
instance.setup({
.plugin("aurelia-i18n", (instance) => {
...
let aliases = ['t','i18n'];
TCustomAttribute.configureAliases(aliases);
...
attributes : ['t','i18n'],
instance.setup({
...
attributes : aliases,
...
});
...
});
...

</source-code>
</code-listing>

Expand Down

0 comments on commit aef8d1a

Please sign in to comment.