You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-32
Original file line number
Diff line number
Diff line change
@@ -21,25 +21,30 @@ System.config({
21
21
```
22
22
23
23
Finally, you can use ng2-translate in your Angular 2 project (make sure that you've loaded the angular2/http bundle as well).
24
-
It is recommended to instantiate `TranslateService` in the bootstrap of your application and to never add it to the "providers" property of your components, this way you will keep it as a singleton.
25
-
If you add it to the "providers" property of a component it will instantiate a new instance of the service that won't be initialized.
24
+
It is recommended to use `NG_TRANSLATE_PROVIDERS` in the bootstrap of your application and to never add `TranslateService` to the "providers" property of your components, this way you will keep it as a singleton.
25
+
`NG_TRANSLATE_PROVIDERS` provides a default configuration for the static translation file loader.
26
+
If you add `TranslateService` to the "providers" property of a component it will instantiate a new instance of the service that won't be initialized with the language to use or the default language.
You can use the method `setMissingTranslationHandler` to define a handler that will be called when the requested translation is not available.
145
+
You can setup a provider for `MissingTranslationHandler` to define a handler that will be called when the requested translation is not available.
153
146
The only required method is `handle` where you can do whatever you want. Just don't forget that it will be called synchronously from the `get` & `instant` methods.
154
147
155
148
##### Example:
@@ -164,13 +157,9 @@ export class MyMissingTranslationHandler implements MissingTranslationHandler {
164
157
}
165
158
```
166
159
167
-
Set the Missing Translation Handler
160
+
Setup the Missing Translation Handler in bootstrap
0 commit comments