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
Please don't edit files in the `dist` subdirectory as they are generated via Grunt. You'll find source code in the `src` subdirectory!
5
+
6
+
### Code style
7
+
Regarding code style like indentation and whitespace, **follow the conventions you see used in the source already.**
8
+
9
+
### PhantomJS
10
+
While Grunt can run the included unit tests via [PhantomJS](http://phantomjs.org/), this shouldn't be considered a substitute for the real thing. Please be sure to test the `test/*.html` unit test file(s) in _actual_ browsers.
11
+
12
+
## Modifying the code
13
+
First, ensure that you have the latest [Node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed.
14
+
15
+
Test that Grunt's CLI is installed by running `grunt --version`. If the command isn't found, run `npm install -g grunt-cli`. For more information about installing Grunt, see the [getting started guide](http://gruntjs.com/getting-started).
16
+
17
+
1. Fork and clone the repo.
18
+
1. Run `npm install` to install all dependencies (including Grunt).
19
+
1. Run `grunt` to grunt this project.
20
+
21
+
Assuming that you don't see any red, you're ready to go. Just be sure to run `grunt` after making any changes, to ensure that nothing is broken.
22
+
23
+
## Submitting pull requests
24
+
25
+
1. Create a new branch, please don't work in your `master` branch directly.
26
+
1. Add failing tests for the change you want to make. Run `grunt` to see the tests fail.
27
+
1. Fix stuff.
28
+
1. Run `grunt` to see if the tests pass. Repeat steps 2-4 until done.
29
+
1. Open `test/*.html` unit test file(s) in actual browser to ensure tests pass everywhere.
30
+
1. Update the documentation to reflect any changes.
The first argument of the localize method is the name of the language pack. You might have a different language pack for different parts of your website.
44
55
45
56
Here's an example of loading several language packs:
46
57
47
-
$("[data-localize]")
48
-
.localize("header")
49
-
.localize("sidebar")
50
-
.localize("footer")
51
-
58
+
```html
59
+
<script>
60
+
$("[data-localize]")
61
+
.localize("header")
62
+
.localize("sidebar")
63
+
.localize("footer")
64
+
</script>
65
+
```
52
66
53
67
If the language of the browser were set to "fr", then the plugin would try to load:
54
68
@@ -64,38 +78,44 @@ if the language of the browser also had a country code, like "fr-FR", then the p
64
78
65
79
This let's you define partial language refinements for different regions. For instance, you can have the base language translation file for a language that translates 100 different phrases, and for countries were maybe a some of those phrases would be out of place, you can just provide a country-specific file with _just those special phrases_ defined.
66
80
67
-
## Skipping Languages (aka Optimizing for My Language)
81
+
###Skipping Languages (aka Optimizing for My Language)
68
82
69
83
This is useful if you've got a default language. For example, if all of your content is served in english, then you probably don't want the overhead of loading up unecessary (and probably non-existant) english langauge packs (foo-en.json)
70
84
71
85
You can tell the localize plugin to always skip certain languages using the skipLanguage option:
72
86
73
-
# using a string will skip ONLY if the language code matches exactly
74
-
# this would prevent loading only if the language was "en-US"
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.
125
149
126
-
$("[data-localize]").localize("application", {
127
-
language: "es",
128
-
callback: function(data, defaultCallback){
150
+
```html
151
+
<script>
152
+
$("[data-localize]").localize("application", {
153
+
language:"es",
154
+
callback:function(data, defaultCallback){
129
155
data.title=data.title+currentBugName();
130
156
defaultCallback(data)
131
-
}
132
-
})
157
+
}
158
+
});
159
+
</script>
160
+
```
133
161
134
162
See the test/samples for working examples.
135
163
@@ -162,4 +190,4 @@ Please use it, and contribute changes.
162
190
http://github.com/coderifous/jquery-localize
163
191
164
192
Based off of Keith Wood's Localisation jQuery plugin.
0 commit comments