Skip to content

Commit 98cb04c

Browse files
committed
More read me cleanup
1 parent 0394292 commit 98cb04c

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

README.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ example-fr.json:
3737

3838
### Use the localize plugin.
3939

40-
// In a browser where the language is set to French
41-
$("[data-localize]").localize("example")
40+
```html
41+
<script>
42+
// In a browser where the language is set to French
43+
$("[data-localize]").localize("example")
4244
43-
// You can also override the language detection, and pass in a language code
44-
$("[data-localize]").localize("example", { language: "fr" })
45+
// You can also override the language detection, and pass in a language code
46+
$("[data-localize]").localize("example", { language: "fr" })
47+
</script>
48+
```
4549

4650
## Gory Details
4751

@@ -51,11 +55,14 @@ The first argument of the localize method is the name of the language pack. You
5155

5256
Here's an example of loading several language packs:
5357

54-
$("[data-localize]")
55-
.localize("header")
56-
.localize("sidebar")
57-
.localize("footer")
58-
58+
```html
59+
<script>
60+
$("[data-localize]")
61+
.localize("header")
62+
.localize("sidebar")
63+
.localize("footer")
64+
</script>
65+
```
5966

6067
If the language of the browser were set to "fr", then the plugin would try to load:
6168

@@ -128,21 +135,25 @@ If you rely on the default callback and use the "data-localize" attribute then t
128135

129136
```html
130137
<script>
131-
$("[data-localize]").localize("application", { language: "es" })
138+
$("[data-localize]").localize("application", { language: "es" });
132139
</script>
133140
```
134141

135142
### Callbacks
136143

137144
You can provide a callback if you want to augment or replace the default callback provided by the plugin. Your callback should take at least 1 argument: the language data (contents of your json file). It can optionally accept a second argument, which is a reference to the default callback function. This is handy if you still want the default behavior, but also need to do something else with the language data.
138145

139-
$("[data-localize]").localize("application", {
140-
language: "es",
141-
callback: function(data, defaultCallback){
146+
```html
147+
<script>
148+
$("[data-localize]").localize("application", {
149+
language: "es",
150+
callback: function(data, defaultCallback){
142151
data.title = data.title + currentBugName();
143152
defaultCallback(data)
144-
}
145-
})
153+
}
154+
});
155+
</script>
156+
```
146157

147158
See the test/samples for working examples.
148159

0 commit comments

Comments
 (0)