rename 'langpacks' to 'i18njs' (bug 1134670)

This commit is contained in:
Allen Short 2016-03-08 09:55:18 -06:00
Родитель 17c0d59bf9
Коммит a01ad27d26
4 изменённых файлов: 30 добавлений и 29 удалений

Просмотреть файл

@ -7,7 +7,7 @@ function help() {
'',
'Commands:',
' extract_strings This command will extract strings into a `.pot` file.',
' langpacks This command will generate langpacks out of `.po` files.',
' i18njs This command will generate translations out of `.po` files.',
'',
'Read more: https://github.com/mozilla/commonplace/wiki/CLI-Tools'
].join('\n'));
@ -38,7 +38,8 @@ switch (argv[0]) {
console.log('This command has been removed. Use `make build` instead.');
break;
case 'langpacks':
commonplace.generate_langpacks();
case 'i18njs':
commonplace.generate_i18njs();
break;
case 'lint':
console.log('This command has been removed. Use `make lint` instead.');

Просмотреть файл

@ -10,15 +10,15 @@ var srcDir = function(cwd) {
};
function generate_langpacks() {
var process_file = require('./generate_langpacks').process_file;
function generate_i18njs() {
var process_file = require('./generate_i18njs').process_file;
var src_dir = srcDir();
var langpacks_path = path.resolve(src_dir, 'media', 'locales');
var i18njs_path = path.resolve(src_dir, 'media', 'locales');
if (!fs.existsSync(langpacks_path)) {
console.log('Language packs do not exist. Creating: ' + langpacks_path);
fs.mkdirSync(langpacks_path);
if (!fs.existsSync(i18njs_path)) {
console.log('Translation files do not exist. Creating: ' + i18njs_path);
fs.mkdirSync(i18njs_path);
}
var count = 0;
@ -41,10 +41,10 @@ function generate_langpacks() {
}
locale = locale.join('-');
process_file(filepath, locale, path.resolve(langpacks_path, locale + '.js'));
process_file(filepath, locale, path.resolve(i18njs_path, locale + '.js'));
count++;
}, function() {
console.log('Finished generating ' + count + ' language packs.');
console.log('Finished generating ' + count + ' translation files.');
});
}
@ -134,7 +134,7 @@ function extract_l10n() {
}
module.exports.generate_langpacks = generate_langpacks;
module.exports.generate_i18njs = generate_i18njs;
module.exports.extract_l10n = extract_l10n;
module.exports.config = require('./config');

Просмотреть файл

@ -1,5 +1,5 @@
/*
Parses .po file, outputting a JS langpack.
Parses .po file, outputting a JS translation file..
Will output {'My String': 'El String'} for simple non-plural localizations.
@ -64,7 +64,7 @@ function parse(po_content) {
if (hasResult && hasResultPlural && notIdentical &&
notIdenticalPlural) {
// Set the string in our langpack if all conditions pass.
// Set the string in our translation if all conditions pass.
output[id] = currentLocalizedResult;
}
} else {
@ -169,7 +169,7 @@ function process_file(path, lang, dest_path, callback) {
var data = fs.readFileSync(path);
fs.readFile(path, function(err, data) {
if (err) {
console.error('Unable to read language pack: ' + path, err);
console.error('Unable to read translation file: ' + path, err);
return;
}
@ -177,7 +177,7 @@ function process_file(path, lang, dest_path, callback) {
if (dest_path) {
fs.writeFile(dest_path, compiled, function(err) {
if (err) {
console.error('Unable to write language pack to: ' + dest_path, err);
console.error('Unable to write translation file to: ' + dest_path, err);
}
if (callback) {
callback(err);

Просмотреть файл

@ -1,6 +1,6 @@
var assert = require('assert');
var langpacks = require('../lib/generate_langpacks').process_file;
var i18njs = require('../lib/generate_i18njs').process_file;
beforeEach(function() {
@ -8,9 +8,9 @@ beforeEach(function() {
});
describe('generate_langpacks', function() {
describe('generate_i18njs', function() {
it('sets navigator.l10n.language', function(done) {
langpacks('test/messages.po', 'es', null, function(err, data) {
i18njs('test/messages.po', 'es', null, function(err, data) {
eval(data);
assert.equal(navigator.l10n.language, 'es');
done();
@ -18,7 +18,7 @@ describe('generate_langpacks', function() {
});
it('sets localized string', function(done) {
langpacks('test/messages.po', 'es', null, function(err, data) {
i18njs('test/messages.po', 'es', null, function(err, data) {
eval(data);
assert.equal(navigator.l10n.strings['My String'],
'El String');
@ -27,7 +27,7 @@ describe('generate_langpacks', function() {
});
it('sets plural string', function(done) {
langpacks('test/messages.po', 'es', null, function(err, data) {
i18njs('test/messages.po', 'es', null, function(err, data) {
eval(data);
assert.deepEqual(navigator.l10n.strings['Result'],
['Resulto', 'N Resultos']);
@ -36,7 +36,7 @@ describe('generate_langpacks', function() {
});
it('sets plural string with three forms', function(done) {
langpacks('test/messages.po', 'es', null, function(err, data) {
i18njs('test/messages.po', 'es', null, function(err, data) {
eval(data);
assert.deepEqual(navigator.l10n.strings['Triple Result'],
['Un Resulto', 'Dos Resultos', 'Resultos']);
@ -45,7 +45,7 @@ describe('generate_langpacks', function() {
});
it('sets partially localized plural string', function(done) {
langpacks('test/messages.po', 'es', null, function(err, data) {
i18njs('test/messages.po', 'es', null, function(err, data) {
eval(data);
assert.deepEqual(
navigator.l10n.strings['Partially Localized Plural String'],
@ -55,7 +55,7 @@ describe('generate_langpacks', function() {
});
it('sets partially identical plural strings', function(done) {
langpacks('test/messages.po', 'es', null, function(err, data) {
i18njs('test/messages.po', 'es', null, function(err, data) {
eval(data);
assert.ok('Partially Identical Plural String' in navigator.l10n.strings);
assert.deepEqual(
@ -68,7 +68,7 @@ describe('generate_langpacks', function() {
});
it('sets no plural form string', function(done) {
langpacks('test/messages.po', 'es', null, function(err, data) {
i18njs('test/messages.po', 'es', null, function(err, data) {
eval(data);
assert.deepEqual(
navigator.l10n.strings['No Plural Form String'], 'NPFS');
@ -77,7 +77,7 @@ describe('generate_langpacks', function() {
});
it('does not set non-localized string', function(done) {
langpacks('test/messages.po', 'es', null, function(err, data) {
i18njs('test/messages.po', 'es', null, function(err, data) {
eval(data);
assert.ok(!('My Non-Localized String' in navigator.l10n.strings));
done();
@ -85,7 +85,7 @@ describe('generate_langpacks', function() {
});
it('does not set non-localized plural string', function(done) {
langpacks('test/messages.po', 'es', null, function(err, data) {
i18njs('test/messages.po', 'es', null, function(err, data) {
eval(data);
assert.ok(!('Non-Localized Result' in navigator.l10n.strings));
done();
@ -93,7 +93,7 @@ describe('generate_langpacks', function() {
});
it('does not set identical string', function(done) {
langpacks('test/messages.po', 'es', null, function(err, data) {
i18njs('test/messages.po', 'es', null, function(err, data) {
eval(data);
assert.ok(!('Identical String' in navigator.l10n.strings));
done();
@ -101,7 +101,7 @@ describe('generate_langpacks', function() {
});
it('does not set identical plural string', function(done) {
langpacks('test/messages.po', 'es', null, function(err, data) {
i18njs('test/messages.po', 'es', null, function(err, data) {
eval(data);
assert.ok(!('Identical Plural String' in navigator.l10n.strings));
done();
@ -109,7 +109,7 @@ describe('generate_langpacks', function() {
});
it('sets pluralizer', function(done) {
langpacks('test/messages.po', 'es', null, function(err, data) {
i18njs('test/messages.po', 'es', null, function(err, data) {
assert.ok(!navigator.l10n);
eval(data);
assert.equal(navigator.l10n.pluralize.toString(),