Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.
*/
'use strict';
const del = require( 'del' );
const glob = require( 'glob' );
const fs = require( 'fs-extra' );
const path = require( 'path' );
const logger = require( '@ckeditor/ckeditor5-dev-utils' ).logger();
const { findOriginalStrings } = require( '@ckeditor/ckeditor5-dev-utils' ).translations;
const langContextSuffix = path.join( 'lang', 'contexts.json' );
const corePackageName = 'ckeditor5-core';
const utils = {
/**
* Collect translations and return array of translations.
*
* @returns {Array.}
*/
collectTranslations() {
const srcPaths = [ process.cwd(), 'packages', '*', 'src', '**', '*.js' ].join( '/' );
const files = glob.sync( srcPaths )
.filter( srcPath => !srcPath.match( /packages\/[^/]+\/src\/lib\// ) );
/**
* @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.
*/
'use strict';
const path = require( 'path' );
const { TranslationService } = require( '@ckeditor/ckeditor5-dev-utils' ).translations;
/**
* Replaces all function call parameters with translated strings for the t function.
*
* @param {Object} compiler Webpack compiler.
* @param {String} language Language code, e.g en_US.
*/
module.exports = function replaceTCalls( compiler, language ) {
const translationService = new TranslationService( language );
compiler.options.translateSource = source => translationService.translateSource( source );
// Adds ckeditor5-core translations before translate-source-loader starts translating.
compiler.plugin( 'after-resolvers', () => {
compiler.resolvers.normal.resolve(
process.cwd(),
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.
*/
'use strict';
const request = require( 'request' );
// In case of debugging requests install and enable following package
// and remove `createJsonResponseHandler` callback from the request arguments.
// See https://github.com/request/request-debug.
// require( 'request-debug' )( request );
const { retryAsyncFunction } = require( '@ckeditor/ckeditor5-dev-utils' ).translations;
const PROJECT_URL = 'https://www.transifex.com/api/2/project/ckeditor5';
/**
* Promise wrappers of the Transifex API.
*
* @see https://docs.transifex.com/api/ for API documentation.
*/
module.exports = {
/**
* Downloads available resources.
*
* @param {Object} config
* @param {String} config.token Token to the Transifex API.
* @returns {Promise.}
*/
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.
*/
'use strict';
const fs = require( 'fs-extra' );
const path = require( 'path' );
const transifexService = require( './transifex-service' );
const logger = require( '@ckeditor/ckeditor5-dev-utils' ).logger();
const { cleanPoFileContent, createDictionaryFromPoFileContent } = require( '@ckeditor/ckeditor5-dev-utils' ).translations;
/**
* Downloads translations from the Transifex for each package and language.
*
* @param {Object} loginConfig
* @param {String} loginConfig.token Token to the Transifex API.
*/
module.exports = function download( loginConfig ) {
return Promise.resolve()
.then( () => getPackageNames( loginConfig ) )
.then( packageNames => downloadAndReplaceTranslations( loginConfig, packageNames ) )
.then( () => {
logger.info( 'Saved all translations.' );
} )
.catch( err => {
logger.error( err );