@@ -9,13 +9,14 @@ import { IExtensionManifest } from 'vs/platform/extensions/common/extensions';
9
9
import { localize } from 'vs/nls' ;
10
10
11
11
export interface ITranslations {
12
- [ key : string ] : string | { message : string ; comment : string [ ] } ;
12
+ [ key : string ] : string | { message : string ; comment : string [ ] } | undefined ;
13
13
}
14
14
15
15
export function localizeManifest ( extensionManifest : IExtensionManifest , translations : ITranslations , fallbackTranslations ?: ITranslations ) : IExtensionManifest {
16
16
try {
17
17
replaceNLStrings ( extensionManifest , translations , fallbackTranslations ) ;
18
18
} catch ( error ) {
19
+ console . error ( error ?. message ?? error ) ;
19
20
/*Ignore Error*/
20
21
}
21
22
return extensionManifest ;
@@ -39,27 +40,32 @@ function replaceNLStrings(extensionManifest: IExtensionManifest, messages: ITran
39
40
if ( translated === undefined && originalMessages ) {
40
41
translated = originalMessages [ messageKey ] ;
41
42
}
42
- const message : string | undefined = typeof translated === 'string' ? translated : translated . message ;
43
- if ( message !== undefined ) {
44
- // This branch returns ILocalizedString's instead of Strings so that the Command Palette can contain both the localized and the original value.
45
- const original = originalMessages ?. [ messageKey ] ;
46
- const originalMessage : string | undefined = typeof original === 'string' ? original : original ?. message ;
47
- if (
48
- // if we are translating the title or category of a command
49
- command && ( key === 'title' || key === 'category' ) &&
50
- // and the original value is not the same as the translated value
51
- originalMessage && originalMessage !== message
52
- ) {
53
- const localizedString : ILocalizedString = {
54
- value : message ,
55
- original : originalMessage
56
- } ;
57
- obj [ key ] = localizedString ;
58
- } else {
59
- obj [ key ] = message ;
43
+ const message : string | undefined = typeof translated === 'string' ? translated : translated ?. message ;
44
+
45
+ // This branch returns ILocalizedString's instead of Strings so that the Command Palette can contain both the localized and the original value.
46
+ const original = originalMessages ?. [ messageKey ] ;
47
+ const originalMessage : string | undefined = typeof original === 'string' ? original : original ?. message ;
48
+
49
+ if ( ! message ) {
50
+ if ( ! originalMessage ) {
51
+ console . warn ( `[${ extensionManifest . name } ]: ${ localize ( 'missingNLSKey' , "Couldn't find message for key {0}." , messageKey ) } ` ) ;
60
52
}
53
+ return ;
54
+ }
55
+
56
+ if (
57
+ // if we are translating the title or category of a command
58
+ command && ( key === 'title' || key === 'category' ) &&
59
+ // and the original value is not the same as the translated value
60
+ originalMessage && originalMessage !== message
61
+ ) {
62
+ const localizedString : ILocalizedString = {
63
+ value : message ,
64
+ original : originalMessage
65
+ } ;
66
+ obj [ key ] = localizedString ;
61
67
} else {
62
- console . warn ( `[ ${ extensionManifest . name } ]: ${ localize ( 'missingNLSKey' , "Couldn't find message for key {0}." , messageKey ) } ` ) ;
68
+ obj [ key ] = message ;
63
69
}
64
70
}
65
71
} else if ( isObject ( value ) ) {
0 commit comments