@@ -36,12 +36,6 @@ exports.extraLanguages = [
3636 { id : 'hu' , folderName : 'hun' } ,
3737 { id : 'tr' , folderName : 'trk' }
3838] ;
39- // non built-in extensions also that are transifex and need to be part of the language packs
40- const externalExtensionsWithTranslations = {
41- 'vscode-chrome-debug' : 'msjsdiag.debugger-for-chrome' ,
42- 'vscode-node-debug' : 'ms-vscode.node-debug' ,
43- 'vscode-node-debug2' : 'ms-vscode.node-debug2'
44- } ;
4539var LocalizeInfo ;
4640( function ( LocalizeInfo ) {
4741 function is ( value ) {
@@ -513,10 +507,10 @@ function createXlfFilesForCoreBundle() {
513507 } ) ;
514508}
515509exports . createXlfFilesForCoreBundle = createXlfFilesForCoreBundle ;
516- function createL10nBundleForExtension ( extensionName ) {
510+ function createL10nBundleForExtension ( extensionFolderName ) {
517511 const result = ( 0 , event_stream_1 . through ) ( ) ;
518512 gulp . src ( [
519- `extensions/${ extensionName } /src/**/*.ts` ,
513+ `extensions/${ extensionFolderName } /src/**/*.ts` ,
520514 ] ) . pipe ( ( 0 , event_stream_1 . writeArray ) ( ( err , files ) => {
521515 if ( err ) {
522516 result . emit ( 'error' , err ) ;
@@ -527,7 +521,7 @@ function createL10nBundleForExtension(extensionName) {
527521 } ) ) ;
528522 if ( Object . keys ( json ) . length > 0 ) {
529523 result . emit ( 'data' , new File ( {
530- path : `${ extensionName } /bundle.l10n.json` ,
524+ path : `extensions/ ${ extensionFolderName } /bundle.l10n.json` ,
531525 contents : Buffer . from ( JSON . stringify ( json ) , 'utf8' )
532526 } ) ) ;
533527 }
@@ -545,10 +539,14 @@ function createXlfFilesForExtensions() {
545539 if ( ! stat . isDirectory ( ) ) {
546540 return ;
547541 }
548- const extensionName = path . basename ( extensionFolder . path ) ;
549- if ( extensionName === 'node_modules' ) {
542+ const extensionFolderName = path . basename ( extensionFolder . path ) ;
543+ if ( extensionFolderName === 'node_modules' ) {
550544 return ;
551545 }
546+ // Get extension id and use that as the id
547+ const manifest = fs . readFileSync ( path . join ( extensionFolder . path , 'package.json' ) , 'utf-8' ) ;
548+ const manifestJson = JSON . parse ( manifest ) ;
549+ const extensionId = manifestJson . publisher + '.' + manifestJson . name ;
552550 counter ++ ;
553551 let _l10nMap ;
554552 function getL10nMap ( ) {
@@ -557,17 +555,17 @@ function createXlfFilesForExtensions() {
557555 }
558556 return _l10nMap ;
559557 }
560- ( 0 , event_stream_1 . merge ) ( gulp . src ( [ `.build/extensions/${ extensionName } /package.nls.json` , `.build/extensions/${ extensionName } /**/nls.metadata.json` ] , { allowEmpty : true } ) , createL10nBundleForExtension ( extensionName ) ) . pipe ( ( 0 , event_stream_1 . through ) ( function ( file ) {
558+ ( 0 , event_stream_1 . merge ) ( gulp . src ( [ `.build/extensions/${ extensionFolderName } /package.nls.json` , `.build/extensions/${ extensionFolderName } /**/nls.metadata.json` ] , { allowEmpty : true } ) , createL10nBundleForExtension ( extensionFolderName ) ) . pipe ( ( 0 , event_stream_1 . through ) ( function ( file ) {
561559 if ( file . isBuffer ( ) ) {
562560 const buffer = file . contents ;
563561 const basename = path . basename ( file . path ) ;
564562 if ( basename === 'package.nls.json' ) {
565563 const json = JSON . parse ( buffer . toString ( 'utf8' ) ) ;
566- getL10nMap ( ) . set ( `extensions/${ extensionName } /package` , json ) ;
564+ getL10nMap ( ) . set ( `extensions/${ extensionId } /package` , json ) ;
567565 }
568566 else if ( basename === 'nls.metadata.json' ) {
569567 const json = JSON . parse ( buffer . toString ( 'utf8' ) ) ;
570- const relPath = path . relative ( `.build/extensions/${ extensionName } ` , path . dirname ( file . path ) ) ;
568+ const relPath = path . relative ( `.build/extensions/${ extensionFolderName } ` , path . dirname ( file . path ) ) ;
571569 for ( const file in json ) {
572570 const fileContent = json [ file ] ;
573571 const info = Object . create ( null ) ;
@@ -578,12 +576,12 @@ function createXlfFilesForExtensions() {
578576 : { key : fileContent . keys [ i ] , comment : undefined } ;
579577 info [ key ] = comment ? { message, comment } : message ;
580578 }
581- getL10nMap ( ) . set ( `extensions/${ extensionName } /${ relPath } /${ file } ` , info ) ;
579+ getL10nMap ( ) . set ( `extensions/${ extensionId } /${ relPath } /${ file } ` , info ) ;
582580 }
583581 }
584582 else if ( basename === 'bundle.l10n.json' ) {
585583 const json = JSON . parse ( buffer . toString ( 'utf8' ) ) ;
586- getL10nMap ( ) . set ( `extensions/${ extensionName } /bundle` , json ) ;
584+ getL10nMap ( ) . set ( `extensions/${ extensionId } /bundle` , json ) ;
587585 }
588586 else {
589587 this . emit ( 'error' , new Error ( `${ file . path } is not a valid extension nls file` ) ) ;
@@ -593,7 +591,7 @@ function createXlfFilesForExtensions() {
593591 } , function ( ) {
594592 if ( _l10nMap ?. size > 0 ) {
595593 const xlfFile = new File ( {
596- path : path . join ( extensionsProject , extensionName + '.xlf' ) ,
594+ path : path . join ( extensionsProject , extensionId + '.xlf' ) ,
597595 contents : Buffer . from ( ( 0 , l10n_dev_1 . getL10nXlf ) ( _l10nMap ) , 'utf8' )
598596 } ) ;
599597 folderStream . queue ( xlfFile ) ;
@@ -712,18 +710,14 @@ function prepareI18nPackFiles(resultingTranslationPaths) {
712710 const path = file . name ;
713711 const firstSlash = path . indexOf ( '/' ) ;
714712 if ( project === extensionsProject ) {
713+ // resource will be the extension id
715714 let extPack = extensionsPacks [ resource ] ;
716715 if ( ! extPack ) {
717716 extPack = extensionsPacks [ resource ] = { version : i18nPackVersion , contents : { } } ;
718717 }
719- const externalId = externalExtensionsWithTranslations [ resource ] ;
720- if ( ! externalId ) { // internal extension: remove 'extensions/extensionId/' segnent
721- const secondSlash = path . indexOf ( '/' , firstSlash + 1 ) ;
722- extPack . contents [ path . substring ( secondSlash + 1 ) ] = getRecordFromL10nJsonFormat ( file . messages ) ;
723- }
724- else {
725- extPack . contents [ path ] = getRecordFromL10nJsonFormat ( file . messages ) ;
726- }
718+ // remove 'extensions/extensionId/' segment
719+ const secondSlash = path . indexOf ( '/' , firstSlash + 1 ) ;
720+ extPack . contents [ path . substring ( secondSlash + 1 ) ] = getRecordFromL10nJsonFormat ( file . messages ) ;
727721 }
728722 else {
729723 mainPack . contents [ path . substring ( firstSlash + 1 ) ] = getRecordFromL10nJsonFormat ( file . messages ) ;
@@ -741,16 +735,10 @@ function prepareI18nPackFiles(resultingTranslationPaths) {
741735 const translatedMainFile = createI18nFile ( './main' , mainPack ) ;
742736 resultingTranslationPaths . push ( { id : 'vscode' , resourceName : 'main.i18n.json' } ) ;
743737 this . queue ( translatedMainFile ) ;
744- for ( const extension in extensionsPacks ) {
745- const translatedExtFile = createI18nFile ( `extensions/${ extension } ` , extensionsPacks [ extension ] ) ;
738+ for ( const extensionId in extensionsPacks ) {
739+ const translatedExtFile = createI18nFile ( `extensions/${ extensionId } ` , extensionsPacks [ extensionId ] ) ;
746740 this . queue ( translatedExtFile ) ;
747- const externalExtensionId = externalExtensionsWithTranslations [ extension ] ;
748- if ( externalExtensionId ) {
749- resultingTranslationPaths . push ( { id : externalExtensionId , resourceName : `extensions/${ extension } .i18n.json` } ) ;
750- }
751- else {
752- resultingTranslationPaths . push ( { id : `vscode.${ extension } ` , resourceName : `extensions/${ extension } .i18n.json` } ) ;
753- }
741+ resultingTranslationPaths . push ( { id : extensionId , resourceName : `extensions/${ extensionId } .i18n.json` } ) ;
754742 }
755743 this . queue ( null ) ;
756744 } )
0 commit comments