Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for grunt-videojs-languages #1453

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 19 additions & 25 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: pkg,
lang: {
src: 'lang/*.json'
vjslanguages: {
defaults: {
files: {
'build/files/lang': ['lang/*.json']
}
}
},
build: {
src: 'src/js/dependencies.js',
Expand Down Expand Up @@ -312,6 +316,7 @@ module.exports = function(grunt) {
}
});

grunt.loadNpmTasks('grunt-videojs-languages');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
Expand All @@ -333,11 +338,11 @@ module.exports = function(grunt) {
// grunt.loadTasks('./docs/tasks/');
// grunt.loadTasks('../videojs-doc-generator/tasks/');

grunt.registerTask('pretask', ['jshint', 'less', 'lang', 'build', 'minify', 'usebanner']);
grunt.registerTask('pretask', ['jshint', 'less', 'vjslanguages', 'build', 'minify', 'usebanner']);
// Default task.
grunt.registerTask('default', ['pretask', 'dist']);
// Development watch task
grunt.registerTask('dev', ['jshint', 'less', 'lang', 'build', 'qunit:source']);
grunt.registerTask('dev', ['jshint', 'less', 'vjslanguages', 'build', 'qunit:source']);
grunt.registerTask('test-qunit', ['pretask', 'qunit']);

// The test task will run `karma:saucelabs` when running in travis,
Expand Down Expand Up @@ -424,24 +429,7 @@ module.exports = function(grunt) {
}
});

var fs = require('fs'),
gzip = require('zlib').gzip;

grunt.registerMultiTask('lang', 'Building Language Support', function() {
var combined = '';

grunt.log.writeln('Building Language Support');

// Create a combined languages file
this.files.forEach(function(file) {
file.src.forEach(function(src){
var code = src.replace('lang/', '').replace('.json', '');
combined += 'videojs.options[\'languages\'][\''+code+'\'] = '+ grunt.file.read(src).trim() + ';\n';
});
});

grunt.file.write('build/files/combined.languages.js', combined);
});
var fs = require('fs');

grunt.registerMultiTask('build', 'Building Source', function(){

Expand All @@ -459,9 +447,6 @@ module.exports = function(grunt) {
// Replace CDN version ref in js. Use major/minor version.
combined = combined.replace(/GENERATED_CDN_VSN/g, version.majorMinor);

// Add Combined Langauges
// combined += grunt.file.read('build/files/combined.languages.js');

grunt.file.write('build/files/combined.video.js', combined);

// Copy over other files
Expand Down Expand Up @@ -561,6 +546,15 @@ module.exports = function(grunt) {
}
});

// Copy over language files
grunt.file.recurse('build/files/lang', function(absdir, rootdir, subdir, filename) {
// Block .DS_Store files
if ('filename'.substring(0,1) !== '.') {
grunt.file.copy(absdir, 'dist/cdn/lang/' + filename);
grunt.file.copy(absdir, 'dist/video-js/lang/' + filename);
}
});

// ds_store files sometime find their way in
if (grunt.file.exists('dist/video-js/.DS_Store')) {
grunt.file['delete']('dist/video-js/.DS_Store');
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"semver": "~1.1.4",
"sinon": "~1.9.1",
"uglify-js": "~2.3.6",
"videojs-doc-generator": "0.0.1"
"videojs-doc-generator": "0.0.1",
"grunt-videojs-languages": "0.0.4"
}
}