diff --git a/apps/mint/README.md b/apps/mint/README.md index f44b52d6..622e8cac 100644 --- a/apps/mint/README.md +++ b/apps/mint/README.md @@ -117,6 +117,11 @@ API `https://mint-api.juw12.workers.dev/api/health` - **Privacy and Terms in four languages,** with a switcher; English prevails if they ever differ. - **Localized spreadsheets.** Downloaded .xlsx files name their tabs, headers and tips in your language, and the formulas follow the renamed tabs. +- **Links pick the language (3.5.1).** Add `?lang=en|id|zh|es` to any Mint link (Budget, the marketplace, the + legal pages) and it opens in that language without changing the reader's saved choice. +- **Studio understands Chinese and Spanish (3.5.1).** Tweak commands such as `添加供应商列`, `货币 人民币`, + `añade la columna Proveedor` or `resalta Qty menor que 5 en rojo` now work, as the zh/es screens already + suggested; colour and currency words in those languages also steer new templates (`网店库存表,绿色` → green). - **Desktop works offline from the first launch.** The Windows and macOS apps carry a copy of Mint and open it from the computer when there is no internet; budgets made offline move into the online app the next time it connects. @@ -320,8 +325,9 @@ apps/mint/web apps/mint/cloud/src/index template. Each user gets 20 generations a day, anonymous visitors 5, with a global cap (`AI_DAILY_LIMIT`). If AI is busy, the instant rule-based generator takes over. An optional bring-your-own OpenAI-compatible model is available under Account. -- **Studio.** Tweak commands work in English and Indonesian: `add column Supplier`, - `tambah kolom Catatan`, `theme midnight`, `currency EUR`, `highlight Qty below 5 red`, +- **Studio.** Tweak commands work in English, Indonesian, Chinese and Spanish: `add column Supplier`, + `tambah kolom Catatan`, `添加供应商列`, `añade la columna Proveedor`, `theme midnight`, + `货币 人民币`, `highlight Qty below 5 red`, `resalta Qty menor que 5 en rojo`, `add column Margin = [Price] - [Cost]`. It also includes a safe formula engine (no `eval`), a real .xlsx writer (Dashboard + Data sheets, 200 ready rows, validation, conditional formats), CSV export, a content kit (X, LinkedIn, TikTok, blog/SEO, Pinterest, WhatsApp diff --git a/apps/mint/desktop/mint.spec b/apps/mint/desktop/mint.spec index 1e5160cd..e64233b5 100644 --- a/apps/mint/desktop/mint.spec +++ b/apps/mint/desktop/mint.spec @@ -6,7 +6,7 @@ import os import sys DESKTOP = os.path.dirname(os.path.abspath(SPEC)) # noqa: F821 (provided by PyInstaller) -VERSION = os.environ.get("MINT_VERSION", "3.5.0") +VERSION = os.environ.get("MINT_VERSION", "3.5.1") VERSION_FILE = os.environ.get("MINT_VERSION_FILE") or None ICON = os.environ.get("MINT_ICON") or None IS_WIN = sys.platform == "win32" diff --git a/apps/mint/desktop/mint_app.py b/apps/mint/desktop/mint_app.py index e1ae503b..1c60a6e0 100644 --- a/apps/mint/desktop/mint_app.py +++ b/apps/mint/desktop/mint_app.py @@ -30,7 +30,7 @@ import urllib.request import webbrowser -VERSION = "3.5.0" +VERSION = "3.5.1" TITLE = "Mint" APP_URL = os.environ.get("MINT_DESKTOP_URL") or "https://juw12.github.io/projects/mint/" DEFAULT_SIZE = (1280, 860) diff --git a/apps/mint/tests/test_core.py b/apps/mint/tests/test_core.py index 35d90512..548af105 100644 --- a/apps/mint/tests/test_core.py +++ b/apps/mint/tests/test_core.py @@ -153,6 +153,32 @@ def seed_checks(): var t5 = C.applyTweak(budget, "remove column Item"); var t6 = C.applyTweak(budget, "currency EUR"); var t7 = C.applyTweak(budget, "flibber the wobble"); +var tZhAdd = C.applyTweak(budget, "添加供应商列"); +var tZhOpts = C.applyTweak(budget, "添加列 状态 选项 待办、完成"); +var tZhRename = C.applyTweak(budget, "把 Planned 重命名为 计划"); +var tZhTheme = C.applyTweak(budget, "主题 深色;货币 人民币"); +var tZhRule = C.applyTweak(budget, "高亮 Actual 大于 500 红色"); +var tEsAdd = C.applyTweak(budget, "añade la columna Proveedor"); +var tEsOpts = C.applyTweak(budget, "añade columna Estado como lista con opciones Pendiente o Hecho"); +var tEsRemove = C.applyTweak(budget, "elimina la columna Item"); +var tEsSum = C.applyTweak(budget, "suma de Actual"); +var tEsCur = C.applyTweak(budget, "cambia la moneda a pesos mexicanos"); +function lastCol(r) { + return r.spec.sheet.columns.slice(-1)[0]; +} +out.tweaksIntl = { + zhAdd: lastCol(tZhAdd).name, + zhOpts: [lastCol(tZhOpts).type, lastCol(tZhOpts).options], + zhRename: tZhRename.spec.sheet.columns.map(function (c) { return c.name; }), + zhTheme: [tZhTheme.spec.theme, tZhTheme.spec.currency], + zhRule: tZhRule.spec.rules.map(function (k) { return k.column + k.op + k.value + ":" + k.style; }), + esAdd: lastCol(tEsAdd).name, + esOpts: [lastCol(tEsOpts).type, lastCol(tEsOpts).options], + esRemove: tEsRemove.spec.sheet.columns.map(function (c) { return c.name; }), + esSum: tEsSum.spec.summary.map(function (s) { return s.fn + ":" + s.column; }), + esCur: tEsCur.spec.currency, + zhGenTheme: C.generate("网店库存表,绿色").spec.theme +}; out.tweaks = { rows: t1.spec.sheet.rows.length, addedId: t2.spec.sheet.columns.map(function (c) { return c.name; }), @@ -281,6 +307,19 @@ def js_checks(): check("Item" not in tweaks["removed"], "'remove column Item'") check(tweaks["currency"] == "EUR", "'currency EUR'") check(tweaks["unknownChanged"] is False, "unknown command changes nothing") + + intl = out["tweaksIntl"] + check(intl["zhAdd"] == "供应商", "zh '添加供应商列' adds a column") + check(intl["zhOpts"] == ["select", ["待办", "完成"]], "zh options split on 、") + check("计划" in intl["zhRename"] and "Planned" not in intl["zhRename"], "zh rename 把…重命名为") + check(intl["zhTheme"] == ["midnight", "CNY"], "zh theme + currency split on ;") + check("Actual>500:bad" in intl["zhRule"], "zh highlight rule") + check(intl["esAdd"] == "Proveedor", "es 'añade la columna Proveedor'") + check(intl["esOpts"] == ["select", ["Pendiente", "Hecho"]], "es dropdown options with 'o'") + check("Item" not in intl["esRemove"], "es remove column") + check("SUM:Actual" in intl["esSum"], "es 'suma de'") + check(intl["esCur"] == "MXN", "es currency words") + check(intl["zhGenTheme"] == "forest", "zh colour word picks the theme in prompts") check(out["diffRows"] == [p[0] - p[1] for p in pairs], "Diff column evaluates per row") f = out["formulas"] diff --git a/apps/mint/web/app.html b/apps/mint/web/app.html index 46444edf..0c9656da 100644 --- a/apps/mint/web/app.html +++ b/apps/mint/web/app.html @@ -21,7 +21,7 @@ if (/[?&](embed|standalone)=1(&|$)/.test(q)) return; var inParams = new URLSearchParams(q); var out = new URLSearchParams(); - ['ref', 'coupon', 'api'].forEach(function (k) { + ['ref', 'coupon', 'api', 'lang'].forEach(function (k) { if (inParams.get(k)) out.set(k, inParams.get(k)); }); out.set('view', 'market'); diff --git a/apps/mint/web/budget/js/app.js b/apps/mint/web/budget/js/app.js index 4f3109c2..2d1fb044 100644 --- a/apps/mint/web/budget/js/app.js +++ b/apps/mint/web/budget/js/app.js @@ -1799,6 +1799,8 @@ }); keep.set('embed', '1'); keep.set('nolocale', '1'); + // The marketplace speaks Budget's language, even when a ?lang= link chose it without saving. + keep.set('lang', K.i18n.lang); let r = String(route || 'market').replace(/^#/, ''); if (r.charAt(0) !== '/') r = '/' + r; return MARKET_PAGE + '?' + keep.toString() + '#' + r; diff --git a/apps/mint/web/budget/js/core.js b/apps/mint/web/budget/js/core.js index 5584299a..923066cb 100644 --- a/apps/mint/web/budget/js/core.js +++ b/apps/mint/web/budget/js/core.js @@ -8,7 +8,7 @@ (function (root) { 'use strict'; const K = (root.MintBudget = root.MintBudget || {}); - K.VERSION = '3.5.0'; + K.VERSION = '3.5.1'; /** Compare dotted versions numerically: 1, 0 or -1 ("1.10.0" is newer than "1.9.9"). */ K.compareVersions = function (a, b) { diff --git a/apps/mint/web/budget/sw.js b/apps/mint/web/budget/sw.js index 14da620a..eb7ef52a 100644 --- a/apps/mint/web/budget/sw.js +++ b/apps/mint/web/budget/sw.js @@ -1,6 +1,6 @@ /* Mint Budget service worker: network-first app shell so updates land immediately, cache as offline fallback. * Scope is budget/ only; Mint Templates (../app.html) has its own worker at ../sw.js. */ -const CACHE = 'mint-budget-v15'; +const CACHE = 'mint-budget-v16'; // Caches this worker owns: its own generations, plus the ones versions before Mint 3.0 left behind. // Never touch other caches: every app on this origin shares one CacheStorage. const OWN_CACHE = /^(mint-budget-v|kitty-v)/; diff --git a/apps/mint/web/budget/version.json b/apps/mint/web/budget/version.json index 54de0dd6..53603fe2 100644 --- a/apps/mint/web/budget/version.json +++ b/apps/mint/web/budget/version.json @@ -1,8 +1,10 @@ { - "version": "3.5.0", + "version": "3.5.1", "released": "2026-11-09", "notes": { "en": [ + "Links can choose the language: add ?lang=es (or id, zh, en) and Budget, the marketplace and the legal pages open in it, without changing your saved choice.", + "Templates Studio understands Chinese and Spanish commands, like 添加供应商列 or añade la columna Proveedor.", "Live prices in Invest: stocks and ETFs (IDX and US), crypto and gold update from the market. Tap Refresh prices any time; prices you type yourself stay until you refresh.", "Mint asks your browser to keep its data, shows when you last backed up, and reminds you to sync or back up once a budget has real history.", "Templates and the Marketplace now speak Chinese and Spanish too, and downloaded .xlsx files use your language for tabs and tips.", @@ -10,6 +12,8 @@ "Desktop app: opens even without internet the very first time; budgets made offline move online on their own." ], "id": [ + "Tautan bisa memilih bahasa: tambahkan ?lang=id (atau en, zh, es) dan Budget, marketplace, serta halaman legal terbuka dalam bahasa itu tanpa mengubah pilihan tersimpanmu.", + "Studio Template kini memahami perintah berbahasa Mandarin dan Spanyol, seperti 添加供应商列 atau añade la columna Proveedor.", "Harga live di Investasi: saham dan ETF (BEI dan AS), kripto, dan emas mengikuti pasar. Ketuk Perbarui harga kapan saja; harga yang kamu isi sendiri tetap sampai kamu memperbarui.", "Mint meminta browser menyimpan datanya, menampilkan kapan terakhir kamu mencadangkan, dan mengingatkan untuk sinkron atau mencadangkan saat anggaran sudah berisi banyak riwayat.", "Template dan Marketplace kini juga berbahasa Mandarin dan Spanyol, dan file .xlsx yang diunduh memakai bahasamu untuk tab dan petunjuk.", @@ -17,6 +21,8 @@ "Aplikasi desktop: tetap terbuka tanpa internet sejak pertama kali; anggaran yang dibuat offline pindah ke online dengan sendirinya." ], "zh": [ + "链接可以指定语言:加上 ?lang=zh(或 en、id、es),预算、市场和法律页面就会以该语言打开,不会改变你保存的设置。", + "模板工作室现在能听懂中文和西班牙语指令,例如“添加供应商列”或“añade la columna Proveedor”。", "投资页实时价格:股票和 ETF(印尼与美股)、加密货币和黄金按市场价更新。随时点“刷新价格”;你手动填写的价格会保留到你刷新为止。", "Mint 会请求浏览器保留数据,显示上次备份时间,并在预算有了足够记录后提醒你同步或备份。", "模板和市场现在也支持中文和西班牙语,下载的 .xlsx 文件的工作表名称和提示也使用你的语言。", @@ -24,6 +30,8 @@ "桌面应用:即使第一次打开时没有网络也能使用;离线创建的预算会在联网后自动同步。" ], "es": [ + "Los enlaces pueden elegir el idioma: añade ?lang=es (o en, id, zh) y Budget, el mercado y las páginas legales se abren en ese idioma sin cambiar tu elección guardada.", + "El estudio de Plantillas entiende órdenes en chino y en español, como «añade la columna Proveedor» o 添加供应商列.", "Precios en vivo en Invertir: acciones y ETF (IDX y EE. UU.), cripto y oro se actualizan con el mercado. Toca Actualizar precios cuando quieras; los precios que escribes tú se quedan hasta que actualices.", "Mint pide al navegador que conserve sus datos, muestra cuándo hiciste la última copia y te recuerda sincronizar o hacer copia cuando un presupuesto ya tiene historial.", "Plantillas y el Marketplace ahora también hablan chino y español, y los .xlsx descargados usan tu idioma en pestañas y consejos.", diff --git a/apps/mint/web/js/app.js b/apps/mint/web/js/app.js index edc21524..f6288bfa 100644 --- a/apps/mint/web/js/app.js +++ b/apps/mint/web/js/app.js @@ -639,6 +639,10 @@ function studioChange(e) { var t = e.target; + if (!draft) { + // The prompt box (before any draft exists) also fires change events. + return; + } var spec = draft.spec; if (t.dataset.r !== undefined && t.dataset.c) { var col = spec.sheet.columns.filter(function (c) { return c.id === t.dataset.c; })[0]; @@ -823,6 +827,8 @@ if (!text) { return; } + var themeBefore = draft.spec.theme; + var currencyBefore = draft.spec.currency; var res = Core.applyTweak(draft.spec, text); draft.spec = res.spec; tweakLog.push({ who: "you", text: text }); @@ -830,7 +836,9 @@ tweakLog.push({ who: /^Didn/.test(m) ? "err" : "mint", text: m }); }); input.value = ""; - if (/theme|tema|dark|gelap/i.test(text)) { + // A new theme or currency repaints the whole Studio (colours, the Details currency picker); + // any language can change them (主题 深色, tema oscuro, 货币 人民币). + if (draft.spec.theme !== themeBefore || draft.spec.currency !== currencyBefore) { viewStudio(); } else { refreshStudio(); diff --git a/apps/mint/web/js/core.js b/apps/mint/web/js/core.js index 357cb3f0..bab962e4 100644 --- a/apps/mint/web/js/core.js +++ b/apps/mint/web/js/core.js @@ -19,14 +19,14 @@ ]; var THEME_WORDS = { - mint: ["mint", "teal", "fresh"], - ocean: ["ocean", "blue", "biru", "navy"], - sunset: ["sunset", "orange", "oranye", "warm"], - lavender: ["lavender", "purple", "ungu", "violet"], - blush: ["blush", "pink", "pastel", "cute", "aesthetic", "girly"], - forest: ["forest", "green", "hijau", "nature"], - mono: ["mono", "minimal", "minimalist", "black and white", "clean", "simple"], - midnight: ["midnight", "dark", "gelap", "night"] + mint: ["mint", "teal", "fresh", "薄荷", "menta"], + ocean: ["ocean", "blue", "biru", "navy", "蓝", "海洋", "azul", "océano", "oceano"], + sunset: ["sunset", "orange", "oranye", "warm", "橙", "日落", "naranja", "atardecer"], + lavender: ["lavender", "purple", "ungu", "violet", "紫", "薰衣草", "morado", "lavanda"], + blush: ["blush", "pink", "pastel", "cute", "aesthetic", "girly", "粉", "rosa", "rosado"], + forest: ["forest", "green", "hijau", "nature", "绿", "森林", "verde", "bosque"], + mono: ["mono", "minimal", "minimalist", "black and white", "clean", "simple", "简约", "极简", "黑白", "minimalista"], + midnight: ["midnight", "dark", "gelap", "night", "深色", "暗色", "午夜", "oscuro"] }; // scale = rough units per 1 USD, used only to size sample numbers in generated templates. @@ -77,6 +77,27 @@ [/\b(brl|reais)\b/, "BRL"], [/\b(aed|dirham|dirhams)\b/, "AED"], [/\b(php|philippine peso)\b/, "PHP"], + [/人民币/, "CNY"], + [/欧元/, "EUR"], + [/英镑|\blibras?( esterlinas?)?\b/, "GBP"], + [/新加坡元|新元/, "SGD"], + [/林吉特|马币/, "MYR"], + [/日元|\byenes\b/, "JPY"], + [/新台币|台币/, "TWD"], + [/港元|港币/, "HKD"], + [/印尼盾/, "IDR"], + [/泰铢/, "THB"], + [/越南盾/, "VND"], + [/卢比/, "INR"], + [/韩元/, "KRW"], + [/澳元/, "AUD"], + [/新西兰元|纽元/, "NZD"], + [/加元/, "CAD"], + [/\bpesos mexicanos\b/, "MXN"], + [/\bpesos colombianos\b/, "COP"], + [/雷亚尔|\breales\b/, "BRL"], + [/迪拉姆/, "AED"], + [/美元|美金|d[óo]lar(es)?\b/, "USD"], [/\b(usd|dollar|dollars)\b|\$/, "USD"] ]; @@ -624,11 +645,145 @@ var TYPE_WORDS = { text: "text", teks: "text", number: "number", angka: "number", money: "currency", currency: "currency", uang: "currency", percent: "percent", persen: "percent", date: "date", tanggal: "date", dropdown: "select", select: "select", pilihan: "select", - checkbox: "check", check: "check", "yes/no": "check", formula: "formula", rumus: "formula" + checkbox: "check", check: "check", "yes/no": "check", formula: "formula", rumus: "formula", + texto: "text", "número": "number", numero: "number", moneda: "currency", dinero: "currency", porcentaje: "percent", + fecha: "date", lista: "select", desplegable: "select", casilla: "check", "fórmula": "formula", + "文本": "text", "文字": "text", "数字": "number", "数值": "number", "金额": "currency", "货币": "currency", + "百分比": "percent", "日期": "date", "下拉": "select", "下拉框": "select", "复选框": "check", "勾选": "check", "公式": "formula" }; + // Chinese and Spanish tweak commands are rewritten into the English grammar of applyOneTweak, + // so one parser (and one set of replies) serves every language. Unknown phrasings pass through. + var ZH_TOTALS = { + "合计": "total", "总计": "total", "求和": "sum", "总和": "sum", "平均": "average", "平均值": "average", + "最大": "max", "最大值": "max", "最小": "min", "最小值": "min", "计数": "count" + }; + var ES_TOTALS = { + total: "total", suma: "sum", promedio: "average", media: "average", "máximo": "max", maximo: "max", + "mínimo": "min", minimo: "min", cuenta: "count", conteo: "count" + }; + var COLOUR_WORDS = { + "红": "red", "红色": "red", "绿": "green", "绿色": "green", "黄": "yellow", "黄色": "yellow", + rojo: "red", verde: "green", amarillo: "yellow" + }; + + function isTypeWord(word) { + return !!TYPE_WORDS[String(word).toLowerCase()]; + } + + // "供应商 类型 数字 选项 A、B" / "Estado como lista con opciones A o B" → "… as … options A, B" + function tailToEnglish(tail) { + var out = String(tail) + .replace(/\s*(?:类型为|类型是|类型|作为|设为)\s*:?\s*(\S+?)(?=\s*(?:选项|公式|=|$))/g, function (m, word) { + return isTypeWord(word) ? " as " + word : m; + }) + .replace(/\s+(?:como|de tipo|tipo)\s+(\S+)(?=\s+(?:con\s+opciones|opciones)\b|\s*=|\s*$)/gi, function (m, word) { + return isTypeWord(word) ? " as " + word : m; + }) + .replace(/\s*(?:选项为|选项是|选项)\s*:?\s*/g, " options ") + .replace(/\s+(?:con\s+opciones|opciones)\s*:?\s*/gi, " options ") + .replace(/\s*(?:公式为|公式是|公式)\s*:?\s*=?\s*/g, " = ") + .replace(/\s+f[óo]rmula\s*:?\s*=?\s*/gi, " = "); + out = out.replace(/ options (.+)$/, function (m, list) { + return " options " + list.replace(/\s*或\s*/g, ", ").replace(/\s+o\s+/gi, ", "); + }); + return out.replace(/\s+/g, " ").trim(); + } + + // Drop a trailing / leading 列 ("备注列", "列 备注") unless that is the column's real name. + function bareColumnName(spec, name) { + var n = String(name).trim(); + var exact = findColumn(spec, n); + if (exact && exact.name.toLowerCase() === n.toLowerCase()) { + return n; + } + return n.replace(/\s*(?:列|栏|字段)$/, "").replace(/^(?:列|栏|字段)\s*/, "").trim() || n; + } + + function zhTweak(spec, text) { + var s = text.replace(/:/g, ":").replace(/[,、]/g, ",").replace(/=/g, "=").trim(); + var m; + if ((m = /^(?:添加|新增|增加|加上?)\s*(\d{1,3})\s*(?:行|条)/.exec(s))) { + return "add " + m[1] + " rows"; + } + if ((m = /^(?:添加|新增|增加|加上?)\s*(?:一个?)?\s*(?:列|栏|字段)\s*:?\s*(.+)$/.exec(s))) { + return "add column " + tailToEnglish(m[1]); + } + if ((m = /^(?:添加)?\s*(合计|总计|求和|总和|平均值|平均|最大值|最大|最小值|最小|计数)\s*:?\s*(.+)$/.exec(s))) { + return ZH_TOTALS[m[1]] + " of " + bareColumnName(spec, m[2]); + } + if ((m = /^(?:添加|新增|增加|加上?)\s*(?:一个?)?\s*(.+?)\s*(?:列|栏|字段)\s*((?:类型|作为|选项|公式|=).*)?$/.exec(s))) { + return "add column " + tailToEnglish(m[1] + " " + (m[2] || "")); + } + if ((m = /^(?:删除|删掉|移除|去掉|去除)\s*:?\s*(.+)$/.exec(s))) { + return "remove column " + bareColumnName(spec, m[1]); + } + if ((m = /^(?:把|将)?\s*(?:货币|币种)\s*(?:改为|改成|换成|设为|为|用)?\s*:?\s*(.+)$/.exec(s))) { + return "currency " + m[1]; + } + if ((m = /^(?:使用|改用|换成)\s*(.+)$/.exec(s)) && detectCurrency(m[1])) { + return "currency " + m[1]; + } + if ((m = /^(?:把|将)?\s*(?:主题|配色|颜色|风格)\s*(?:改为|改成|换成|设为|为|用)?\s*:?\s*(.+)$/.exec(s))) { + return "theme " + m[1]; + } + if ((m = /^(?:把|将)?\s*(?:标题|模板名称|模板名|表名)\s*(?:改为|改成|设为|为|是)?\s*:?\s*(.+)$/.exec(s)) || + (m = /^(?:命名为|重命名模板为)\s*:?\s*(.+)$/.exec(s))) { + return "title " + m[1]; + } + if ((m = /^(?:把|将)\s*(.+?)\s*(?:重命名为|重命名成|改名为|改名成|改为|改成)\s*(.+)$/.exec(s)) || + (m = /^(?:重命名|改名)\s*(.+?)\s*(?:为|成|到|->|→)\s*(.+)$/.exec(s))) { + return "rename column " + bareColumnName(spec, m[1]) + " to " + m[2].trim(); + } + if ((m = /^(?:高亮|标记|突出显示|突出|标出)\s*(.+?)\s*(小于|低于|少于|<|大于|高于|多于|超过|>|等于|=)\s*(.+?)\s*(?:时|的)?\s*(?:标为|显示为|标|为|用)?\s*(红色|红|绿色|绿|黄色|黄)?$/.exec(s))) { + var zhOp = /小于|低于|少于|/.test(m[2]) ? "above" : "equal to"; + return "highlight " + bareColumnName(spec, m[1]) + " " + zhOp + " " + m[3] + (m[4] ? " " + COLOUR_WORDS[m[4]] : ""); + } + return text; + } + + function esTweak(spec, text) { + var s = text.trim(); + var m; + var art = "(?:(?:el|la|los|las|un|una)\\s+)?"; + if ((m = /^(?:añad[ea]|añadir|agreg[ae]|agregar|inserta|insertar)\s+(\d{1,3})\s+filas?\b/i.exec(s))) { + return "add " + m[1] + " rows"; + } + if ((m = new RegExp("^(?:añad[ea]|añadir|agreg[ae]|agregar|inserta|insertar|crea|crear)\\s+" + art + "(?:nueva\\s+)?(?:columna|campo)\\s+(.+)$", "i").exec(s))) { + return "add column " + tailToEnglish(m[1]); + } + if ((m = new RegExp("^(?:elimina|eliminar|quita|quitar|borra|borrar|suprime|suprimir)\\s+" + art + "(?:columna\\s+|campo\\s+)?(.+)$", "i").exec(s))) { + return "remove column " + m[1]; + } + if ((m = /^(?:t[íi]tulo|ll[áa]mal[ao]|ponle\s+de\s+nombre|renombra(?:r)?\s+la\s+(?:plantilla|hoja)\s+(?:a|como))\s*:?\s+(.+)$/i.exec(s))) { + return "title " + m[1]; + } + if ((m = /^(?:renombra(?:r)?|cambia(?:r)?\s+el\s+nombre\s+de)\s+(?:la\s+columna\s+|el\s+campo\s+|columna\s+)?(.+?)\s+(?:a|por|como)\s+(.+)$/i.exec(s))) { + return "rename column " + m[1] + " to " + m[2]; + } + if ((m = /^(?:(?:cambia(?:r)?|pon(?:er)?|usa(?:r)?)\s+(?:la\s+)?)?(?:moneda|divisa)\s*(?:a\s+|en\s+|:)?\s*(.+)$/i.exec(s))) { + return "currency " + m[1]; + } + if ((m = /^(?:(?:cambia(?:r)?|pon(?:er)?|usa(?:r)?)\s+(?:el\s+)?)?(?:tema|estilo|color)\b\s*(?:a\s+|en\s+|:)?\s*(.+)$/i.exec(s))) { + return "theme " + m[1]; + } + if ((m = new RegExp("^(?:(?:añad[ea]|agreg[ae])\\s+" + art + ")?(suma|promedio|media|m[áa]ximo|m[íi]nimo|cuenta|conteo)\\s+(?:de\\s+" + art + ")?(.+)$", "i").exec(s)) || + (m = new RegExp("^(?:(?:añad[ea]|agreg[ae])\\s+" + art + ")?(total)\\s+de\\s+" + art + "(.+)$", "i").exec(s))) { + return ES_TOTALS[m[1].toLowerCase()] + " of " + m[2]; + } + if ((m = /^(?:resalta(?:r)?|marca(?:r)?|destaca(?:r)?|colorea(?:r)?)\s+(?:la\s+columna\s+|el\s+campo\s+)?(.+?)\s+(?:cuando\s+(?:sea|est[ée])\s+)?(menor\s+que|menos\s+de|por\s+debajo\s+de|debajo\s+de|mayor\s+que|m[áa]s\s+de|por\s+encima\s+de|encima\s+de|igual\s+a)\s+(.+?)(?:\s+(?:en\s+)?(rojo|verde|amarillo))?$/i.exec(s))) { + var esOp = /menor|menos|debajo/i.test(m[2]) ? "below" : /mayor|m[áa]s|encima/i.test(m[2]) ? "above" : "equal to"; + return "highlight " + m[1] + " " + esOp + " " + m[3] + (m[4] ? " " + COLOUR_WORDS[m[4].toLowerCase()] : ""); + } + return text; + } + + function localizeTweak(spec, text) { + return /[\u3400-\u9fff]/.test(text) ? zhTweak(spec, text) : esTweak(spec, text); + } + function applyOneTweak(spec, raw) { - var t = raw.trim(); + var t = localizeTweak(spec, raw.trim()); var lower = t.toLowerCase(); var m; @@ -658,7 +813,7 @@ }).filter(Boolean); rest = rest.slice(0, om.index); } - var tm = /\s+(?:as|sebagai|type)\s+(?:a\s+|an\s+)?([a-z/]+)\s*$/i.exec(rest); + var tm = /\s+(?:as|sebagai|type)\s+(?:a\s+|an\s+)?(\S+)\s*$/i.exec(rest); if (tm && TYPE_WORDS[tm[1].toLowerCase()]) { type = TYPE_WORDS[tm[1].toLowerCase()]; rest = rest.slice(0, tm.index); @@ -811,7 +966,7 @@ function applyTweak(spec, text) { var next = clone(spec); - var parts = String(text || "").split(/\n|;|\.\s+(?=[A-Za-z])/).map(function (s) { + var parts = String(text || "").split(/\n|;|;|。|\.\s+(?=[A-Za-z\u00c0-\u00ff])/).map(function (s) { return s.trim().replace(/\.$/, ""); }).filter(Boolean); var messages = []; diff --git a/apps/mint/web/js/i18n-more.js b/apps/mint/web/js/i18n-more.js index 9d816fe4..c586ee7c 100644 --- a/apps/mint/web/js/i18n-more.js +++ b/apps/mint/web/js/i18n-more.js @@ -73,6 +73,8 @@ "Describe the template you want first": "请先描述你想要的模板", "Designed by Mint AI. Tweak anything below — or ask in words.": "由 Mint AI 设计。下面任何内容都可以修改——或直接用文字说明。", "AI returned too few columns": "AI 返回的列太少", + "add column Supplier theme ocean highlight Qty below 5 red": "添加供应商列 · 主题 ocean · 高亮 数量 小于 5 红色", + "No matching blueprint, so I built a custom tracker from your words.": "没有匹配的蓝本,所以根据你的描述做了一个自定义表格。", "Tweak with words": "用文字修改", "Type a change and press Apply.": "输入修改内容,然后点“应用”。", "Apply": "应用", @@ -654,6 +656,8 @@ "Describe the template you want first": "Primero describe la plantilla que quieres", "Designed by Mint AI. Tweak anything below — or ask in words.": "Diseñada por Mint AI. Ajusta lo que quieras abajo, o pídelo con palabras.", "AI returned too few columns": "La IA devolvió muy pocas columnas", + "add column Supplier theme ocean highlight Qty below 5 red": "añade la columna Proveedor · tema ocean · resalta Cantidad menor que 5 en rojo", + "No matching blueprint, so I built a custom tracker from your words.": "No encontré una plantilla base, así que creé un registro a medida con tus palabras.", "Tweak with words": "Ajusta con palabras", "Type a change and press Apply.": "Escribe un cambio y pulsa Aplicar.", "Apply": "Aplicar", @@ -1203,9 +1207,13 @@ [/^Renamed “(.+)” to “(.+)”\.$/, "已将“$1”重命名为“$2”。"], [/^Currency changed to (.+)\.$/, "货币已改为 $1。"], [/^Theme set to (.+)\.$/, "主题已设为 $1。"], + [/^Theme: (.+)\.$/, "主题:$1。"], + [/^Currency: (\w+)\.$/, "货币:$1。"], + [/^AI unavailable \((.+)\) — used the quick generator\.$/, "AI 暂不可用($1)——已改用快速生成器。"], + [/^Generated with your AI model \((.+)\)\.$/, "由你的 AI 模型($1)生成。"], [/^Added a (\w+) card for “(.+)”\.$/, "已为“$2”添加 $1 卡片。"], [/^Highlight rule added on “(.+)”\.$/, "已在“$1”上添加高亮规则。"], - [/^Didn’t understand “(.+)”\. Try: (.+)$/, "没听懂“$1”。试试:$2"], + [/^Didn’t understand “(.+)”\. Try: (.+)$/, "没听懂“$1”。试试:添加列 优先级 · 删除列 备注 · 把 成本 重命名为 价格 · 添加 5 行 · 主题 ocean · 货币 CNY · 合计 金额 · 高亮 利润 小于 0 红色。"], [/^(.+) connected — orders now unlock automatically$/, "$1 已连接——订单现在会自动解锁"] ]; var RULES_ES = [ @@ -1244,9 +1252,13 @@ [/^Renamed “(.+)” to “(.+)”\.$/, "“$1” renombrada a “$2”."], [/^Currency changed to (.+)\.$/, "Moneda cambiada a $1."], [/^Theme set to (.+)\.$/, "Tema cambiado a $1."], + [/^Theme: (.+)\.$/, "Tema: $1."], + [/^Currency: (\w+)\.$/, "Moneda: $1."], + [/^AI unavailable \((.+)\) — used the quick generator\.$/, "IA no disponible ($1): usé el generador rápido."], + [/^Generated with your AI model \((.+)\)\.$/, "Generado con tu modelo de IA ($1)."], [/^Added a (\w+) card for “(.+)”\.$/, "Tarjeta $1 añadida para “$2”."], [/^Highlight rule added on “(.+)”\.$/, "Regla de resaltado añadida en “$1”."], - [/^Didn’t understand “(.+)”\. Try: (.+)$/, "No entendí “$1”. Prueba: $2"], + [/^Didn’t understand “(.+)”\. Try: (.+)$/, "No entendí “$1”. Prueba: añade columna Prioridad · elimina la columna Notas · renombra Costo a Precio · añade 5 filas · tema ocean · moneda EUR · suma de Importe · resalta Beneficio menor que 0 en rojo."], [/^(.+) connected — orders now unlock automatically$/, "$1 conectado: los pedidos ahora se desbloquean solos"] ]; diff --git a/apps/mint/web/js/i18n.js b/apps/mint/web/js/i18n.js index 5507c914..92bdb264 100644 --- a/apps/mint/web/js/i18n.js +++ b/apps/mint/web/js/i18n.js @@ -100,6 +100,8 @@ "Describe the template you want first": "Jelaskan dulu template yang kamu mau", "Designed by Mint AI. Tweak anything below — or ask in words.": "Dirancang oleh Mint AI. Ubah apa saja di bawah — atau minta dengan kata-kata.", "AI returned too few columns": "AI mengembalikan terlalu sedikit kolom", + "add column Supplier theme ocean highlight Qty below 5 red": "tambah kolom Pemasok · tema ocean · warnai Qty below 5 red", + "No matching blueprint, so I built a custom tracker from your words.": "Tidak ada cetak biru yang cocok, jadi aku membuat tracker khusus dari kata-katamu.", "Tweak with words": "Ubah dengan kata-kata", "Type a change and press Apply.": "Ketik perubahan lalu tekan Terapkan.", "Apply": "Terapkan", @@ -703,6 +705,10 @@ [/^Renamed “(.+)” to “(.+)”\.$/, "“$1” diganti nama menjadi “$2”."], [/^Currency changed to (.+)\.$/, "Mata uang diganti ke $1."], [/^Theme set to (.+)\.$/, "Tema diatur ke $1."], + [/^Theme: (.+)\.$/, "Tema: $1."], + [/^Currency: (\w+)\.$/, "Mata uang: $1."], + [/^AI unavailable \((.+)\) — used the quick generator\.$/, "AI tidak tersedia ($1) — memakai generator cepat."], + [/^Generated with your AI model \((.+)\)\.$/, "Dibuat dengan model AI-mu ($1)."], [/^Added a (\w+) card for “(.+)”\.$/, "Kartu $1 untuk “$2” ditambahkan."], [/^Highlight rule added on “(.+)”\.$/, "Aturan sorotan ditambahkan pada “$1”."], [/^Didn’t understand “(.+)”\. Try: (.+)$/, "Tidak paham “$1”. Coba: $2"], @@ -772,6 +778,12 @@ // ---------------------------------------------------------------- state function detect() { try { + // A shared link can pick the language (?lang=es), like Budget and the legal pages; it is not saved. + var search = (root.location && root.location.search) || ""; + var linked = /[?&]lang=([a-z]{2})(?:&|$)/i.exec(search); + if (linked && LANGS[linked[1].toLowerCase()]) { + return linked[1].toLowerCase(); + } var saved = localStorage.getItem(KEY); if (saved) { return LANGS[saved] ? saved : "en"; diff --git a/apps/mint/web/js/locale.js b/apps/mint/web/js/locale.js index 6cf64f19..e1e3c15e 100644 --- a/apps/mint/web/js/locale.js +++ b/apps/mint/web/js/locale.js @@ -161,6 +161,13 @@ } function guessLang() { + try { + // A shared link (?lang=es) pre-selects that language on the first-visit screen too. + var fromUrl = new URLSearchParams(root.location.search).get('lang'); + if (fromUrl && supportedLang(fromUrl)) return fromUrl; + } catch (e) { + /* no location (tests) */ + } var langs = browserLanguages(); for (var i = 0; i < langs.length; i++) { var base = langs[i].toLowerCase().split('-')[0]; diff --git a/apps/mint/web/sw.js b/apps/mint/web/sw.js index 2c2b8eb1..9cc6c7e4 100644 --- a/apps/mint/web/sw.js +++ b/apps/mint/web/sw.js @@ -1,6 +1,6 @@ /* Mint Templates service worker — app shell cache. API calls (api/...) always go to the network. * Mint Budget (budget/) has its own worker with the narrower scope budget/, so it is not cached here. */ -var CACHE = "mint-v3.5.0"; +var CACHE = "mint-v3.5.1"; var SHELL = [ "./", "index.html", "app.html", "web.html", "mobile.html", "privacy.html", "terms.html", "delete-account.html", "app.css", "js/locale.js", "js/mint-cloud.js", "js/core.js", "js/xlsx.js", "js/guides.js", "js/store.js", "js/i18n-more.js", "js/i18n.js", "js/app.js",