grunt-i18n-abide
Advanced tools
Comparing version 0.0.9 to 0.0.10
{ | ||
"name": "grunt-i18n-abide", | ||
"description": "Grunt plugin for running jsxgettext against your codebase.", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"homepage": "https://github.com/mozilla/grunt-i18n-abide", | ||
@@ -32,11 +32,12 @@ "author": { | ||
"dependencies": { | ||
"jsxgettext": "~0.3.9", | ||
"shelljs": "~0.2.6", | ||
"po2json": "~0.2.3" | ||
"i18n-abide": "0.0.19", | ||
"jsxgettext": "0.4.3", | ||
"po2json": "0.2.3", | ||
"shelljs": "0.3.0" | ||
}, | ||
"devDependencies": { | ||
"grunt-contrib-jshint": "~0.6.0", | ||
"grunt": "~0.4.5", | ||
"grunt-contrib-clean": "~0.4.0", | ||
"grunt-contrib-nodeunit": "~0.2.0", | ||
"grunt": "~0.4.1" | ||
"grunt-contrib-jshint": "~0.10.0", | ||
"grunt-contrib-nodeunit": "~0.3.3" | ||
}, | ||
@@ -47,8 +48,9 @@ "peerDependencies": { | ||
"keywords": [ | ||
"gettext", | ||
"grunt", | ||
"gruntplugin", | ||
"l10n", | ||
"i18n", | ||
"i18n-abide", | ||
"gettext" | ||
"l10n" | ||
] | ||
} |
@@ -1,4 +0,4 @@ | ||
[](https://travis-ci.org/mozilla/grunt-i18n-abide) | ||
[](http://badge.fury.io/js/grunt-i18n-abide) | ||
[](https://david-dm.org/mozilla/grunt-i18n-abide) | ||
[](https://travis-ci.org/mozilla/grunt-i18n-abide) | ||
[](http://badge.fury.io/js/grunt-i18n-abide) | ||
[](https://david-dm.org/mozilla/grunt-i18n-abide) | ||
@@ -285,2 +285,8 @@ | ||
* 0.0.10: | ||
* Use localeFrom and languageFrom from i18n-abide. | ||
* Update jsxgettext 0.4.0 -> 0.4.2 | ||
* Update i18n-abide 0.0.17 -> 0.0.19 | ||
* Update shelljs 0.2.6 -> 0.3.0 | ||
* Update dev deps. | ||
* 0.0.9: | ||
@@ -287,0 +293,0 @@ * Use pretty json for readability. |
var fs = require('fs'); | ||
var path = require('path'); | ||
var lockFilePath = '/tmp/abideCompile.lock'; | ||
var po2json = require('po2json'); | ||
var shell = require('shelljs'); | ||
var i18n = require('i18n-abide'); | ||
var helpers = require('./lib/helpers'); | ||
var po2json = require('po2json'); | ||
var lockFilePath = '/tmp/abideCompile.lock'; | ||
var runShellSync = helpers.runShellSync; | ||
@@ -75,3 +78,3 @@ var checkCommand = helpers.checkCommand; | ||
fs.writeFileSync(jsfile, '"locale": "' + locale + '",\n', { flag: 'a' }); | ||
fs.writeFileSync(jsfile, '"lang": "' + helpers.languageFrom(locale) + '"\n}', { flag: 'a' }); | ||
fs.writeFileSync(jsfile, '"lang": "' + i18n.languageFrom(locale) + '"\n}', { flag: 'a' }); | ||
} | ||
@@ -78,0 +81,0 @@ }); |
var fs = require('fs'); | ||
var path = require('path'); | ||
var i18n = require('i18n-abide'); | ||
var helpers = require('./lib/helpers'); | ||
@@ -33,3 +35,3 @@ | ||
// en-US -> en_US | ||
var locale = helpers.localeFrom(language); | ||
var locale = i18n.localeFrom(language); | ||
@@ -36,0 +38,0 @@ // Make the dir for the locale. |
@@ -24,56 +24,1 @@ var util = require('util'); | ||
}; | ||
/** | ||
* Given a language code, return a locale code the OS understands. | ||
* Based on: https://github.com/mozilla/i18n-abide/blob/master/lib/i18n.js | ||
* | ||
* language: en-US | ||
* locale: en_US | ||
*/ | ||
exports.localeFrom = function(language) { | ||
if (! language || ! language.split) { | ||
return ""; | ||
} | ||
if (language.indexOf('_') > -1) { | ||
grunt.log.writeln(util.format("Check this is a language code. Language [%s] already contains a '_'", language)); | ||
return language; | ||
} | ||
var parts = language.split('-'); | ||
if (parts.length === 1) { | ||
return parts[0].toLowerCase(); | ||
} else if (parts.length === 2) { | ||
return util.format('%s_%s', parts[0].toLowerCase(), parts[1].toUpperCase()); | ||
} else if (parts.length === 3) { | ||
// sr-Cyrl-RS should be sr_RS | ||
return util.format('%s_%s', parts[0].toLowerCase(), parts[2].toUpperCase()); | ||
} else { | ||
grunt.log.writeln(util.format("Unable to map a locale from language code [%s]", language)); | ||
return language; | ||
} | ||
}; | ||
/** | ||
* Given a locale code, return a language code | ||
* Based on: https://github.com/mozilla/i18n-abide/blob/master/lib/i18n.js | ||
*/ | ||
exports.languageFrom = function languageFrom(locale) { | ||
if (!locale || !locale.split) { | ||
return ""; | ||
} | ||
var parts = locale.split('_'); | ||
if (parts.length === 1) { | ||
return parts[0].toLowerCase(); | ||
} else if (parts.length === 2) { | ||
return util.format('%s-%s', parts[0].toLowerCase(), parts[1].toUpperCase()); | ||
} else if (parts.length === 3) { | ||
// sr_RS should be sr-RS | ||
return util.format('%s-%s', parts[0].toLowerCase(), parts[2].toUpperCase()); | ||
} else { | ||
grunt.log.writeln(util.format("Unable to map a language from locale code [%s]", locale)); | ||
return locale; | ||
} | ||
}; |
315
38523
5
840
+ Addedi18n-abide@0.0.19
+ Addedacorn@0.5.0(transitive)
+ Addedasync@0.2.10(transitive)
+ Addedcamelcase@1.2.1(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addedi18n-abide@0.0.19(transitive)
+ Addedjsxgettext@0.3.90.4.3(transitive)
+ Addedminimist@0.0.10(transitive)
+ Addedoptimist@0.3.40.6.1(transitive)
+ Addedplist@0.4.3(transitive)
+ Addedshelljs@0.3.0(transitive)
+ Addedsource-map@0.1.34(transitive)
+ Addedswig@1.3.2(transitive)
+ Addeduglify-js@2.4.24(transitive)
+ Addeduglify-to-browserify@1.0.2(transitive)
+ Addedwindow-size@0.1.0(transitive)
+ Addedwordwrap@0.0.2(transitive)
+ Addedxmlbuilder@0.4.3(transitive)
+ Addedxmldom@0.1.31(transitive)
+ Addedyargs@3.5.4(transitive)
- Removedjsxgettext@0.3.10(transitive)
- Removedshelljs@0.2.6(transitive)
Updatedjsxgettext@0.4.3
Updatedpo2json@0.2.3
Updatedshelljs@0.3.0