grunt-i18n-abide
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -13,3 +13,3 @@ /* | ||
var projectLocales = ['en_US', 'fr', 'es']; | ||
var projectLanguages = ['en-US', 'fr', 'es']; | ||
@@ -111,3 +111,3 @@ // Project configuration. | ||
template: 'tests/tmp/messages.pot', | ||
locales: projectLocales, | ||
languages: projectLanguages, | ||
localeDir: 'tests/tmp', | ||
@@ -118,3 +118,3 @@ } | ||
options: { | ||
locales: projectLocales, | ||
languages: projectLanguages, | ||
template: 'tests/tmp/noexist.pot', | ||
@@ -125,3 +125,3 @@ } | ||
options: { | ||
locales: projectLocales, | ||
languages: projectLanguages, | ||
template: 'tests/tmp/messages.pot', | ||
@@ -128,0 +128,0 @@ cmd: 'tests/bin/whatevs.sh', |
{ | ||
"name": "grunt-i18n-abide", | ||
"description": "Grunt plugin for running jsxgettext against your codebase.", | ||
"version": "0.0.4", | ||
"homepage": "https://github.com/muffinresearch/grunt-i18n-abide", | ||
"version": "0.0.5", | ||
"homepage": "https://github.com/mozilla/grunt-i18n-abide", | ||
"author": { | ||
@@ -13,6 +13,6 @@ "name": "Stuart Colville", | ||
"type": "git", | ||
"url": "git://github.com/muffinresearch/grunt-i18n-abide.git" | ||
"url": "git://github.com/mozilla/grunt-i18n-abide.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/muffinresearch/grunt-i18n-abide/issues" | ||
"url": "https://github.com/mozilla/grunt-i18n-abide/issues" | ||
}, | ||
@@ -19,0 +19,0 @@ "licenses": [ |
@@ -1,4 +0,4 @@ | ||
[![Build Status](https://travis-ci.org/muffinresearch/grunt-i18n-abide.png?branch=master)](https://travis-ci.org/muffinresearch/grunt-i18n-abide) | ||
[![Build Status](https://travis-ci.org/mozilla/grunt-i18n-abide.png?branch=master)](https://travis-ci.org/mozilla/grunt-i18n-abide) | ||
[![NPM version](https://badge.fury.io/js/grunt-i18n-abide.png)](http://badge.fury.io/js/grunt-i18n-abide) | ||
[![Dependency Status](https://david-dm.org/muffinresearch/grunt-i18n-abide.png?theme=shields.io)](https://david-dm.org/muffinresearch/grunt-i18n-abide) | ||
[![Dependency Status](https://david-dm.org/mozilla/grunt-i18n-abide.png?theme=shields.io)](https://david-dm.org/mozilla/grunt-i18n-abide) | ||
@@ -98,3 +98,3 @@ | ||
template: 'locale/templates/LC_MESSAGES/messages.pot', // (default: 'locale/templates/LC_MESSAGES/messages.pot') | ||
locales: ['en_US', 'fr', 'es'], | ||
languages: ['en-US', 'fr', 'es'], | ||
localeDir: 'locale', | ||
@@ -114,6 +114,6 @@ } | ||
#### options.locales | ||
#### options.languages | ||
Type: `Array` | ||
A list of the locales you want to create. | ||
A list of the language codes you want to create locales for e.g. en-US not en_US. | ||
@@ -216,3 +216,3 @@ #### options.template | ||
template: 'locale/templates/LC_MESSAGES/messages.pot', // (default: 'locale/templates/LC_MESSAGES/messages.pot') | ||
locales: locales, | ||
languages: ['en-US', 'fr', 'es'], | ||
localeDir: 'locale', | ||
@@ -271,2 +271,7 @@ } | ||
* 0.0.5: | ||
* options.locales -> options.languages in abideCreate | ||
* fix dir creation. | ||
* Move npm images to mozilla repo. | ||
* Update package.json | ||
* 0.0.4: Updated deps. | ||
@@ -273,0 +278,0 @@ * 0.0.3: Updated for initial npm release. |
@@ -25,10 +25,14 @@ var path = require('path'); | ||
var locales = options.locales || []; | ||
if (locales.length === 0) { | ||
grunt.fail.fatal('A list of locales needs to be specified.'); | ||
var languages = options.languages || []; | ||
if (languages.length === 0) { | ||
grunt.fail.fatal('A list of languages needs to be specified.'); | ||
} | ||
locales.forEach(function(locale) { | ||
languages.forEach(function(language) { | ||
// en-US -> en_US | ||
var locale = helpers.localeFrom(language); | ||
// Make the dir for the locale. | ||
var args = []; | ||
var outputFile = path.join(baseLocaleDir, locale, 'LC_MESSAGES/messages.po'); | ||
@@ -35,0 +39,0 @@ var cmd = options.cmd || 'msginit'; |
@@ -0,1 +1,3 @@ | ||
var util = require('util'); | ||
var shell = require('shelljs'); | ||
@@ -22,1 +24,33 @@ var grunt = require('grunt'); | ||
}; | ||
/** | ||
* Given a language code, return a locale code the OS understands. | ||
* Based on from: 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; | ||
} | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32965
720
277