Improve editor localization, localization reporting, i18n separation
All checks were successful
Build on Push and create Release on Tag / build (push) Successful in 56s

This commit is contained in:
MassiveBox 2025-08-06 17:29:42 +02:00
parent 3874378824
commit 163a1513e8
4 changed files with 23 additions and 19 deletions

View file

@ -2,15 +2,17 @@
"insertWhiteboard": "Insert whiteboard", "insertWhiteboard": "Insert whiteboard",
"editWhiteboard": "Edit whiteboard", "editWhiteboard": "Edit whiteboard",
"editShortcut": "Edit selected whiteboard", "editShortcut": "Edit selected whiteboard",
"errNoFileID": "File ID missing - couldn't open file.", "errors": {
"errNotAWhiteboard": "You must select a whiteboard, not a regular image. <a href='https://s.massive.box/jsdraw-plugin-instructions'>Usage instructions</a>", "noFileID": "File ID missing - couldn't open file.",
"errSyncIDNotFound": "Couldn't find SyncID in document for drawing, make sure you're trying to edit a whiteboard that is included in at least a note.", "notAWhiteboard": "You must select a whiteboard, not a regular image. <a href='https://s.massive.box/jsdraw-plugin-instructions'>Usage instructions</a>",
"errCreateUnknown": "Unknown error while creating editor, please try again.", "syncIDNotFound": "Couldn't find SyncID in document for drawing, make sure you're trying to edit a whiteboard that is included in at least a note.",
"errInvalidBackgroundColor": "Invalid background color! Please enter an HEX color, like #000000 (black) or #FFFFFF (white). The old background color will be used.", "createUnknown": "Unknown error while creating editor, please try again.",
"errMultipleSyncIDs": "Multiple syncIDs found in documents. Remove the drawings that don't exist from your documents.\n Sync conflict copies can cause this error, so make sure to delete them.\nFile IDs (the part you can change in the Rename menu) must be unique across all documents.\n<a href='https://git.massive.box/massivebox/siyuan-jsdraw-plugin/wiki/Errors-and-Fixes#multiple-syncids-found'>Full explanation</a>", "invalidBackgroundColor": "Invalid background color! Please enter an HEX color, like #000000 (black) or #FFFFFF (white). The old background color will be used.",
"errUnchangedProtyle": "Make sure the image you're trying to edit still exists in your documents.", "multipleSyncIDs": "Multiple syncIDs found in documents. Remove the drawings that don't exist from your documents.\n Sync conflict copies can cause this error, so make sure to delete them.\nFile IDs (the part you can change in the Rename menu) must be unique across all documents.\n<a href='https://git.massive.box/massivebox/siyuan-jsdraw-plugin/wiki/Errors-and-Fixes#multiple-syncids-found'>Full explanation</a>",
"errSaveGeneric": "Error saving! The current drawing has been copied to your clipboard. You may need to create a new drawing and paste it there.", "unchangedProtyle": "Make sure the image you're trying to edit still exists in your documents.",
"errMustSelect": "Select a whiteboard in your document by left-clicking it, then use this icon/shortcut to open the editor directly. <a href='https://s.massive.box/jsdraw-plugin-instructions'>Usage instructions</a>", "saveGeneric": "Error saving! The current drawing has been copied to your clipboard. You may need to create a new drawing and paste it there.",
"mustSelect": "Select a whiteboard in your document by left-clicking it, then use this icon/shortcut to open the editor directly. <a href='https://s.massive.box/jsdraw-plugin-instructions'>Usage instructions</a>"
},
"whiteboard": "Whiteboard", "whiteboard": "Whiteboard",
"settings": { "settings": {
"name": "js-draw Plugin Settings", "name": "js-draw Plugin Settings",

View file

@ -24,6 +24,7 @@ export class Analytics {
'frontend': getFrontend(), 'frontend': getFrontend(),
'backend': getBackend(), 'backend': getBackend(),
'language': navigator.language, 'language': navigator.language,
'appLanguage': window.siyuan.config.lang,
} : {}; } : {};
await fetch(Analytics.ENDPOINT, { await fetch(Analytics.ENDPOINT, {

View file

@ -5,7 +5,7 @@ import Editor, {
BackgroundComponentBackgroundType, BackgroundComponentBackgroundType,
BaseWidget, BaseWidget,
Color4, Color4,
EditorEventType, EditorEventType, getLocalizationTable,
Mat33, Mat33,
Vec2, Vec2,
Viewport Viewport
@ -45,6 +45,7 @@ export class PluginEditor {
this.element = document.createElement("div"); this.element = document.createElement("div");
this.element.style.height = '100%'; this.element.style.height = '100%';
this.editor = new Editor(this.element, { this.editor = new Editor(this.element, {
localization: getLocalizationTable([window.siyuan.config.lang]),
iconProvider: new MaterialIconProvider(), iconProvider: new MaterialIconProvider(),
}); });

View file

@ -21,7 +21,7 @@ export class ErrorReporter {
console.error(err); console.error(err);
let errorTxt = err.message; let errorTxt = err.message;
if(err instanceof InternationalizedError) { if(err instanceof InternationalizedError) {
errorTxt = ErrorReporter.i18n[err.key]; errorTxt = ErrorReporter.i18n.errors[err.key];
} }
if(!timeout) { if(!timeout) {
timeout = 0; timeout = 0;
@ -33,48 +33,48 @@ export class ErrorReporter {
export class SyncIDNotFoundError extends InternationalizedError { export class SyncIDNotFoundError extends InternationalizedError {
constructor() { constructor() {
super('errSyncIDNotFound'); super('syncIDNotFound');
} }
} }
export class UnchangedProtyleError extends InternationalizedError { export class UnchangedProtyleError extends InternationalizedError {
constructor() { constructor() {
super('errUnchangedProtyle'); super('unchangedProtyle');
} }
} }
export class MultipleSyncIDsError extends InternationalizedError { export class MultipleSyncIDsError extends InternationalizedError {
constructor() { constructor() {
super('errMultipleSyncIDs'); super('multipleSyncIDs');
} }
} }
export class GenericSaveError extends InternationalizedError { export class GenericSaveError extends InternationalizedError {
constructor() { constructor() {
super('errSaveGeneric'); super('saveGeneric');
} }
} }
export class NotAWhiteboardError extends InternationalizedError { export class NotAWhiteboardError extends InternationalizedError {
constructor() { constructor() {
super('errNotAWhiteboard'); super('notAWhiteboard');
} }
} }
export class InvalidBackgroundColorError extends InternationalizedError { export class InvalidBackgroundColorError extends InternationalizedError {
constructor() { constructor() {
super('errInvalidBackgroundColor'); super('invalidBackgroundColor');
} }
} }
export class NoFileIDError extends InternationalizedError { export class NoFileIDError extends InternationalizedError {
constructor() { constructor() {
super('errNoFileID'); super('noFileID');
} }
} }
export class MustSelectError extends InternationalizedError { export class MustSelectError extends InternationalizedError {
constructor() { constructor() {
super('errMustSelect'); super('mustSelect');
} }
} }