Skip to content

Commit

Permalink
Merge pull request #77 from jdforrester/master
Browse files Browse the repository at this point in the history
Release 1.0.3
  • Loading branch information
santhoshtr committed Jul 6, 2015
2 parents 3ef3b1e + 64aff85 commit 8e84755
Show file tree
Hide file tree
Showing 13 changed files with 480 additions and 459 deletions.
3 changes: 3 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"preset": "wikimedia"
}
31 changes: 13 additions & 18 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
{
"predef": [
"jQuery",
"QUnit",
"_"
],

"camelcase": true,
"curly": true,
// Enforcing
"bitwise": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"noempty": true,
"nonew": true,
"plusplus": false,
"quotmark": "single",
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"strict": false,

// Relaxing
"es5": false,
"freeze": false,

// Environment
"browser": true,
"jquery": true,

"nomen": true,
"onevar": true,
"white": false
"globals": {
"QUnit": false,
"_": false
}
}
3 changes: 1 addition & 2 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ Amir E. Aharoni
Siebrand Mazeland
Niklas Laxström
Neil Kandalgaonkar


David Chan
30 changes: 27 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ module.exports = function ( grunt ) {
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
grunt.loadNpmTasks( 'grunt-contrib-qunit' );
grunt.loadNpmTasks( 'grunt-contrib-connect' );
grunt.loadNpmTasks( 'grunt-contrib-watch' );
grunt.loadNpmTasks( 'grunt-jscs' );

grunt.initConfig( {
pkg: grunt.file.readJSON( 'package.json' ),
connect: {
Expand All @@ -20,10 +23,30 @@ module.exports = function ( grunt ) {
}
},
jshint: {
options: JSON.parse( grunt.file.read( '.jshintrc' )
.replace( /\/\*(?:(?!\*\/)[\s\S])*\*\//g, '' ).replace( /\/\/[^\n\r]*/g, '' ) ),
options: {
jshintrc: true
},
all: [ 'src/**/*.js' ]
},
jscs: {
fix: {
options: {
fix: true
},
src: '<%= jshint.all %>'
},
main: {
src: '<%= jshint.all %>'
}
},
watch: {
files: [
'.{jscsrc,jshintignore,jshintrc}',
'Gruntfile.js',
'<%= jshint.all %>'
],
tasks: 'test'
},
qunit: {
all: {
options: {
Expand All @@ -34,7 +57,8 @@ module.exports = function ( grunt ) {
} );

grunt.registerTask( 'server', [ 'connect' ] );
grunt.registerTask( 'lint', [ 'jshint' ] );
grunt.registerTask( 'lint', [ 'jshint', 'jscs:main' ] );
grunt.registerTask( 'fix', [ 'jscs:fix' ] );
grunt.registerTask( 'unit', [ 'server', 'qunit' ] );
grunt.registerTask( 'test', [ 'lint', 'unit' ] );
grunt.registerTask( 'default', [ 'test' ] );
Expand Down
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jQuery.i18n is a jQuery based Javascript internationalization library. It helps

This is a project by Wikimedia foundation's [Language Engineering team](http://wikimediafoundation.org/wiki/Language_Engineering_team) and used in some of the Wikimedia Foundation projects like Universal Language Selector.

The jquery.i18n library uses a json based localization file format and it is now used as localization file format for MediaWiki.
The jquery.i18n library uses a json based localization file format, "banana", which is used as the localization file format for MediaWiki and other projects.

Features
========
Expand Down Expand Up @@ -229,28 +229,28 @@ It is also possible to refer messages from an external URL. See below example

```javascript
$.i18n().load( {
'en': {
'message_hello': 'Hello World',
'message_welcome': 'Welcome'
en: {
message_hello: 'Hello World',
message_welcome: 'Welcome'
},
'hi': 'i18n/messages-hi.json', // Messages for Hindi
'de': 'i18n/messages-de.json'
hi: 'i18n/messages-hi.json', // Messages for Hindi
de: 'i18n/messages-de.json'
} );
```

Messages for a locale can be also loaded in parts. Example

```javascript
$.i18n().load( {
'en': {
'message_hello': 'Hello World',
'message_welcome': 'Welcome'
en: {
message_hello: 'Hello World',
message_welcome: 'Welcome'
}
} );

$.i18n().load( {
// This does not remove the previous messages.
'en': {
en: {
'message_header' : 'Header',
'message_footer' : 'Footer',
// This will overwrite message_welcome message
Expand Down Expand Up @@ -354,6 +354,15 @@ $.i18n().locale = 'hy'; // Switch to locale Armenian
$.i18n(message, 'Մաունա'); // This gives "Մաունայի"
```

## Directionality-safe isolation

To avoid BIDI corruption that looks like "(Foo_(Bar", which happens when a string is inserted into a context with the reverse directionality, you can use `{{bidi:…}}`. Directionality-neutral characters at the edge of the string can get wrongly interpreted by the BIDI algorithm. This would let you embed your substituted string into a new BIDI context, //e.g.//:

"`Shalom, {{bidi:$1}}, hi!`"

The embedded context's directionality is determined by looking at the argument for `$1`, and then explicitly inserted into the Unicode text, ensuring correct rendering (because then the bidi algorithm "knows" the argument text is a separate context).


Fallback
========

Expand Down Expand Up @@ -420,4 +429,4 @@ Example qqq.json:

```

In MediaWiki and its hundreds of extension, message documentation is a practice strictly followed. There is a grunt task to check whether all messages are documented or not. See https://www.npmjs.org/package/grunt-banana-checker
In MediaWiki and its hundreds of extensions, message documentation is a strictly followed practice. There is a grunt task to check whether all messages are documented or not. See https://www.npmjs.org/package/grunt-banana-checker
27 changes: 10 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery.i18n",
"version": "1.0.2",
"version": "1.0.3",
"description": "jQuery based internationalization library",
"homepage": "https://github.com/wikimedia/jquery.i18n",
"keywords": [
Expand All @@ -17,16 +17,18 @@
"contributors": [
"Amir Aharoni <[email protected]>",
"Niklas Laxström <[email protected]>",
"Neil Kandalgaonkar <[email protected]>"
"Neil Kandalgaonkar <[email protected]>",
"David Chan <[email protected]>"
],
"devDependencies": {
"qunit": "0.7.4",
"qunit": "0.7.6",
"grunt": "0.4.5",
"grunt-cli": "0.1.13",
"grunt-contrib-jshint": "0.10.0",
"grunt-contrib-connect": "0.8.0",
"grunt-contrib-qunit": "0.5.2",
"grunt-contrib-watch": "0.5.1"
"grunt-contrib-jshint": "0.11.2",
"grunt-contrib-connect": "0.10.1",
"grunt-contrib-qunit": "0.7.0",
"grunt-contrib-watch": "0.6.1",
"grunt-jscs": "1.8.0"
},
"repository": {
"type": "git",
Expand All @@ -38,16 +40,7 @@
"engine": {
"node": ">=0.8.x"
},
"licenses": [
{
"type": "GPL",
"url": "https://github.com/wikimedia/jquery.i18n/blob/master/GPL-LICENSE"
},
{
"type": "MIT",
"url": "https://github.com/wikimedia/jquery.i18n/blob/master/MIT-LICENSE"
}
],
"license": "(MIT OR GPL-2.0)",
"scripts": {
"test": "grunt test --verbose"
}
Expand Down
Loading

0 comments on commit 8e84755

Please sign in to comment.