System
diff --git a/www/jslicense.html b/www/jslicense.html
index f3c8eaa..d789a95 100644
--- a/www/jslicense.html
+++ b/www/jslicense.html
@@ -42,10 +42,16 @@
i18n.js |
- Expat |
- i18n.js |
+ CC0-1.0-only |
+ i18n.js |
For internationalization (language support) |
+
+ i18n-ext.js |
+ CC0-1.0-only |
+ i18n-ext.js |
+ I18n "extensions" |
+
main.js |
GNU-GPL-3.0-or-later |
diff --git a/www/lang/de-DE.json b/www/lang/de-DE.json
index 009408d..357924c 100644
--- a/www/lang/de-DE.json
+++ b/www/lang/de-DE.json
@@ -1,65 +1,61 @@
{
- "values": {
- "cat-printer": "Cat Printer",
- "printer": "Drucker",
- "device-": "Gerät:",
- "refresh": "Aktualisieren",
- "mode-": "Modus:",
- "canvas": "Leinwand",
- "document": "Dokument",
- "insert-picture": "Bild einfügen",
- "help": "Hilfe",
- "javascript-license-information": "Informationen zur JavaScript-Lizenz",
- "settings": "Einstellungen",
- "image": "Bild",
- "monochrome-algorithm-": "Schwarzweiß-Algorithmus:",
- "direct": "Direkt",
- "floyd-steinberg": "Floyd Steinberg",
- "halftone": "Halbtone",
- "wave": "Wave",
- "fall": "Fall",
- "legacy": "Legacy",
- "threshold-": "Schwellwert",
- "transmission-speed-": "Übertragungsgeschwindigkeit:",
- "low": "Gering",
- "moderate": "Moderat",
- "high": "Hoch",
- "transparent-as-white": "Transparent als Weiß",
- "misc": "Sonstiges",
- "system": "System",
- "disable-page-animation": "Seitenanimation ausschalten",
- "exit": "Exit",
- "error-message": "Fehlermeldung",
- "preview": "Vorschau",
- "print": "Drucken",
- "expand": "Erweitern",
- "crop": "Zuschneiden",
- "scanning-for-devices": "Scannen nach Geräten…",
- "scan-time-": "Scanzeit:",
- "-seconds": "Sekunden",
- "no-available-devices-found": "Keine verfügbaren Geräte gefunden",
- "found-1-available-devices": [
- [1, 1, "1 verfügbares Gerät gefunden"],
- [2, null, "%n verfügbare Geräte gefunden"]
- ],
- "please-check-if-the-printer-is-down": "Bitte prüfe, ob der Drucker ausgeschaltet ist",
- "printing": "Drucken…",
- "finished": "Fertiggestellt",
- "coming-soon-": "Demnächst verfügbar…",
- "dry-run": "Testlauf",
- "dry-run-test-print-process-only": "Testlauf: nur Probedruckvorgang",
- "you-can-close-this-page-manually": "Sie können diese Seite manuell schließen",
- "please-enable-bluetooth": "Bitte aktivieren Sie Bluetooth",
- "error-happened-please-check-error-message": "Fehler aufgetreten, bitte Fehlermeldung einsehen",
- "you-can-seek-for-help-with-detailed-info-below": "Sie können mit den nachstehenden ausführlichen Informationen Hilfe bekommen.",
- "or-try-to-scan-longer": "Oder versuchen Sie, länger zu suchen",
- "print-pbm-image-to-cat-printer": "PBM-Bild auf Cat Printer drucken.",
- "supported-models-": "Unterstützte Modelle:",
- "path-to-pbm-file-dash-for-stdin": "Pfad zur PBM-Datei. '-' für stdin.",
- "scan-for-specified-seconds": "Suchlauf für die angegebenen Sekunden",
- "specify-printer-mac-address": "Geben Sie die MAC-Adresse des Druckers an",
- "communication-frequency-0.8-or-1-recommended": "Übermittlungsfrequenz. 0,8 oder 1 empfohlen.",
- "dump-the-traffic-to-printer-and-pbm-image-when-text-printing": "Den Datenverkehr auf dem Drucker ausgeben und PBM-Bild beim Textdruck.",
- "text-printing-mode-input-text-from-stdin": "Textdruckmodus, Eingabe von stdin."
- }
+ "cat-printer": "Cat Printer",
+ "printer": "Drucker",
+ "device-": "Gerät:",
+ "refresh": "Aktualisieren",
+ "mode-": "Modus:",
+ "canvas": "Leinwand",
+ "document": "Dokument",
+ "insert-picture": "Bild einfügen",
+ "help": "Hilfe",
+ "javascript-license-information": "Informationen zur JavaScript-Lizenz",
+ "settings": "Einstellungen",
+ "image": "Bild",
+ "monochrome-algorithm-": "Schwarzweiß-Algorithmus:",
+ "direct": "Direkt",
+ "floyd-steinberg": "Floyd Steinberg",
+ "halftone": "Halbtone",
+ "wave": "Wave",
+ "fall": "Fall",
+ "legacy": "Legacy",
+ "threshold-": "Schwellwert",
+ "transmission-speed-": "Übertragungsgeschwindigkeit:",
+ "low": "Gering",
+ "moderate": "Moderat",
+ "high": "Hoch",
+ "transparent-as-white": "Transparent als Weiß",
+ "misc": "Sonstiges",
+ "system": "System",
+ "disable-page-animation": "Seitenanimation ausschalten",
+ "exit": "Exit",
+ "error-message": "Fehlermeldung",
+ "preview": "Vorschau",
+ "print": "Drucken",
+ "expand": "Erweitern",
+ "crop": "Zuschneiden",
+ "scanning-for-devices": "Scannen nach Geräten…",
+ "scan-time-": "Scanzeit:",
+ "-seconds": "Sekunden",
+ "no-available-devices-found": "Keine verfügbaren Geräte gefunden",
+ "found-0-available-devices": {
+ "single": "{0} verfügbares Gerät gefunden",
+ "multiple": "{0} verfügbare Geräte gefunden"
+ },
+ "please-check-if-the-printer-is-down": "Bitte prüfe, ob der Drucker ausgeschaltet ist",
+ "printing": "Drucken…",
+ "finished": "Fertiggestellt",
+ "coming-soon-": "Demnächst verfügbar…",
+ "dry-run": "Testlauf",
+ "dry-run-test-print-process-only": "Testlauf: nur Probedruckvorgang",
+ "you-can-close-this-page-manually": "Sie können diese Seite manuell schließen",
+ "please-enable-bluetooth": "Bitte aktivieren Sie Bluetooth",
+ "error-happened-please-check-error-message": "Fehler aufgetreten, bitte Fehlermeldung einsehen",
+ "you-can-seek-for-help-with-detailed-info-below": "Sie können mit den nachstehenden ausführlichen Informationen Hilfe bekommen",
+ "or-try-to-scan-longer": "Oder versuchen Sie, länger zu suchen",
+ "print-to-cat-printer": "PBM-Bild auf Cat Printer drucken",
+ "supported-models-": "Unterstützte Modelle:",
+ "path-to-input-file-dash-for-stdin": "Pfad zur Datei. '-' für stdin",
+ "scan-for-specified-seconds": "Suchlauf für die angegebenen Sekunden",
+ "dump-the-traffic": "Den Datenverkehr auf dem Drucker ausgeben und PBM-Bild beim Textdruck",
+ "text-printing-mode": "Textdruckmodus"
}
\ No newline at end of file
diff --git a/www/lang/en-US.json b/www/lang/en-US.json
index 166f517..ecc0828 100644
--- a/www/lang/en-US.json
+++ b/www/lang/en-US.json
@@ -1,67 +1,87 @@
{
- "values": {
- "cat-printer": "Cat Printer",
- "printer": "Printer",
- "device-": "Device:",
- "refresh": "Refresh",
- "mode-": "Mode:",
- "canvas": "Canvas",
- "document": "Document",
- "insert-picture": "Insert Picture",
- "help": "Help",
- "javascript-license-information": "JavaScript License Information",
- "settings": "Settings",
- "image": "Image",
- "monochrome-algorithm-": "Monochrome Algorithm:",
- "direct": "Direct",
- "floyd-steinberg": "Floyd Steinberg",
- "halftone": "Halftone",
- "wave": "Wave",
- "fall": "Fall",
- "legacy": "Legacy",
- "threshold-": "Threshold",
- "transmission-speed-": "Transmission Speed:",
- "low": "Low",
- "moderate": "Moderate",
- "high": "High",
- "transparent-as-white": "Transparent as White",
- "misc": "Misc",
- "system": "System",
- "disable-page-animation": "Disable Page Animation",
- "exit": "Exit",
- "error-message": "Error Message",
- "preview": "Preview",
- "print": "Print",
- "expand": "Expand",
- "crop": "Crop",
- "scanning-for-devices": "Scanning for devices…",
- "scan-time-": "Scan time:",
- "-seconds": "seconds",
- "no-available-devices-found": "No available devices found",
- "found-1-available-devices": [
- [1, 1, "Found 1 available device"],
- [2, null, "Found %n available devices"]
- ],
- "please-check-if-the-printer-is-down": "Please check if the printer is down",
- "printing": "Printing…",
- "finished": "Finished",
- "coming-soon-": "Coming Soon…",
- "dry-run": "Dry Run",
- "dry-run-test-print-process-only": "Dry Run: test print process only",
- "you-can-close-this-page-manually": "You can close this page manually",
- "please-enable-bluetooth": "Please enable Bluetooth",
- "error-happened-please-check-error-message": "Error happened, please check error message",
- "you-can-seek-for-help-with-detailed-info-below": "You can seek for help with detailed info below.",
+ "cat-printer": "Cat Printer",
+ "printer": "Printer",
+ "device-": "Device:",
+ "refresh": "Refresh",
+ "mode-": "Mode:",
+ "canvas": "Canvas",
+ "document": "Document",
+ "insert-picture": "Insert Picture",
+ "help": "Help",
+ "javascript-license-information": "JavaScript License Information",
+ "settings": "Settings",
+ "image": "Image",
+ "monochrome-algorithm-": "Monochrome Algorithm:",
+ "direct": "Direct",
+ "floyd-steinberg": "Floyd Steinberg",
+ "halftone": "Halftone",
+ "wave": "Wave",
+ "fall": "Fall",
+ "legacy": "Legacy",
+ "threshold-": "Threshold",
+ "transmission-speed-": "Transmission Speed:",
+ "low": "Low",
+ "moderate": "Moderate",
+ "high": "High",
+ "transparent-as-white": "Transparent as White",
+ "misc": "Misc",
+ "system": "System",
+ "disable-page-animation": "Disable Page Animation",
+ "exit": "Exit",
+ "error-message": "Error Message",
+ "preview": "Preview",
+ "print": "Print",
+ "expand": "Expand",
+ "crop": "Crop",
+ "scanning-for-devices": "Scanning for devices…",
+ "scan-time-": "Scan time:",
+ "-seconds": "seconds",
+ "no-available-devices-found": "No available devices found",
+ "found-0-available-devices": {
+ "single": "Found {0} available device",
+ "multiple": "Found {0} available devices"
+ },
+ "please-check-if-the-printer-is-down": "Please check if the printer is down",
+ "printing": "Printing…",
+ "finished": "Finished",
+ "coming-soon-": "Coming Soon…",
+ "dry-run": "Dry Run",
+ "dry-run-test-print-process-only": "Dry Run: test print process only",
+ "you-can-close-this-page-manually": "You can close this page manually",
+ "please-enable-bluetooth": "Please enable Bluetooth",
+ "error-happened-please-check-error-message": "Error happened, please check error message",
+ "you-can-seek-for-help-with-detailed-info-below": "You can seek for help with detailed info below",
- "or-try-to-scan-longer": "Or try to scan longer",
- "print-pbm-image-to-cat-printer": "Print PBM image to Cat Printer.",
- "supported-models-": "Supported models:",
- "path-to-pbm-file-dash-for-stdin": "Path to PBM file. '-' for stdin.",
- "scan-for-specified-seconds": "Scan for specified seconds",
- "specify-printer-mac-address": "Specify printer MAC address",
- "communication-frequency-0.8-or-1-recommended": "Communication frequency. 0.8 or 1 recommended.",
+ "or-try-to-scan-longer": "Or try to scan longer",
+ "print-to-cat-printer": "Print to Cat Printer",
+ "supported-models-": "Supported models:",
+ "path-to-input-file-dash-for-stdin": "Path to input file. '-' for stdin",
+ "scan-for-specified-seconds": "Scan for specified seconds",
- "dump-the-traffic-to-printer-and-pbm-image-when-text-printing": "Dump the traffic to printer, and PBM image when text printing.",
- "text-printing-mode-input-text-from-stdin": "Text printing mode, input from stdin."
- }
+ "dump-the-traffic": "Dump the traffic",
+ "text-printing-mode": "Text printing mode",
+
+ "please-install-pyobjc-via-pip": "Please install `pyobjc` via pip",
+ "please-install-bleak-via-pip": "Please install `bleak` via pip",
+ "folder-printer_lib-is-incomplete-or-missing-please-check": "Folder `printer_lib` is incomplete or missing, please check",
+ "input-is-not-pbm-image": "Input is not PBM image",
+ "unsuitable-image-width-expected-0-got-1": "Unsuitable image width, expected {0}, got {1}",
+ "broken-pbm-image": "Broken PBM image",
+ "input-is-not-text-file": "Input is not text file",
+ "match-printer-with-this-name-or-address": "Match printer with this name or address",
+ "virtual-run-on-specified-model": "Virtual run on specified model",
+ "font-size-0": "Font size {0}",
+ "stopping": "Stopping",
+ "connecting": "Connecting",
+ "model-0-is-not-supported-yet": "Model '{0}' is not supported yet",
+ "invalid-address-0": "Invalid address: '{0}'",
+ "will-listen-on-all-addresses": "Will listen on ALL addresses",
+ "serving-at-0": "Serving at {0}",
+ "disconnecting-from-printer": "Disconnecting from printer",
+ "connected-to-0-1": "Connected to {0} {1}",
+ "flip-horizontally": "Flip Horizontally",
+ "flip-vertically": "Flip Vertically",
+ "dump-traffic": "Dump Traffic",
+ "right-to-left-text-order": "Right-to-left text order",
+ "auto-wrap-line": "Auto wrap line"
}
\ No newline at end of file
diff --git a/www/lang/zh-CN.json b/www/lang/zh-CN.json
index a079ee1..45f983e 100644
--- a/www/lang/zh-CN.json
+++ b/www/lang/zh-CN.json
@@ -1,66 +1,83 @@
{
- "values": {
- "cat-printer": "猫咪打印机",
- "printer": "打印机",
- "device-": "设备:",
- "refresh": "刷新",
- "mode-": "模式:",
- "canvas": "画布",
- "document": "文档",
- "insert-picture": "插入图片",
- "help": "帮助",
- "javascript-license-information": "JavaScript 许可证信息",
- "settings": "设置",
- "monochrome-algorithm-": "单色化算法:",
- "direct": "直接",
- "image": "图像",
- "floyd-steinberg": "科学",
- "halftone": "点状",
- "wave": "波纹",
- "fall": "下落",
- "legacy": "旧版",
- "threshold-": "阈值:",
- "transmission-speed-": "传输速度:",
- "low": "低",
- "moderate": "适中",
- "high": "高",
- "transparent-as-white": "透明为白色",
- "misc": "杂项",
- "system": "系统",
- "disable-page-animation": "禁用页面动画",
- "exit": "退出",
- "error-message": "错误消息",
- "preview": "预览",
- "print": "打印",
- "expand": "扩大",
- "crop": "裁减",
- "scanning-for-devices": "正在扫描设备……",
- "scan-time-": "扫描时间:",
- "-seconds": "秒",
- "no-available-devices-found": "未发现可用设备",
- "found-1-available-devices": [
- [1, null, "发现 %n 个可用设备"]
- ],
- "please-check-if-the-printer-is-down": "请检查打印机是否已关闭",
- "printing": "打印中……",
- "finished": "完成",
- "coming-soon-": "即将到来……",
- "dry-run": "干运行",
- "dry-run-test-print-process-only": "干运行:仅测试打印流程",
- "you-can-close-this-page-manually": "您可手动关闭此页面",
- "please-enable-bluetooth": "请启用蓝牙",
- "error-happened-please-check-error-message": "发生错误,请检查错误消息",
- "you-can-seek-for-help-with-detailed-info-below": "您可以使用以下详细信息寻求帮助。",
+ "cat-printer": "猫咪打印机",
+ "printer": "打印机",
+ "device-": "设备:",
+ "refresh": "刷新",
+ "mode-": "模式:",
+ "canvas": "画布",
+ "document": "文档",
+ "insert-picture": "插入图片",
+ "help": "帮助",
+ "javascript-license-information": "JavaScript 许可证信息",
+ "settings": "设置",
+ "monochrome-algorithm-": "单色化算法:",
+ "direct": "直接",
+ "image": "图像",
+ "floyd-steinberg": "科学",
+ "halftone": "点状",
+ "wave": "波纹",
+ "fall": "下落",
+ "legacy": "旧版",
+ "threshold-": "阈值:",
+ "transmission-speed-": "传输速度:",
+ "low": "低",
+ "moderate": "适中",
+ "high": "高",
+ "transparent-as-white": "透明为白色",
+ "misc": "杂项",
+ "system": "系统",
+ "disable-page-animation": "禁用页面动画",
+ "exit": "退出",
+ "error-message": "错误消息",
+ "preview": "预览",
+ "print": "打印",
+ "expand": "扩大",
+ "crop": "裁减",
+ "scanning-for-devices": "正在扫描设备……",
+ "scan-time-": "扫描时间:",
+ "-seconds": "秒",
+ "no-available-devices-found": "未发现可用设备",
+ "found-0-available-devices": "发现 {0} 个可用设备",
+ "please-check-if-the-printer-is-down": "请检查打印机是否已关闭",
+ "printing": "打印中……",
+ "finished": "完成",
+ "coming-soon-": "即将到来……",
+ "dry-run": "干运行",
+ "dry-run-test-print-process-only": "干运行:仅测试打印流程",
+ "you-can-close-this-page-manually": "您可手动关闭此页面",
+ "please-enable-bluetooth": "请启用蓝牙",
+ "error-happened-please-check-error-message": "发生错误,请检查错误消息",
+ "you-can-seek-for-help-with-detailed-info-below": "您可以使用以下详细信息寻求帮助",
- "or-try-to-scan-longer": "或者尝试延长扫描时间",
- "print-pbm-image-to-cat-printer": "打印 PBM 图片到猫咪打印机。",
- "supported-models-": "支持的型号:",
- "path-to-pbm-file-dash-for-stdin": "PBM 文件的位置。“-” 作为标准输入。",
- "scan-for-specified-seconds": "扫描指定的时长。",
- "specify-printer-mac-address": "指定打印机的 MAC 地址",
- "communication-frequency-0.8-or-1-recommended": "通讯频率。推荐 0.8 或 1。",
+ "or-try-to-scan-longer": "或者尝试延长扫描时间",
+ "print-to-cat-printer": "打印到猫咪打印机。",
+ "supported-models-": "支持的型号:",
+ "path-to-input-file-dash-for-stdin": "输入文件的位置。使用 '-' 作为标准输入",
+ "scan-for-specified-seconds": "扫描指定的时长",
- "dump-the-traffic-to-printer-and-pbm-image-when-text-printing": "转储到打印机的数据,和文字打印模式的 PBM 图像。",
- "text-printing-mode-input-text-from-stdin": "文字打印模式,将从标准输入读取文字。"
- }
+ "dump-the-traffic": "转储数据",
+ "text-printing-mode": "文字打印模式",
+
+ "please-install-pyobjc-via-pip": "请从 pip 安装 `pyobjc`",
+ "please-install-bleak-via-pip": "请从 pip 安装 `bleak`",
+ "folder-printer_lib-is-incomplete-or-missing-please-check": "文件夹 `printer_lib` 不完整或丢失,请检查",
+ "input-is-not-pbm-image": "输入不是 PBM 图像",
+ "unsuitable-image-width-expected-0-got-1": "不适合的图像宽度,需要 {0}, 输入为 {1}",
+ "broken-pbm-image": "损坏的 PBM 图像",
+ "input-is-not-text-file": "输入不是文本文件",
+ "match-printer-with-this-name-or-address": "使用符合此名称或地址的打印机",
+ "virtual-run-on-specified-model": "在指定的型号模拟运行",
+ "font-size-0": "字体大小 {0}",
+ "stopping": "停止中",
+ "connecting": "正在连接",
+ "model-0-is-not-supported-yet": "型号 '{0}' 仍未支持",
+ "invalid-address-0": "无效的地址:'{0}'",
+ "will-listen-on-all-addresses": "将接受所有地址的连接",
+ "serving-at-0": "服务器在 {0}",
+ "disconnecting-from-printer": "正在从打印机断开连接",
+ "flip-horizontally": "水平翻转",
+ "flip-vertically": "垂直翻转",
+ "dump-traffic": "转储数据",
+ "right-to-left-text-order": "从右到左的文字顺序",
+ "auto-wrap-line": "自动折行"
}
\ No newline at end of file
diff --git a/www/loader.js b/www/loader.js
index 5be8fc9..a37204e 100644
--- a/www/loader.js
+++ b/www/loader.js
@@ -6,7 +6,7 @@
var fallbacks = [
// main scripts, which we will directly modify
- 'i18n.js', 'image.js', 'main.js',
+ 'i18n-ext.js', 'i18n.js', 'image.js', 'main.js',
// "compatibility" script, produced with eg. typescript tsc
'main.comp.js'
];
diff --git a/www/main.js b/www/main.js
index 3a5fe8f..5e03596 100644
--- a/www/main.js
+++ b/www/main.js
@@ -38,13 +38,13 @@ class _Notice {
constructor() {
this.element = document.getElementById('notice');
}
- _message(message, ...args) {
- this.element.innerText = i18n(message, ...args) || message;
+ _message(message, things) {
+ this.element.innerText = i18n(message, things) || message;
}
makeLogger(class_name) {
- return (message, ...args) => {
+ return (message, things) => {
this.element.classList.value = class_name;
- this._message(message, ...args);
+ this._message(message, things);
}
}
notice = this.makeLogger('notice');
@@ -373,7 +373,7 @@ class Main {
putEvent('#button-exit', 'click', this.exit, this);
putEvent('#button-print', 'click', this.print, this);
putEvent('#device-refresh', 'click', this.searchDevices, this);
- this.attachSetter('#scan-time', 'change', 'scan_time');
+ this.attachSetter('#scan-time', 'change', 'scan_timeout');
this.attachSetter('#device-options', 'input', 'printer');
this.attachSetter('input[name="algo"]', 'change', 'mono_algorithm');
this.attachSetter('#transparent-as-white', 'change', 'transparent_as_white');
@@ -387,7 +387,9 @@ class Main {
this.attachSetter('#threshold', 'change', 'threshold',
(value) => this.canvasController.threshold = value
);
- this.attachSetter('#frequency', 'change', 'frequency');
+ this.attachSetter('#flip-h', 'change', 'flip_h');
+ this.attachSetter('#flip-v', 'change', 'flip_v');
+ this.attachSetter('#dump', 'change', 'dump');
await this.loadConfig();
this.searchDevices();
resolve();
@@ -488,7 +490,7 @@ class Main {
hint('#device-refresh');
return;
}
- Notice.notice('found-1-available-devices', devices.length);
+ Notice.notice('found-0-available-devices', [devices.length]);
hint('#insert-picture');
devices.forEach(device => {
let option = document.createElement('option');
@@ -519,18 +521,15 @@ class Main {
}
async initI18n() {
if (typeof i18n === 'undefined') return;
- let language_list = navigator.languages;
- let loaded_languages = [];
- let data;
- for (let i = language_list.length - 1; i >= 0; i--) {
- data = await fetch(`/lang/${language_list[i]}.json`)
+ i18n.useLanguage(navigator.languages[0]);
+ for (let language of navigator.languages) {
+ let data = await fetch(`/lang/${language}.json`)
.then(response => response.ok ? response.json() : null);
if (data !== null) {
- i18n.translator.add(data);
- loaded_languages.unshift(language_list[i]);
+ i18n.add(language, data);
+ console.log('Loaded language:', language);
}
}
- console.log('Language stack:', loaded_languages);
let elements = document.querySelectorAll('*[data-i18n]');
let i18n_data, translated_string;
elements.forEach(element => {