Skip to content

Commit

Permalink
docs(README): improved docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ocombe committed Aug 13, 2016
1 parent 2b6ae6b commit 146717f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ translate.setTranslation('en', {

You can use the `TranslateService` to get new translations like this:
```ts
translate.getTranslation(userLang);
translate.get('SOME_KEY').subscribe((res: string) => {
// do something with res
});
```

Or use the `TranslatePipe` in any template:
Expand All @@ -166,7 +168,7 @@ Or use the `TranslatePipe` in any template:
- `setDefaultLang(lang: string)`: Sets the default language to use as a fallback
- `use(lang: string): Observable<any>`: Changes the lang currently used
- `getTranslation(lang: string): Observable<any>`: Gets an object of translations for a given language with the current loader
- `setTranslation(lang: string, translations: Object)`: Manually sets an object of translations for a given language
- `setTranslation(lang: string, translations: Object, shouldMerge: boolean = false)`: Manually sets an object of translations for a given language, set `shouldMerge` to true if you want to append the translations instead of replacing them
- `getLangs()`: Returns an array of currently available langs
- `get(key: string|Array<string>, interpolateParams?: Object): Observable<string|Object>`: Gets the translated value of a key (or an array of keys)
- `instant(key: string|Array<string>, interpolateParams?: Object): string|Object`: Gets the instant translated value of a key (or an array of keys). /!\ This method is **synchronous** and the default file loader is asynchronous. You are responsible for knowing when your translations have been loaded and it is safe to use this method. If you are not sure then you should use the `get` method instead.
Expand Down
1 change: 1 addition & 0 deletions src/translate.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export class TranslateService {
* Manually sets an object of translations for a given language
* @param lang
* @param translations
* @param shouldMerge
*/
public setTranslation(lang: string, translations: Object, shouldMerge: boolean = false): void {
if (shouldMerge && this.translations[lang]) {
Expand Down

0 comments on commit 146717f

Please sign in to comment.