Skip to content

Commit

Permalink
Merge pull request #2284 from codefori/feature/tol10n
Browse files Browse the repository at this point in the history
Migrate to `vscode.l10n` API
  • Loading branch information
worksofliam authored Oct 22, 2024
2 parents b872351 + f361e54 commit 7562569
Show file tree
Hide file tree
Showing 38 changed files with 3,059 additions and 3,200 deletions.
408 changes: 408 additions & 0 deletions l10n/bundle.l10n.da.json

Large diffs are not rendered by default.

408 changes: 408 additions & 0 deletions l10n/bundle.l10n.de.json

Large diffs are not rendered by default.

408 changes: 408 additions & 0 deletions l10n/bundle.l10n.fr.json

Large diffs are not rendered by default.

408 changes: 408 additions & 0 deletions l10n/bundle.l10n.json

Large diffs are not rendered by default.

408 changes: 408 additions & 0 deletions l10n/bundle.l10n.no.json

Large diffs are not rendered by default.

408 changes: 408 additions & 0 deletions l10n/bundle.l10n.pl.json

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 3 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"license": "MIT",
"engines": {
"vscode": "^1.66.0"
"vscode": "^1.90.0"
},
"categories": [
"Other"
Expand All @@ -37,6 +37,7 @@
"onFileSystem:streamfile"
],
"main": "./dist/extension.js",
"l10n": "./l10n",
"contributes": {
"taskDefinitions": [
{
Expand Down Expand Up @@ -502,29 +503,6 @@
"default": false,
"description": "If enabled, when the user tries to delete a directory, they will be asked to confirm the deletion by typing in the directory's name."
},
"code-for-ibmi.locale": {
"type": "string",
"default": "inherit",
"enum": [
"inherit",
"en",
"da",
"de",
"no",
"pl",
"fr"
],
"enumDescriptions": [
"Inherit from VS Code settings",
"English",
"Danish",
"German",
"Norwegian",
"Polish",
"French"
],
"description": "The locale used when displaying text in Code for IBM i. Requires restart if changed."
},
"code-for-ibmi.showDateSearchButton": {
"type": "boolean",
"default": true,
Expand Down Expand Up @@ -2960,7 +2938,7 @@
"@types/source-map-support": "^0.5.6",
"@types/tar": "^6.1.4",
"@types/tmp": "^0.2.3",
"@types/vscode": "^1.66.0",
"@types/vscode": "^1.90.0",
"esbuild": "^0.19.2",
"esbuild-loader": "^3.0.1",
"eslint": "^7.19.0",
Expand Down
42 changes: 21 additions & 21 deletions src/api/IBMiContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -976,48 +976,48 @@ export default class IBMiContent {

objectToToolTip(path: string, object: IBMiObject) {
const tooltip = new MarkdownString(Tools.generateTooltipHtmlTable(path, {
type: object.type,
attribute: object.attribute,
text: object.text,
size: object.size,
created: object.created?.toISOString().slice(0, 19).replace(`T`, ` `),
changed: object.changed?.toISOString().slice(0, 19).replace(`T`, ` `),
created_by: object.created_by,
owner: object.owner,
iasp: object.asp
"Type": object.type,
"Attribute": object.attribute,
"Text": object.text,
"Size": object.size,
"Created": object.created?.toISOString().slice(0, 19).replace(`T`, ` `),
"Changed": object.changed?.toISOString().slice(0, 19).replace(`T`, ` `),
"Created by": object.created_by,
"Owner": object.owner,
"IASP": object.asp
}));
tooltip.supportHtml = true;
return tooltip;
}

async sourcePhysicalFileToToolTip(path: string, object: IBMiObject) {
const tooltip = new MarkdownString(Tools.generateTooltipHtmlTable(path, {
text: object.text,
members: await this.countMembers(object),
length: object.sourceLength,
CCSID: (await this.getAttributes(object, "CCSID"))?.CCSID || '?',
iasp: object.asp
"Text": object.text,
"Members": await this.countMembers(object),
"Length": object.sourceLength,
"CCSID": (await this.getAttributes(object, "CCSID"))?.CCSID || '?',
"IASP": object.asp
}));
tooltip.supportHtml = true;
return tooltip;
}

memberToToolTip(path: string, member: IBMiMember) {
const tooltip = new MarkdownString(Tools.generateTooltipHtmlTable(path, {
text: member.text,
lines: member.lines,
created: member.created?.toISOString().slice(0, 19).replace(`T`, ` `),
changed: member.changed?.toISOString().slice(0, 19).replace(`T`, ` `)
"Text": member.text,
"Lines": member.lines,
"Created": member.created?.toISOString().slice(0, 19).replace(`T`, ` `),
"Changed": member.changed?.toISOString().slice(0, 19).replace(`T`, ` `)
}));
tooltip.supportHtml = true;
return tooltip;
}

ifsFileToToolTip(path: string, ifsFile: IFSFile) {
const tooltip = new MarkdownString(Tools.generateTooltipHtmlTable(path, {
size: ifsFile.size,
modified: ifsFile.modified ? new Date(ifsFile.modified.getTime() - ifsFile.modified.getTimezoneOffset() * 60 * 1000).toISOString().slice(0, 19).replace(`T`, ` `) : ``,
owner: ifsFile.owner ? ifsFile.owner.toUpperCase() : ``
"Size": ifsFile.size,
"Modified": ifsFile.modified ? new Date(ifsFile.modified.getTime() - ifsFile.modified.getTimezoneOffset() * 60 * 1000).toISOString().slice(0, 19).replace(`T`, ` `) : ``,
"Owner": ifsFile.owner ? ifsFile.owner.toUpperCase() : ``
}));
tooltip.supportHtml = true;
return tooltip;
Expand Down
3 changes: 1 addition & 2 deletions src/api/Tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Crypto from 'crypto';
import { readFileSync } from "fs";
import path from "path";
import vscode from "vscode";
import { t } from "../locale";
import { IBMiMessage, IBMiMessages, QsysPath } from '../typings';
import { API, GitExtension } from "./import/git";

Expand Down Expand Up @@ -377,7 +376,7 @@ export namespace Tools {
.concat(`${header ? `<thead>${header}</thead>` : ``}`)
.concat(`${Object.entries(rows)
.filter(([key, value]) => value !== undefined && value !== '')
.map(([key, value]) => `<tr><td>${t(key)}:</td><td>&nbsp;${value}</td></tr>`)
.map(([key, value]) => `<tr><td>${vscode.l10n.t(key)}:</td><td>&nbsp;${value}</td></tr>`)
.join(``)}`
)
.concat(`</table>`);
Expand Down
5 changes: 2 additions & 3 deletions src/api/debug/certificates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import path, { dirname, posix } from "path";
import { promisify } from 'util';
import vscode from "vscode";
import { instance } from '../../instantiate';
import { t } from '../../locale';
import IBMi from "../IBMi";
import IBMiContent from '../IBMiContent';
import { Tools } from '../Tools';
Expand Down Expand Up @@ -248,15 +247,15 @@ export async function checkClientCertificate(connection: IBMi, debugConfig?: Deb
if (!remote.code) {
const localCertificate = readFileSync(locaCertificatePath).toString("utf-8");
if (localCertificate.trim() !== remote.stdout.trim()) {
throw new Error(t('local.dont.match.remote'));
throw new Error(vscode.l10n.t(`Local certificate doesn't match remote`));
}
}
else {
throw new Error(`Could not read client certificate on host: ${remote.stderr}`);
}
}
else {
throw new Error(t('local.certificate.not.found'));
throw new Error(vscode.l10n.t(`Local certificate not found`));
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/api/debug/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import path from "path";
import vscode from "vscode";
import { instance } from "../../instantiate";
import { t } from "../../locale";
import IBMi from "../IBMi";
import { SERVICE_CERTIFICATE } from "./certificates";

Expand Down Expand Up @@ -148,9 +147,9 @@ export async function getDebugServiceDetails(): Promise<DebugServiceDetails> {
};
}
}
} catch (e) {
} catch (e: any) {
// Something very very bad has happened
vscode.window.showErrorMessage(t('detail.reading.error', detailFilePath, e));
vscode.window.showErrorMessage(vscode.l10n.t(`Failed to read debug service detail file {0}: {1}`, detailFilePath, e));
console.log(e);
}
}
Expand All @@ -175,7 +174,7 @@ export function getJavaHome(connection: IBMi, version: string) {
version = version.padEnd(2, '0');
const javaHome = connection.remoteFeatures[`jdk${version}`];
if (!javaHome) {
throw new Error(t('java.not.found', version));
throw new Error(vscode.l10n.t(`Java version {0} is not installed.`, version));
}

return javaHome;
Expand Down
25 changes: 12 additions & 13 deletions src/api/debug/server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import path from "path";
import { commands, window } from "vscode";
import { commands, l10n, window } from "vscode";
import { instance } from "../../instantiate";
import { t } from "../../locale";
import { CustomUI } from "../CustomUI";
import IBMi from "../IBMi";
import { Tools } from "../Tools";
Expand Down Expand Up @@ -32,8 +31,8 @@ export async function startService(connection: IBMi) {
const debugConfig = await new DebugConfiguration().load();

const submitOptions = await window.showInputBox({
title: t("debug.service.submit.options"),
prompt: t("debug.service.submit.options.prompt"),
title: l10n.t(`Debug Service submit options`),
prompt: l10n.t(`Valid parameters for SBMJOB`),
value: `JOBQ(QSYS/QUSRNOMAX) JOBD(QSYS/QSYSJOBD) USER(*CURRENT)`
});

Expand All @@ -55,7 +54,7 @@ export async function startService(connection: IBMi) {
const jobDetail = await readActiveJob(connection, { name: job, ports: [] });
if (jobDetail && typeof jobDetail === "object" && !["HLD", "MSGW", "END"].includes(String(jobDetail.JOB_STATUS))) {
if (await getDebugServiceJob()) {
window.showInformationMessage(t("start.debug.service.succeeded"));
window.showInformationMessage(l10n.t(`Debug service started.`));
refreshDebugSensitiveItems();
done(true);
}
Expand Down Expand Up @@ -102,11 +101,11 @@ export async function stopService(connection: IBMi) {
});

if (!endResult.code) {
window.showInformationMessage(t("stop.debug.service.succeeded"));
window.showInformationMessage(l10n.t(`Debug service stopped.`));
refreshDebugSensitiveItems();
return true;
} else {
window.showErrorMessage(t("stop.debug.service.failed", endResult.stdout || endResult.stderr));
window.showErrorMessage(l10n.t(`Failed to stop debug service: {0}`, endResult.stdout || endResult.stderr));
return false;
}
}
Expand Down Expand Up @@ -167,12 +166,12 @@ export async function startServer() {
const result = await instance.getConnection()?.runCommand({ command: "STRDBGSVR", noLibList: true });
if (result) {
if (result.code) {
window.showErrorMessage(t("strdbgsvr.failed", result.stderr));
window.showErrorMessage(l10n.t(`Failed to start debug server: {0}`, result.stderr));
return false;
}
else {
refreshDebugSensitiveItems();
window.showInformationMessage(t("strdbgsvr.succeeded"));
window.showInformationMessage(l10n.t(`Debug server started.`));
}
}
return true;
Expand All @@ -182,12 +181,12 @@ export async function stopServer() {
const result = await instance.getConnection()?.runCommand({ command: "ENDDBGSVR", noLibList: true });
if (result) {
if (result.code) {
window.showErrorMessage(t("enddbgsvr.failed", result.stderr));
window.showErrorMessage(l10n.t(`Failed to stop debug server: {0}`, result.stderr));
return false;
}
else {
refreshDebugSensitiveItems();
window.showInformationMessage(t("enddbgsvr.succeeded"));
window.showInformationMessage(l10n.t(`Debug server stopped.`));
}
}
return true;
Expand All @@ -201,7 +200,7 @@ export function refreshDebugSensitiveItems() {
export async function readActiveJob(connection: IBMi, job: DebugJob) {
try {
return (await connection.runSQL(
`select job_name_short, job_user, job_number, subsystem_library_name concat '/' concat subsystem as subsystem, authorization_name, job_status, memory_pool from table(qsys2.active_job_info(job_name_filter => '${job.name.substring(job.name.lastIndexOf('/') + 1)}')) where job_name = '${job.name}' fetch first row only`
`select job_name_short "Job name", job_user "Job user", job_number "Job number", subsystem_library_name concat '/' concat subsystem as "Subsystem", authorization_name "Current user", job_status "Job status", memory_pool "Memory pool" from table(qsys2.active_job_info(job_name_filter => '${job.name.substring(job.name.lastIndexOf('/') + 1)}')) where job_name = '${job.name}' fetch first row only`
)).at(0);
} catch (error) {
return String(error);
Expand All @@ -211,7 +210,7 @@ export async function readActiveJob(connection: IBMi, job: DebugJob) {
export async function readJVMInfo(connection: IBMi, job: DebugJob) {
try {
return (await connection.runSQL(`
select START_TIME, JAVA_HOME, USER_DIRECTORY, CURRENT_HEAP_SIZE, MAX_HEAP_SIZE
select START_TIME "Start time", JAVA_HOME "Java Home", USER_DIRECTORY "User directory", CURRENT_HEAP_SIZE "Current memory", MAX_HEAP_SIZE "Maximum allowed memory"
from QSYS2.JVM_INFO
where job_name = '${job.name}'
fetch first row only`)).at(0);
Expand Down
2 changes: 0 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { GetNewLibl } from "./components/getNewLibl";
import { extensionComponentRegistry } from "./components/manager";
import { IFSFS } from "./filesystems/ifsFs";
import { LocalActionCompletionItemProvider } from "./languages/actions/completion";
import { updateLocale } from "./locale";
import * as Sandbox from "./sandbox";
import { initialise } from "./testing";
import { CodeForIBMi, ConnectionData } from "./typings";
Expand Down Expand Up @@ -86,7 +85,6 @@ export async function activate(context: ExtensionContext): Promise<CodeForIBMi>
return (await new IBMi().connect(connectionData, undefined, reloadSettings)).success;
}
),
onCodeForIBMiConfigurationChange("locale", updateLocale),
onCodeForIBMiConfigurationChange("connections", updateLastConnectionAndServerCache),
onCodeForIBMiConfigurationChange("connectionSettings", async () => {
const connection = instance.getConnection();
Expand Down
Loading

0 comments on commit 7562569

Please sign in to comment.