Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update I18N documentation #275

Merged
merged 3 commits into from
Jun 29, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 1 addition & 42 deletions doc/article/en-US/i18n-with-aurelia.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,48 +485,7 @@ Notice in the above example that the key was set to `home.title`. This will make
</source-code>
</code-listing>

Use `updateTranslation()` to update all translations within the children of the element that is passed to it.
The following example shows how a view model can be configured to update it's contents when the view is attached and every time a locale is changed.

<code-listing heading="Updating translations manually">
<source-code lang="ES 2015">
import {I18N} from 'aurelia-i18n';
import {EventAggregator} from 'aurelia-event-aggregator';

export class MyDemoVM {
static inject = [I18N,Element,EventAggregator];
constructor(i18n,element,ea) {
this.i18n = i18n;
this.element = element;

ea.subscribe('i18n:locale:changed', payload => {
this.i18n.updateTranslations(this.element);
});
}

attached(){
this.i18n.updateTranslations(this.element);
}
}
</source-code>
</code-listing>

Alternatively you may extend your VM with the provided Base-I18N-VM, which will set that up for you automatically.

<code-listing heading="Automatic locale changed subscription using the Base-I18N-VM">
<source-code lang="ES 2015">
import {BaseI18N} from 'aurelia-i18n';

export class MyDemoVM extends BaseI18N {

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

> Info
> Just remember in case you define your own `constructor`, to call `this.super` and pass it the instances of its
dependencies as described in the previous example. Same applies to `attached`, although nothing needs to be passed
in here
Use `i18n.updateTranslation()` to update all translations within the children of the element that is passed to it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually its i18n.updateTranslations()


#### Specifying attributes

Expand Down