Skip to content

Commit 3fbd0e0

Browse files
committed
Update README.md
1 parent 4b52788 commit 3fbd0e0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ import {TranslateService, TranslatePipe} from 'ng2-translate/ng2-translate';
4040
@Component({
4141
selector: 'app',
4242
template: `
43-
<div>{{ 'HELLO_WORLD' | translate:'{value: "world"}' }} world</div>
43+
<div>{{ 'HELLO' | translate:{value: param} }}</div>
4444
`,
4545
pipes: [TranslatePipe]
4646
})
4747
export class AppComponent {
48+
param: string = "world";
49+
4850
constructor(translate: TranslateService) {
4951
var userLang = navigator.language.split('-')[0]; // use navigator lang if available
5052
userLang = /(fr|en)/gi.test(userLang) ? userLang : 'en';
@@ -68,7 +70,7 @@ translate.useStaticFilesLoader(prefix, suffix);
6870
Then put your translations in a json file that looks like this (for `en.json`):
6971
```json
7072
{
71-
"HELLO_WORLD": "hello {{value}}"
73+
"HELLO": "hello {{value}}"
7274
}
7375
```
7476

@@ -80,7 +82,7 @@ An then you can get new translations like this:
8082
But you can also define your translations manually instead of using `getTranslation`:
8183
```js
8284
translate.setTranslation('en', {
83-
"HELLO_WORLD": "hello {{value}}"
85+
"HELLO": "hello {{value}}"
8486
});
8587
```
8688

@@ -113,10 +115,10 @@ You can call the TranslatePipe with some optional parameters that will be transp
113115

114116
Example:
115117
```html
116-
<p>Say {{ 'HELLO_WORLD' | translate:'{value: "world"}' }}</p>
118+
<p>Say {{ 'HELLO' | translate:{value: "world"} }}</p>
117119
```
118120

119-
With the given translation: `"HELLO_WORLD": "hello {{value}}"`.
121+
With the given translation: `"HELLO": "hello {{value}}"`.
120122

121123
### Parser
122124
#### Methods:

0 commit comments

Comments
 (0)