@@ -21,14 +21,9 @@ const flat = require('flat');
2121const { argv } = require ( 'yargs' ) ;
2222const os = require ( 'os' ) ;
2323const rmrf = require ( 'rimraf' ) ;
24- const nls = require ( 'vscode-nls-dev' ) ;
25- const sourcemaps = require ( 'gulp-sourcemaps' ) ;
2624const typescript = require ( 'typescript' ) ;
27- const es = require ( 'event-stream' ) ;
28- const minimist = require ( 'minimist' ) ;
2925
3026const tsProject = ts . createProject ( './tsconfig.json' , { typescript } ) ;
31- const filter = require ( 'gulp-filter' ) ;
3227
3328const isCI = process . env . TRAVIS === 'true' || process . env . TF_BUILD !== undefined ;
3429
@@ -360,122 +355,3 @@ function hasNativeDependencies() {
360355 }
361356 return false ;
362357}
363-
364- const translationProjectName = 'ms-python.python' ;
365- const translationExtensionName = 'vscode-python' ;
366-
367- const defaultLanguages = [
368- { id : 'de' , folderName : 'de' } ,
369- { id : 'fr' , folderName : 'fr' } ,
370- { id : 'es' , folderName : 'es' } ,
371- { id : 'cs' , folderName : 'cs' } ,
372- { id : 'it' , folderName : 'it' } ,
373- { id : 'ja' , folderName : 'ja' } ,
374- { id : 'ko' , folderName : 'ko' } ,
375- { id : 'pl' , folderName : 'pl' } ,
376- { id : 'pt-BR' , folderName : 'pt-br' } ,
377- { id : 'ru' , folderName : 'ru' } ,
378- { id : 'tr' , folderName : 'tr' } ,
379- { id : 'zh-Hans' , folderName : 'zh-Hans' } ,
380- { id : 'zh-Hant' , folderName : 'zh-Hant' } ,
381- { id : 'qps-ploc' , folderName : 'qps-ploc' } ,
382- ] ;
383-
384- // You can find a more complex implementation of the translations in the CPP Extension repository.
385- // See: https://github.com/microsoft/vscode-cpptools/blob/main/Extension/gulpfile.js#L76
386-
387- // ****************************
388- // Command: translations-generate
389- // The following is used to import an i18n directory structure and generate files used at runtime.
390- // ****************************
391-
392- // Generate package.nls.*.json files from: ./i18n/*/package.i18n.json
393- // Outputs to root path, as these nls files need to be along side package.json
394-
395- const generateAdditionalLocFiles = ( ) =>
396- gulp
397- . src ( [ 'package.nls.json' ] )
398- . pipe ( nls . createAdditionalLanguageFiles ( defaultLanguages , 'i18n' ) )
399- . pipe ( gulp . dest ( '.' ) ) ;
400-
401- // Generates ./out/nls.bundle.<language_id>.json from files in ./i18n/** *//<src_path>/<filename>.i18n.json
402- // Localized strings are read from these files at runtime.
403- const generateSrcLocBundle = ( ) =>
404- // Transpile the TS to JS, and let vscode-nls-dev scan the files for calls to localize.
405- tsProject
406- . src ( )
407- . pipe ( sourcemaps . init ( ) )
408- . pipe ( tsProject ( ) )
409- . js . pipe ( nls . createMetaDataFiles ( ) )
410- . pipe ( nls . createAdditionalLanguageFiles ( defaultLanguages , 'i18n' ) )
411- . pipe ( nls . bundleMetaDataFiles ( 'ms-vscode.python' , 'out' ) )
412- . pipe ( nls . bundleLanguageFiles ( ) )
413- . pipe ( filter ( [ '**/nls.bundle.*.json' , '**/nls.metadata.header.json' , '**/nls.metadata.json' ] ) )
414- . pipe ( gulp . dest ( 'out' ) ) ;
415-
416- gulp . task ( 'translations-generate' , gulp . series ( generateSrcLocBundle , generateAdditionalLocFiles ) ) ;
417-
418- // ****************************
419- // Command: translations-export
420- // The following is used to export and XLF file containing english strings for translations.
421- // The result will be written to: ../vscode-extensions-localization-export/ms-vscode/
422- // ****************************
423- const exportTranslations = ( done ) => {
424- const jsStream = tsProject . src ( ) . pipe ( sourcemaps . init ( ) ) . pipe ( tsProject ( ) ) . js . pipe ( nls . createMetaDataFiles ( ) ) ;
425-
426- // Merge files from all source streams
427- jsStream
428-
429- // Filter down to only the files we need
430- . pipe ( filter ( [ '**/*.nls.json' , '**/*.nls.metadata.json' ] ) )
431-
432- // Consoldate them into nls.metadata.json, which the xlf is built from.
433- . pipe ( nls . bundleMetaDataFiles ( 'ms-vscode.python' , '.' ) )
434-
435- // filter down to just the resulting metadata files
436- . pipe ( filter ( [ '**/nls.metadata.header.json' , '**/nls.metadata.json' ] ) )
437-
438- // Add package.nls.json, used to localized package.json
439- . pipe ( gulp . src ( [ 'package.nls.json' ] ) )
440-
441- // package.nls.json and nls.metadata.json are used to generate the xlf file
442- // Does not re-queue any files to the stream. Outputs only the XLF file
443- . pipe ( nls . createXlfFiles ( translationProjectName , translationExtensionName ) )
444- . pipe ( gulp . dest ( '../' ) )
445- . pipe (
446- es . wait ( ( ) => {
447- done ( ) ;
448- } ) ,
449- ) ;
450- } ;
451-
452- gulp . task ( 'translations-export' , exportTranslations ) ;
453-
454- // ****************************
455- // Command: translations-import
456- // The following is used to import an XLF file containing all language strings.
457- // This results in a i18n directory, which should be checked in.
458- // ****************************
459-
460- // Imports translations from raw localized MLCP strings to VS Code .i18n.json files
461- gulp . task ( 'translations-import' , ( done ) => {
462- const options = minimist ( process . argv . slice ( 2 ) , {
463- string : 'location' ,
464- default : {
465- location : '../vscode-translations-import' ,
466- } ,
467- } ) ;
468- es . merge (
469- defaultLanguages . map ( ( language ) => {
470- const id = language . transifexId || language . id ;
471- return gulp
472- . src ( path . join ( options . location , id , `${ translationExtensionName } .xlf` ) )
473- . pipe ( nls . prepareJsonFiles ( ) )
474- . pipe ( gulp . dest ( path . join ( './i18n' , language . folderName ) ) ) ;
475- } ) ,
476- ) . pipe (
477- es . wait ( ( ) => {
478- done ( ) ;
479- } ) ,
480- ) ;
481- } ) ;
0 commit comments