@@ -36,12 +36,6 @@ exports.extraLanguages = [
36
36
{ id : 'hu' , folderName : 'hun' } ,
37
37
{ id : 'tr' , folderName : 'trk' }
38
38
] ;
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
- } ;
45
39
var LocalizeInfo ;
46
40
( function ( LocalizeInfo ) {
47
41
function is ( value ) {
@@ -513,10 +507,10 @@ function createXlfFilesForCoreBundle() {
513
507
} ) ;
514
508
}
515
509
exports . createXlfFilesForCoreBundle = createXlfFilesForCoreBundle ;
516
- function createL10nBundleForExtension ( extensionName ) {
510
+ function createL10nBundleForExtension ( extensionFolderName ) {
517
511
const result = ( 0 , event_stream_1 . through ) ( ) ;
518
512
gulp . src ( [
519
- `extensions/${ extensionName } /src/**/*.ts` ,
513
+ `extensions/${ extensionFolderName } /src/**/*.ts` ,
520
514
] ) . pipe ( ( 0 , event_stream_1 . writeArray ) ( ( err , files ) => {
521
515
if ( err ) {
522
516
result . emit ( 'error' , err ) ;
@@ -527,7 +521,7 @@ function createL10nBundleForExtension(extensionName) {
527
521
} ) ) ;
528
522
if ( Object . keys ( json ) . length > 0 ) {
529
523
result . emit ( 'data' , new File ( {
530
- path : `${ extensionName } /bundle.l10n.json` ,
524
+ path : `extensions/ ${ extensionFolderName } /bundle.l10n.json` ,
531
525
contents : Buffer . from ( JSON . stringify ( json ) , 'utf8' )
532
526
} ) ) ;
533
527
}
@@ -545,10 +539,14 @@ function createXlfFilesForExtensions() {
545
539
if ( ! stat . isDirectory ( ) ) {
546
540
return ;
547
541
}
548
- const extensionName = path . basename ( extensionFolder . path ) ;
549
- if ( extensionName === 'node_modules' ) {
542
+ const extensionFolderName = path . basename ( extensionFolder . path ) ;
543
+ if ( extensionFolderName === 'node_modules' ) {
550
544
return ;
551
545
}
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 ;
552
550
counter ++ ;
553
551
let _l10nMap ;
554
552
function getL10nMap ( ) {
@@ -557,17 +555,17 @@ function createXlfFilesForExtensions() {
557
555
}
558
556
return _l10nMap ;
559
557
}
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 ) {
561
559
if ( file . isBuffer ( ) ) {
562
560
const buffer = file . contents ;
563
561
const basename = path . basename ( file . path ) ;
564
562
if ( basename === 'package.nls.json' ) {
565
563
const json = JSON . parse ( buffer . toString ( 'utf8' ) ) ;
566
- getL10nMap ( ) . set ( `extensions/${ extensionName } /package` , json ) ;
564
+ getL10nMap ( ) . set ( `extensions/${ extensionId } /package` , json ) ;
567
565
}
568
566
else if ( basename === 'nls.metadata.json' ) {
569
567
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 ) ) ;
571
569
for ( const file in json ) {
572
570
const fileContent = json [ file ] ;
573
571
const info = Object . create ( null ) ;
@@ -578,12 +576,12 @@ function createXlfFilesForExtensions() {
578
576
: { key : fileContent . keys [ i ] , comment : undefined } ;
579
577
info [ key ] = comment ? { message, comment } : message ;
580
578
}
581
- getL10nMap ( ) . set ( `extensions/${ extensionName } /${ relPath } /${ file } ` , info ) ;
579
+ getL10nMap ( ) . set ( `extensions/${ extensionId } /${ relPath } /${ file } ` , info ) ;
582
580
}
583
581
}
584
582
else if ( basename === 'bundle.l10n.json' ) {
585
583
const json = JSON . parse ( buffer . toString ( 'utf8' ) ) ;
586
- getL10nMap ( ) . set ( `extensions/${ extensionName } /bundle` , json ) ;
584
+ getL10nMap ( ) . set ( `extensions/${ extensionId } /bundle` , json ) ;
587
585
}
588
586
else {
589
587
this . emit ( 'error' , new Error ( `${ file . path } is not a valid extension nls file` ) ) ;
@@ -593,7 +591,7 @@ function createXlfFilesForExtensions() {
593
591
} , function ( ) {
594
592
if ( _l10nMap ?. size > 0 ) {
595
593
const xlfFile = new File ( {
596
- path : path . join ( extensionsProject , extensionName + '.xlf' ) ,
594
+ path : path . join ( extensionsProject , extensionId + '.xlf' ) ,
597
595
contents : Buffer . from ( ( 0 , l10n_dev_1 . getL10nXlf ) ( _l10nMap ) , 'utf8' )
598
596
} ) ;
599
597
folderStream . queue ( xlfFile ) ;
@@ -712,18 +710,14 @@ function prepareI18nPackFiles(resultingTranslationPaths) {
712
710
const path = file . name ;
713
711
const firstSlash = path . indexOf ( '/' ) ;
714
712
if ( project === extensionsProject ) {
713
+ // resource will be the extension id
715
714
let extPack = extensionsPacks [ resource ] ;
716
715
if ( ! extPack ) {
717
716
extPack = extensionsPacks [ resource ] = { version : i18nPackVersion , contents : { } } ;
718
717
}
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 ) ;
727
721
}
728
722
else {
729
723
mainPack . contents [ path . substring ( firstSlash + 1 ) ] = getRecordFromL10nJsonFormat ( file . messages ) ;
@@ -741,16 +735,10 @@ function prepareI18nPackFiles(resultingTranslationPaths) {
741
735
const translatedMainFile = createI18nFile ( './main' , mainPack ) ;
742
736
resultingTranslationPaths . push ( { id : 'vscode' , resourceName : 'main.i18n.json' } ) ;
743
737
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 ] ) ;
746
740
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` } ) ;
754
742
}
755
743
this . queue ( null ) ;
756
744
} )
0 commit comments