-
Notifications
You must be signed in to change notification settings - Fork 29.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(web): add support for language packs #146012
Conversation
@@ -44,3 +50,39 @@ export namespace InternalNLSConfiguration { | |||
return candidate && typeof candidate._languagePackId === 'string'; | |||
} | |||
} | |||
|
|||
export const getLocaleFromConfig = async (argvResource: string): Promise<string> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be able to use this function:
Line 585 in f3a9245
function getUserDefinedLocale(argvConfig) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually...not 1:1 and can't import from JS file I don't think (well I don't see any other files using this since it's not exported) so going to leave as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar function/logic as well:
Lines 233 to 256 in f3a9245
function readArgvConfigSync() { | |
// Read or create the argv.json config file sync before app('ready') | |
const argvConfigPath = getArgvConfigPath(); | |
let argvConfig; | |
try { | |
argvConfig = JSON.parse(stripComments(fs.readFileSync(argvConfigPath).toString())); | |
} catch (error) { | |
if (error && error.code === 'ENOENT') { | |
createDefaultArgvConfigSync(argvConfigPath); | |
} else { | |
console.warn(`Unable to read argv.json configuration file in ${argvConfigPath}, falling back to defaults (${error})`); | |
} | |
} | |
// Fallback to default | |
if (!argvConfig) { | |
argvConfig = { | |
'disable-color-correct-rendering': true // Force pre-Chrome-60 color profile handling (for https://github.com/microsoft/vscode/issues/51791) | |
}; | |
} | |
return argvConfig; | |
} |
I'm running into issues building locally. Any ideas? Does [15:28:58] Error: /Users/jp/dev/oss/vscode/src/vs/workbench/contrib/debug/node/terminals.ts(9,10): '"windows-process-tree"' has no exported member named 'IProcessTreeNode'. Did you mean 'ProcessTreeNode'?
[15:28:58] Error: /Users/jp/dev/oss/vscode/src/vs/platform/terminal/node/windowsShellHelper.ts(135,89): '"/Users/jp/dev/oss/vscode/node_modules/@types/windows-process-tree/index"' has no exported member named 'IProcessTreeNode'. Did you mean 'ProcessTreeNode'?
[15:28:58] Finished compilation with 2 errors after 165738 ms
[15:28:58] Error: /Users/jp/dev/oss/vscode/src/vs/workbench/contrib/debug/node/terminals.ts(9,10): '"windows-process-tree"' has no exported member named 'IProcessTreeNode'. Did you mean 'ProcessTreeNode'?
[15:28:58] Error: /Users/jp/dev/oss/vscode/src/vs/platform/terminal/node/windowsShellHelper.ts(135,89): '"/Users/jp/dev/oss/vscode/node_modules/@types/windows-process-tree/index"' has no exported member named 'IProcessTreeNode'. Did you mean 'ProcessTreeNode'?
[15:28:58] Finished compilation with 2 errors after 165740 ms
[15:28:58] 'vscode-reh-web-darwin-x64-min' errored after 2.85 min
[15:28:58] Error: Found 2 errors
at Stream.<anonymous> (/Users/jp/dev/oss/vscode/build/lib/reporter.js:91:29)
at _end (/Users/jp/dev/oss/vscode/node_modules/through/index.js:65:9)
at Stream.stream.end (/Users/jp/dev/oss/vscode/node_modules/through/index.js:74:5)
at Stream.onend (internal/streams/legacy.js:47:10)
at Stream.emit (events.js:412:35)
at Stream.emit (domain.js:532:15)
at drain (/Users/jp/dev/oss/vscode/node_modules/through/index.js:34:23)
at Stream.stream.queue.stream.push (/Users/jp/dev/oss/vscode/node_modules/through/index.js:45:5)
at Stream.end (/Users/jp/dev/oss/vscode/node_modules/through/index.js:15:35)
at _end (/Users/jp/dev/oss/vscode/node_modules/through/index.js:65:9)
error Command failed with exit code 1. |
Looks like the build is in a bad state. Unrelated to your change. Should be fixed tomorrow. |
@jsjoeio just an FYI I updated your brand from main to help with the CI and local failures. |
Yes I believe all of this is expected and is the same as Desktop. The commit is used in the path of one of the localization files and also when running out of sources we don’t bundle files (for easier debugging) but bundling is important for the localization feature. @dbaeumer please let me know if I have this wrong. |
yeah I’d like to get to the bottom of this before we merge this PR in. I should have some cycles to look into it this week. |
Awesome! Thank you so much for the quick replies and offering to help us get to the bottom of this! Really appreciate it. Let me know how else I can be helpful. |
Okay a couple updates:
I'm not sure how to fix this Hygine error: $ node build/lib/layersChecker.js
[build/lib/layersChecker.ts]: Reference to 'document' from 'lib.dom.d.ts' violates layer '**/vs/base/common/platform.ts' (/home/runner/work/vscode/vscode/src/vs/base/common/platform.ts ([8](https://github.com/microsoft/vscode/runs/5756751534?check_suite_focus=true#step:11:8)7,20)
[build/lib/layersChecker.ts]: Reference to 'document' from 'lib.dom.d.ts' violates layer '**/vs/base/common/platform.ts' (/home/runner/work/vscode/vscode/src/vs/base/common/platform.ts (87,48)
[build/lib/layersChecker.ts]: Reference to 'getElementById' from 'lib.dom.d.ts' violates layer '**/vs/base/common/platform.ts' (/home/runner/work/vscode/vscode/src/vs/base/common/platform.ts (87,57)
[build/lib/layersChecker.ts]: Reference to 'getAttribute' from 'lib.dom.d.ts' violates layer '**/vs/base/common/platform.ts' (/home/runner/work/vscode/vscode/src/vs/base/common/platform.ts (88,32)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. I see Maybe there's a way to refactor this code to do it the "proper way": const el = typeof document !== 'undefined' && document.getElementById('vscode-remote-nls-configuration');
const rawNlsConfig = el && el.getAttribute('data-settings'); |
Friendly bump @TylerLeonhardt - do you think you'll have a chance to look at this this month? |
👋 @jsjoeio so sorry for the delay. Lots of stuff happened (including personally) and I wasn't able to get around to this. I really appreciate all the work you've done to achieve language pack support. Based on your findings, I'm currently working on solving the known limitations by allowing the client to dictate what the language is so that we can avoid some of things you've pointed out. I can speak more about that once I actually have something to show off 😅 but essentially the idea is to have |
@TylerLeonhardt no worries at all - hope everything is okay personally! Thanks so much for the update.
That sounds amazing! I'll keep an eye out then for an update from you 😄 |
@TylerLeonhardt now that 1.68 has core localization support, is this still needed? |
I think we can close this now since we went in a different direction. This wasn't thrown away though, we all learned from the work you did for sure so thank you for taking the time to contribute. It means a lot to the community! |
Description
This PR adds support for using language packs with VS Code Web via the CLI flag
--locale
.Known Limitations
There are a couple limitations with this implementation. Hoping that the Code Team can provide guidance on whether these limitations need to be addressed before merging and if so, how they recommend addressing them.
Implementation only works on a full build
I am not sure why exactly, but this patch only works when you do a full build of VS Code and run that (meaning you can't use this in dev mode).
Requires
commit
inproduct.json
I had to manually add commit to
product.json
in the build output because of this logic.Only works with
--locale
CLI flagSwitching the display language only works using the
--locale
CLI flag. I believe this is because theargv.json
is only modified in the client and saved in the IndexedDB.If we patched this to use the file system instead of
userRoamingDataHome
, it could potentially work normally (without passing a CLI flag).Still shows "Install in Browser" which leads to error
Even if it's installed on the remote/server, you still see the "Install in Browser" button. When you click on it, you get an error toast notification. Error comes from this block. Do language packs not have manifests?
Demo
Screen.Recording.2022-03-30.at.9.29.12.AM.mov
How to Test
git clone https://github.com/microsoft/vscode.git
gh pr checkout 146012
yarn
yarn gulp "vscode-reh-web-darwin-x64-min"
(replacedarwin-x64
with your platform)cd .. && ./vscode-reh-web-darwin-x64/bin/code-server-oss
./vscode-reh-web-darwin-x64/bin/code-server-oss --locale es
Fixes #82595
Fixes coder/code-server#4703
Contributors