Skip to content

Commit

Permalink
feat(signaling): add alias for t-params
Browse files Browse the repository at this point in the history
 foreach attribute registered, add the corresponding *-params attribute as well

 fixes issue #41
  • Loading branch information
zewa666 committed Jan 7, 2016
1 parent 6965592 commit 3fd242f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -318,6 +318,7 @@ This will be picked up by the CLI when translations are extracted from the sourc

#### Passing parameters to the attribute
In order to use parameters for replaceable parts in your translation key, you can provide an additional `t-params` attribute and bind it to the object containing the replacement values.
Also note that for whatever attribute you registered, the corresponding \*-params attribute will get registered as well automatically.

```javascript
// Translation file
Expand All @@ -328,7 +329,7 @@ In order to use parameters for replaceable parts in your translation key, you ca

```markup
<!-- View -->
<span t.="[html]paramstest" t-params.bind="params"></span>
<span t="[html]paramstest" t-params.bind="params"></span>
```

```javascript
Expand Down
1 change: 1 addition & 0 deletions src/aurelia-i18n.js
Expand Up @@ -42,6 +42,7 @@ function configure(frameworkConfig, cb) {
}

attributes.forEach(alias => resources.registerAttribute(alias, htmlBehaviorResource, 't'));
attributes.forEach(alias => resources.registerAttribute(alias + '-params', htmlParamsResource, 't-params'));

This comment has been minimized.

Copy link
@doktordirk

doktordirk Jan 9, 2016

Contributor

ain't no htmlParamsResource defined

});

return ret;
Expand Down
12 changes: 6 additions & 6 deletions test/unit/i18n-attribute.spec.js
Expand Up @@ -19,13 +19,13 @@ describe('testing i18n attributes', () => {
sut = new I18N(new EventAggregator(), new DefaultLoader(), new BindingSignaler());
sut.setup({
resStore: {},
lng : 'en',
getAsync : false,
sendMissing : false,
fallbackLng : 'en',
debug : false
lng: 'en',
getAsync: false,
sendMissing: false,
fallbackLng: 'en',
debug: false
});

container = new Container();
container.registerInstance(I18N, sut);
container.registerInstance(DOM.Element, DOM.createElement('div'));
Expand Down

0 comments on commit 3fd242f

Please sign in to comment.