Skip to content

Commit

Permalink
@mister-ben added task to maintain translations. closes #3572
Browse files Browse the repository at this point in the history
  • Loading branch information
mister-ben authored and gkatsev committed Aug 25, 2016
1 parent 0b10b69 commit 94f22bb
Show file tree
Hide file tree
Showing 6 changed files with 424 additions and 1 deletion.
35 changes: 35 additions & 0 deletions build/tasks/languages.js
@@ -0,0 +1,35 @@
module.exports = function(grunt) {
grunt.registerTask('check-translations', 'Check that translations are up to date', function(){
const source = require('../../lang/en.json');
const table = require('markdown-table');
let doc = grunt.file.read('docs/translations-needed.md');
const tableRegex = /(<!-- START langtable -->)(.|\n)*(<!-- END langtable -->)/;
let tableData = [['Language file', 'Missing translations']];

grunt.file.recurse('lang', (abspath, rootdir, subdir, filename) => {
if (filename === 'en.json') {
return;
}
const target = require(`../../${abspath}`);
let missing = [];
for (const string in source) {
if (!target[string]) {
grunt.log.writeln(`${filename} missing "${string}"`);
missing.push(string);
}
}
if (missing.length > 0) {
grunt.log.error(`${filename} is missing ${missing.length} translations.`);
tableData.push([`${filename} (missing ${missing.length})`, missing[0]]);
for (var i = 1; i < missing.length; i++) {
tableData.push(['', missing[i]]);
}
} else {
grunt.log.ok(`${filename} is up to date.`);
tableData.push([`${filename} (Complete)`, '']);
}
});
doc = doc.replace(tableRegex, `$1\n` + table(tableData) + `\n$3`);
grunt.file.write('docs/translations-needed.md', doc);
});
};
4 changes: 4 additions & 0 deletions docs/guides/languages.md
Expand Up @@ -110,6 +110,10 @@ NOTE: These need to be added after the core Video.js script.
Notes:
- This will add your language key/values to the Video.js player instances individually. If these values already exist in the global dictionary via the process above, those will be overridden for the player instance in question.

Updating default translations
-----------------------------

A list of the current translations and any strings that need translation are at [docs/translations-needed.md](../translations-needed.md). After updating the language files in /lang/ running `grunt check-languages` will update that list.

Setting Default Language in a Video.js Player
---------------------------------------------
Expand Down

0 comments on commit 94f22bb

Please sign in to comment.