Skip to content
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

Fix missing localizations #427

Merged
merged 5 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion rollup/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ function transformVSCodeCode (id: string, code: string) {
const name = node.callee.type === 'MemberExpression' || node.callee.type === 'Identifier' ? getMemberExpressionPath(node.callee) : null

if (name != null && (name.endsWith('localizeWithPath') || name.endsWith('localize2WithPath'))) {
const translationPath = nodePath.relative(id.startsWith(OVERRIDE_PATH) ? OVERRIDE_PATH : VSCODE_SRC_DIR, id).slice(0, -3)
const translationPath = nodePath.relative(id.startsWith(OVERRIDE_PATH) ? OVERRIDE_PATH : VSCODE_SRC_DIR, id)
.slice(0, -3) // remove extension
.replace(/\._[^/.]*/g, '') // remove own refactor module suffixes
let localizationKey: string
if (path.node.arguments[1]?.type === 'StringLiteral') {
localizationKey = path.node.arguments[1].value
Expand Down
18 changes: 9 additions & 9 deletions rollup/rollup.types.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default rollup.defineConfig((<{input: Record<string, string>, output: str
if (id === path.resolve(TYPES_SRC_DIR, 'editor.api.d.ts')) {
return {
name: 'editor.api',
publicName: '@codngame/monaco-vscode-editor-api'
publicName: '@codingame/monaco-vscode-editor-api'
}
}
return {
Expand Down Expand Up @@ -250,8 +250,7 @@ export default rollup.defineConfig((<{input: Record<string, string>, output: str
{
name: 'replace-interfaces',
load (id) {
const path = new URL(id, 'file:/').pathname
const sourceFile = project.addSourceFileAtPath(path)
const sourceFile = project.addSourceFileAtPath(id)

if (id.includes('node_modules') && id.includes('xterm')) {
// xterm modules use `declare module` syntax not supposed by the rollup-dts-plugin, so let's transform the code
Expand Down Expand Up @@ -302,14 +301,15 @@ export default rollup.defineConfig((<{input: Record<string, string>, output: str
{
name: 'resolve-vscode',
resolveId: async function (importee, importer) {
if (importee.startsWith('vscode/')) {
return path.resolve(VSCODE_DIR, path.relative('vscode', `${importee}.d.ts`))
const importeeWithoutExtension = importee.endsWith('.js') ? importee.slice(0, -3) : importee
if (importeeWithoutExtension.startsWith('vscode/')) {
return path.resolve(VSCODE_DIR, path.relative('vscode', `${importeeWithoutExtension}.d.ts`))
}
if (importee.startsWith('.') && importer != null && importer.startsWith(VSCODE_SRC_DIR)) {
importee = path.relative(VSCODE_SRC_DIR, path.resolve(path.dirname(importer), importee))
if (importeeWithoutExtension.startsWith('.') && importer != null && importeeWithoutExtension.startsWith(VSCODE_SRC_DIR)) {
importee = path.relative(VSCODE_SRC_DIR, path.resolve(path.dirname(importer), importeeWithoutExtension))
}
if (importee.startsWith('vs/')) {
return path.join(VSCODE_SRC_DIR, `${importee}.d.ts`)
if (importeeWithoutExtension.startsWith('vs/')) {
return path.join(VSCODE_SRC_DIR, `${importeeWithoutExtension}.d.ts`)
}
return undefined
}
Expand Down
6 changes: 3 additions & 3 deletions src/service-override/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import { DEFAULT_EDITOR_PART_OPTIONS } from 'vs/workbench/browser/parts/editor/e
import { mainWindow } from 'vs/base/browser/window'
import { MonacoDelegateEditorGroupsService, MonacoEditorService, OpenEditor, fakeActiveGroup } from './tools/editor'
import { unsupported } from '../tools'
import 'vs/workbench/browser/parts/editor/editor.autosave.contribution'
import 'vs/workbench/contrib/files/browser/files.fileEditorFactory.contribution'
import 'vs/workbench/contrib/files/browser/fileCommands.save'
import 'vs/workbench/browser/parts/editor/editor.contribution._autosave.js'
import 'vs/workbench/contrib/files/browser/files.contribution._fileEditorFactory.js'
import 'vs/workbench/contrib/files/browser/fileCommands._save.js'

class EmptyEditorPart implements IEditorPart {
hasMaximizedGroup = () => false
Expand Down
2 changes: 1 addition & 1 deletion src/service-override/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ExplorerService } from 'vs/workbench/contrib/files/browser/explorerServ
import { IExplorerService } from 'vs/workbench/contrib/files/browser/files.service'
import 'vs/workbench/contrib/files/browser/fileCommands'
import 'vs/workbench/contrib/files/browser/fileActions.contribution'
import 'vs/workbench/contrib/files/browser/files.explorer.contribution'
import 'vs/workbench/contrib/files/browser/files.contribution._explorer.js'

function getServiceOverride (): IEditorOverrideServices {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/service-override/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { BrowserElevatedFileService } from 'vs/workbench/services/files/browser/
import { IElevatedFileService } from 'vs/workbench/services/files/common/elevatedFileService.service'
import { checkServicesNotInitialized, registerServiceInitializePreParticipant } from '../lifecycle'
import { logsPath } from '../workbench'
import 'vs/workbench/contrib/files/browser/files.configuration.contribution'
import 'vs/workbench/contrib/files/browser/files.contribution._configuration.js'

abstract class RegisteredFile {
protected ctime: number
Expand Down
6 changes: 3 additions & 3 deletions src/service-override/viewCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ import 'vs/workbench/contrib/webview/browser/webview.contribution'
import 'vs/workbench/contrib/limitIndicator/browser/limitIndicator.contribution'
import 'vs/workbench/contrib/sash/browser/sash.contribution'
import 'vs/workbench/contrib/preferences/browser/keyboardLayoutPicker'
import 'vs/workbench/browser/parts/editor/editor.autosave.contribution'
import 'vs/workbench/contrib/files/browser/files.editorPane.contribution'
import 'vs/workbench/contrib/files/browser/fileCommands.save'
import 'vs/workbench/browser/parts/editor/editor.contribution._autosave.js'
import 'vs/workbench/contrib/files/browser/files.contribution._editorPane.js'
import 'vs/workbench/contrib/files/browser/fileCommands._save.js'
import 'vs/workbench/browser/actions/navigationActions'
import 'vs/workbench/browser/style'
import './tools/editorAssets'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Date: Mon, 11 Mar 2024 16:45:29 +0100
Subject: [PATCH] feat: add a way to register a locale with translations

---
build/lib/standalone.js | 15 +++++++++++++--
build/lib/standalone.ts | 11 +++++++++++
build/lib/standalone.js | 18 ++++++++++++++++--
build/lib/standalone.ts | 14 ++++++++++++++
src/vs/nls.ts | 31 ++++++++++++++++++++++++++++++-
3 files changed, 54 insertions(+), 3 deletions(-)
3 files changed, 60 insertions(+), 3 deletions(-)

diff --git a/build/lib/standalone.js b/build/lib/standalone.js
index 723a1127492..02b239898f1 100644
index 723a1127492..e327023f021 100644
--- a/build/lib/standalone.js
+++ b/build/lib/standalone.js
@@ -4,8 +4,7 @@
Expand All @@ -31,7 +31,7 @@ index 723a1127492..02b239898f1 100644
function createESMSourcesAndResources2(options) {
const ts = require('typescript');
const SRC_FOLDER = path.join(REPO_ROOT, options.srcFolder);
@@ -190,6 +190,16 @@ function createESMSourcesAndResources2(options) {
@@ -190,6 +190,19 @@ function createESMSourcesAndResources2(options) {
fileContents = fileContents.replace(/import ([a-zA-Z0-9]+) = require\(('[^']+')\);/g, function (_, m1, m2) {
return `import * as ${m1} from ${m2};`;
});
Expand All @@ -40,15 +40,18 @@ index 723a1127492..02b239898f1 100644
+ return `${name}WithPath(_moduleId, `;
+ });
+ if (newFileContents !== fileContents) {
+ newFileContents = `//@ts-ignore\nconst _moduleId = "${file.slice(0, -3)}"\n${newFileContents}`;
+ let moduleId = file.slice(0, -3);
+ // Ignore own refactors ("gettingStartedService._contribution" => "gettingStartedService")
+ moduleId = moduleId.replace(/\._[^/.]*/g, '');
+ newFileContents = `//@ts-ignore\nconst _moduleId = "${moduleId}"\n${newFileContents}`;
+ }
+ fileContents = newFileContents;
+ }
+ fileContents = fileContents.replace(/(?<=import \{.*)\b(localize2?)\b(?=.* from '.*\/nls')/g, '$1WithPath');
write(getDestAbsoluteFilePath(file), fileContents);
continue;
}
@@ -258,6 +268,7 @@ function createESMSourcesAndResources2(options) {
@@ -258,6 +271,7 @@ function createESMSourcesAndResources2(options) {
}
}
}
Expand All @@ -57,10 +60,10 @@ index 723a1127492..02b239898f1 100644
if (!/\.css/.test(module)) {
return false;
diff --git a/build/lib/standalone.ts b/build/lib/standalone.ts
index 90517a9236f..0c0b4b03610 100644
index 90517a9236f..b5e658903fc 100644
--- a/build/lib/standalone.ts
+++ b/build/lib/standalone.ts
@@ -223,6 +223,17 @@ export function createESMSourcesAndResources2(options: IOptions2): void {
@@ -223,6 +223,20 @@ export function createESMSourcesAndResources2(options: IOptions2): void {
return `import * as ${m1} from ${m2};`;
});

Expand All @@ -69,7 +72,10 @@ index 90517a9236f..0c0b4b03610 100644
+ return `${name}WithPath(_moduleId, `;
+ });
+ if (newFileContents !== fileContents) {
+ newFileContents = `//@ts-ignore\nconst _moduleId = "${file.slice(0, -3)}"\n${newFileContents}`;
+ let moduleId = file.slice(0, -3);
+ // Ignore own refactors ("gettingStartedService._contribution" => "gettingStartedService")
+ moduleId = moduleId.replace(/\._[^/.]*/g, '');
+ newFileContents = `//@ts-ignore\nconst _moduleId = "${moduleId}"\n${newFileContents}`;
+ }
+ fileContents = newFileContents;
+ }
Expand Down
Loading