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
+15-3
Original file line number
Diff line number
Diff line change
@@ -267,6 +267,9 @@ The localization key can be defined as the value of the `i18n` attribute:
267
267
268
268
If the attribute value is not a valid token, then it will itself be used as the element's content.
269
269
270
+
__NOTE:__ Localizations defined by the `i18n` attribute cannot contain HTML tags, as the translation result will be assigned as text, not as HTML.
271
+
This limitation enables a slightly faster localization, as no sanitization is required.
272
+
270
273
#### Localize with Dynamic User Data
271
274
272
275
It is also possible to provide dynamic user data to the translation function.
@@ -281,7 +284,10 @@ Whenever `user.name` is updated, it's indicator in the token `helloWorld` is sub
281
284
282
285
### i18nAttr directive
283
286
284
-
TODO
287
+
The i18n Attribute directive is pretty much the same as the i18n directive except that it expects a json-like object structure represented as a set of key-value pair combinations.
288
+
The key corresponds to the HTML attribute to be localized, and the value is the localization resource string token which will be passed to the service itself.
289
+
290
+
If you want to pass dynamic values for the string, those should come after the value for each key; the series of additional parameters is expected to be appendeded to the token, prepended with a separator so that the directive will walk through and replace the numbered place holders with their values.
285
291
286
292
### locale Service
287
293
@@ -318,7 +324,7 @@ It is also possible to pass an object or an array with localization arguments or
318
324
<p>{{ errorMessage | i18n:data }}</p>
319
325
```
320
326
321
-
The filter also serves a special purpose use-case targeted at maximum compatibilty with other third party plugin modules, directives, components etc. where it is not possible to provide the parameters as a separate argument.
327
+
The filter also serves a special purpose targeted at maximum compatibilty with other third party plugin modules, directives, components etc. where it is not possible to provide the parameters as a separate argument.
322
328
In such a situation, the token is modified to have the substitution text params appended to it like so:
323
329
324
330
```js
@@ -337,7 +343,13 @@ The part after the token must be in a valid JSON format as either an array, obje
337
343
338
344
### Sample App
339
345
340
-
TODO
346
+
I've created a sample app that uses this plugin to provide the text for the entire application.
347
+
I registered 'ngLocalize' in my app's dependency list and I then use a combination of
348
+
`ng-bind="'home.title' | i18n"`,
349
+
`{{ 'home.title' | i18n }}`,
350
+
`data-i18n="home.title"` and
351
+
`data-i18n-attr="{placeholder: 'home.title'}`
352
+
to insert the text into the page at run time along with their variously supported use-cases.
0 commit comments