Skip to content

Commit

Permalink
Internal: Improved the translations:collect script to reuse the same …
Browse files Browse the repository at this point in the history
…function inside (external/) the CKEditor 5 repository.
  • Loading branch information
pomek committed Jul 17, 2023
1 parent 03feb37 commit cc7f05a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
14 changes: 12 additions & 2 deletions scripts/translations/collect.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

/* eslint-env node */

const upath = require( 'upath' );
const { createPotFiles } = require( '@ckeditor/ckeditor5-dev-transifex' );
const {
TRANSLATION_DIRECTORY_PATH,
Expand All @@ -14,6 +15,8 @@ const {
normalizePath
} = require( './utils' );

const CKEDITOR5_ROOT_PATH = upath.join( __dirname, '..', '..' );

main();

function main() {
Expand All @@ -27,9 +30,16 @@ function main() {
packagePaths: getCKEditor5PackagePaths( options ),

// A relative path to the `@ckeditor/ckeditor5-core` package where common translations are located.
corePackagePath: 'packages/ckeditor5-core',
corePackagePath: upath.relative(
options.cwd,
upath.join( CKEDITOR5_ROOT_PATH, 'packages', 'ckeditor5-core' )
),

// Where to save translation files.
translationsDirectory: normalizePath( options.cwd, TRANSLATION_DIRECTORY_PATH )
translationsDirectory: normalizePath( options.cwd, TRANSLATION_DIRECTORY_PATH ),

// Whether to hide unused context errors from the `@ckeditor/ckeditor5-core` package.
// Required when only some of the common translations are used.
ignoreUnusedCorePackageContexts: options.ignoreUnusedCorePackageContexts
} );
}
10 changes: 8 additions & 2 deletions scripts/translations/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ function parseArguments( args ) {
],

boolean: [
'include-external-directory'
'include-external-directory',
'ignore-unused-core-package-contexts'
],

default: {
cwd: process.cwd(),
packages: [],
ignore: [],
'include-external-directory': false
'include-external-directory': false,
'ignore-unused-core-package-contexts': false
}
};

Expand All @@ -52,6 +54,8 @@ function parseArguments( args ) {
// Convert to camelCase.
options.includeExternalDirectory = options[ 'include-external-directory' ];
delete options[ 'include-external-directory' ];
options.ignoreUnusedCorePackageContexts = options[ 'ignore-unused-core-package-contexts' ];
delete options[ 'ignore-unused-core-package-contexts' ];

// Normalize the current work directory path.
options.cwd = normalizePath( path.resolve( options.cwd ) );
Expand Down Expand Up @@ -182,6 +186,8 @@ function normalizePath( ...values ) {
* @property {Array.<String>} [ignore] Name of packages that should be skipped while processing then.
*
* @property {Boolean} includeExternalDirectory Whether to look for packages located in the `external/` directory.
*
* @property {Boolean} ignoreUnusedCorePackageContexts Whether to allow having unused contexts by the `ckeditor5-core` package.
*/

/**
Expand Down

0 comments on commit cc7f05a

Please sign in to comment.