Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

All localized strings show up as 'Failed to load message bundle' in extension development host #40

Open
joyceerhl opened this issue May 26, 2022 · 5 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug
Milestone

Comments

@joyceerhl
Copy link

E.g. for RemoteHub: image

@TylerLeonhardt TylerLeonhardt added this to the June 2022 milestone May 27, 2022
@TylerLeonhardt TylerLeonhardt added the bug Issue identified by VS Code Team member as probable bug label May 27, 2022
@sadasant
Copy link

This is the case as well for VSIXs generated locally. Is there a workaround?

@joyceerhl
Copy link
Author

@sadasant I worked around this in the extension development host by not using the nls loader in dev mode. You could modify your build scripts to not use the loader if an environment variable is set, perhaps?

@sadasant
Copy link

@joyceerhl that makes sense! thank you!

@TylerLeonhardt
Copy link
Member

I'm thinking in the patcher we could include the original string so that that is used as a fallback instead of throwing. Probably somewhere in this beast of a code block:

vscode-nls-dev/src/lib.ts

Lines 565 to 599 in 545e01a

localizeCalls.reduce((memo, localizeCall) => {
const firstArg = localizeCall.arguments[0];
const secondArg = localizeCall.arguments[1];
let key: string | null = null;
let message: string | null = null;
let comment: string[] = [];
let text: string | null = null;
if (ts.isStringLiteralLike(firstArg)) {
text = firstArg.getText();
key = text.substr(1, text.length - 2);
} else if (ts.isObjectLiteralExpression(firstArg)) {
for (let i = 0; i < firstArg.properties.length; i++) {
const property = firstArg.properties[i];
if (ts.isPropertyAssignment(property)) {
const name = property.name.getText();
if (name === 'key') {
const initializer = property.initializer;
if (ts.isStringLiteralLike(initializer)) {
text = initializer.getText();
key = text.substr(1, text.length - 2);
}
} else if (name === 'comment') {
const initializer = property.initializer;
if (ts.isArrayLiteralExpression(initializer)) {
initializer.elements.forEach(element => {
if (ts.isStringLiteralLike(element)) {
text = element.getText();
comment.push(text.substr(1, text.length - 2));
}
});
}
}
}
}
}

What do you think @dbaeumer?

@dbaeumer
Copy link
Member

The drawback of this is that we might have strings double in memory. This would put all English strings into the source code and they would be ignored if a LP is used. I guess this is the reason why I didn't do this in the first place.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

4 participants