Skip to content

Commit 7f5e262

Browse files
committed
chore(README): complete it
1 parent aac3eaf commit 7f5e262

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

README.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ The localization key can be defined as the value of the `i18n` attribute:
267267

268268
If the attribute value is not a valid token, then it will itself be used as the element's content.
269269

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+
270273
#### Localize with Dynamic User Data
271274

272275
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
281284

282285
### i18nAttr directive
283286

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.
285291

286292
### locale Service
287293

@@ -318,7 +324,7 @@ It is also possible to pass an object or an array with localization arguments or
318324
<p>{{ errorMessage | i18n:data }}</p>
319325
```
320326

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.
322328
In such a situation, the token is modified to have the substitution text params appended to it like so:
323329

324330
```js
@@ -337,7 +343,13 @@ The part after the token must be in a valid JSON format as either an array, obje
337343

338344
### Sample App
339345

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.
341353

342354
## License
343355

0 commit comments

Comments
 (0)