Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
robisim74 committed Nov 7, 2018
1 parent a5a7453 commit 9bcc62b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 52 deletions.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ It allows, in addition to translation, to localize numbers and dates of your app

---

Library version: 6.2.0 - [Changelog](https://github.com/robisim74/angular-l10n/releases)
Library version: 6.3.0 - [Changelog](https://github.com/robisim74/angular-l10n/releases)

---

Expand Down
26 changes: 0 additions & 26 deletions docs/spec/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,32 +88,6 @@ Method | Function

---

## Translation
Property | Value
-------- | -----
`lang: string` |
`protected paramSubscriptions: ISubscription[]` |

Method | Function
------ | --------
`protected cancelParamSubscriptions(): void` |

---

## Localization
Property | Value
-------- | -----
`defaultLocale: string` |
`currency: string` |
`timezone: string` |
`protected paramSubscriptions: ISubscription[]` |

Method | Function
------ | --------
`protected cancelParamSubscriptions(): void` |

---

## ILocaleValidation
Method | Function
------ | --------
Expand Down
31 changes: 9 additions & 22 deletions docs/spec/getting-the-translation.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,42 +186,29 @@ where `currencyDisplay` is the currency formatting. Possible values are _'symbol
{{ value | l10nCurrency:defaultLocale:currency:'symbol':'1.2-2' }}
```

### Translation & Localization classes
When using _pipes_, alternatively to _decorators_ you can
extend `Translation` or `Localization` classes.

Extend `Translation` class in the component to provide _lang_ to the _translate_ pipe:
```TypeScript
export class HomeComponent extends Translation { }
```
Extend `Localization` class in the component to provide _lang_ to the _translate_ pipe, _defaultLocale_, _currency_, _timezone_ to _l10nDate_, _l10nDecimal_, _l10nPercent_ & _l10nCurrency_ pipes.
```TypeScript
export class HomeComponent extends Localization { }
```
To cancel subscriptions for the params, you can call the `cancelParamSubscriptions` method into `ngOnDestroy`.

### OnPush ChangeDetectionStrategy
_Pure pipes_ don't need to set `ChangeDetectionStrategy` to `OnPush`. If into your components you need to use it, you have to extend `Translation` or `Localization` class and pass `ChangeDetectorRef`:
_Pure pipes_ don't need to set `ChangeDetectionStrategy` to `OnPush`. If into your components you need to use it, you have to inject `ChangeDetectorRef`:
```TypeScript
import { Component, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';

import { Translation } from 'angular-l10n'

@Component({
...
changeDetection: ChangeDetectionStrategy.OnPush
})
export class HomeComponent extends Translation {
export class HomeComponent implements OnInit {

constructor(public ref: ChangeDetectorRef) {
super(ref);
...
}
@Language() lang: string;

constructor(private cdr: ChangeDetectorRef) { }

ngOnInit(): void { }

}
```
That's because we need to know the component reference that implements the `OnPush` strategy.

> Note that if you use in the component only the _directives_ and not the _pipes_, you don't need to inject `ChangeDetectorRef`.
---

## Directives
Expand Down
2 changes: 0 additions & 2 deletions docs/spec/library-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Class | Contract
`L10nLoader` | Initializes the services
`LocaleService` | Manages language, default locale, currency & timezone
`TranslationService` | Manages the translation data
`Translation` | Provides _lang_ to the _translate_ pipe
`Localization` | Provides _lang_ to the _translate_ pipe, _defaultLocale_, _currency_, _timezone_ to _l10nDate_, _l10nDecimal_, _l10nPercent_ & _l10nCurrency_ pipes
`LocaleValidation` | Provides the methods for locale validation
`Collator` | Intl.Collator APIs
`IntlAPI` | Provides the methods to check if Intl APIs are supported
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "angular-l10n",
"private": true,
"version": "6.2.0",
"version": "6.3.0",
"description": "An Angular library to translate messages, dates and numbers",
"main": "./bundles/angular-l10n.umd.js",
"module": "./fesm5/angular-l10n.js",
Expand Down
1 change: 1 addition & 0 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
true,
"ignore-same-line"
],
"deprecation": false,
"forin": false,
"import-blacklist": false,
"interface-name": false,
Expand Down

0 comments on commit 9bcc62b

Please sign in to comment.