UNPKG

1.4 kBJavaScriptView Raw
1#!/usr/bin/env node
2
3/**
4 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
5 * For licensing, see LICENSE.md.
6 */
7
8'use strict';
9
10const chalk = require( 'chalk' );
11
12const task = process.argv[ 2 ];
13
14const tasks = {
15 /**
16 * Collects translation strings ( from `t()` calls ) and stores them in ckeditor5/build/.transifex directory.
17 */
18 collect() {
19 const collectTranslations = require( './../lib/translations/collect' );
20
21 collectTranslations();
22 },
23
24 /**
25 * Uploads translation strings on the Transifex server.
26 *
27 * @returns {Promise}
28 */
29 upload() {
30 const uploadTranslations = require( './../lib/translations/upload' );
31 const getToken = require( './../lib/translations/gettoken' );
32
33 return getToken()
34 .then( credentials => uploadTranslations( credentials ) );
35 },
36
37 /**
38 * Download translations from the Transifex server.
39 *
40 * @returns {Promise}
41 */
42 download() {
43 const downloadTranslations = require( './../lib/translations/download' );
44 const getToken = require( './../lib/translations/gettoken' );
45
46 return getToken()
47 .then( credentials => downloadTranslations( credentials ) );
48 }
49};
50
51const taskNames = Object.keys( tasks );
52
53if ( !task || !tasks[ task ] ) {
54 console.log( `Please provide valid task name. Available tasks: ${ taskNames.map( task => chalk.bold( task ) ).join( ', ' ) }.` );
55
56 process.exit( 1 );
57}
58
59tasks[ task ]();