mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-17 11:58:06 +00:00
i18n: a quoted message value is found at its own place
message() kept a placeholder value in English whenever the same text appeared in quotes anywhere in the message, so for a property named like the reason, "cannot assign to property 'it is read-only': it is read-only", the reason after the colon stayed in English. The quote check now looks at the characters around the value's own position. The merge of main left 13 script interpreter rows twice in ja.tsv and hu.tsv, which failed bundled_catalogs_are_consistent. The rows this branch added are removed and main's rows stay.
This commit is contained in:
@@ -694,9 +694,15 @@ fn message_at(lang: Lang, s: &str, depth: usize) -> String {
|
||||
let count = caps.iter().find(|(k, _)| *k == "n").and_then(|(_, v)| v.parse::<u64>().ok());
|
||||
let form = count.map_or(forms.len().saturating_sub(1), |n| (lang.0.plural)(n).min(forms.len().saturating_sub(1)));
|
||||
let Some(template) = forms.get(form) else { return s.to_string() };
|
||||
let quoted = |v: &str| [('"', '"'), ('“', '”'), ('\'', '\''), ('`', '`')].iter().any(|(a, b)| s.contains(&format!("{a}{v}{b}")));
|
||||
// A value is quoted when quotes surround it at its own place in `s`. The same text quoted at
|
||||
// another place in `s` (a property named like the reason given for it) does not count.
|
||||
let quoted = |v: &str| {
|
||||
let at = (v.as_ptr() as usize).checked_sub(s.as_ptr() as usize);
|
||||
let Some((before, after)) = at.and_then(|at| Some((s.get(..at)?, s.get(at + v.len()..)?))) else { return false };
|
||||
[('"', '"'), ('“', '”'), ('\'', '\''), ('`', '`')].iter().any(|(a, b)| before.ends_with(*a) && after.starts_with(*b))
|
||||
};
|
||||
let nested = |v: &str| {
|
||||
if depth <= 1 || quoted(v) {
|
||||
if depth <= 1 || v.is_empty() || quoted(v) {
|
||||
v.to_string()
|
||||
} else if v.starts_with(['{', '[']) {
|
||||
exact_translation(lang.catalog(), v).unwrap_or_else(|| v.to_string())
|
||||
|
||||
@@ -5130,19 +5130,6 @@ imageTrace Outline Körvonal
|
||||
@msg $.evalFile requires a file path A $.evalFile fájlútvonalat igényel
|
||||
@msg $.evalFile: the timeout must be a finite number of milliseconds, 0 or more $.evalFile: az időkorlátnak véges számú ezredmásodpercnek kell lennie, 0 vagy több
|
||||
@msg $.evalFile: takes a file path and a timeout $.evalFile: egy fájlútvonalat és egy időkorlátot vár
|
||||
@msg assignment to a constant binding értékadás konstans kötésnek
|
||||
@msg invalid array length érvénytelen tömbhossz
|
||||
@msg array literal too long a tömbliterál túl hosszú
|
||||
@msg the value is not a function az érték nem függvény
|
||||
@msg apply was called on a value that is not a function az apply olyan értéken lett meghívva, amely nem függvény
|
||||
@msg the argument list is not an object az argumentumlista nem objektum
|
||||
@msg too many arguments túl sok argumentum
|
||||
@msg the value is not a constructor az érték nem konstruktor
|
||||
@msg cannot convert the object to a primitive value az objektum nem alakítható primitív értékké
|
||||
@msg cannot convert undefined or null to an object az undefined és a null nem alakítható objektummá
|
||||
@msg the right side of 'in' is not an object az 'in' jobb oldala nem objektum
|
||||
@msg the right side of 'instanceof' is not a function az 'instanceof' jobb oldala nem függvény
|
||||
@msg the function's prototype is not an object a függvény prototípusa nem objektum
|
||||
@msg Error: {e} Error: {e}
|
||||
@msg TypeError: {e} TypeError: {e}
|
||||
@msg ReferenceError: {e} ReferenceError: {e}
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5135,19 +5135,6 @@ swatch Bright Violet ビビッドバイオレット
|
||||
@msg $.evalFile requires a file path $.evalFile にはファイルパスが必要です
|
||||
@msg $.evalFile: the timeout must be a finite number of milliseconds, 0 or more $.evalFile: タイムアウトは 0 以上の有限のミリ秒数にしてください
|
||||
@msg $.evalFile: takes a file path and a timeout $.evalFile: ファイルパスとタイムアウトを指定します
|
||||
@msg assignment to a constant binding 定数バインディングへの代入です
|
||||
@msg invalid array length 配列の長さが無効です
|
||||
@msg array literal too long 配列リテラルが長すぎます
|
||||
@msg the value is not a function 値は関数ではありません
|
||||
@msg apply was called on a value that is not a function 関数ではない値に対して apply が呼び出されました
|
||||
@msg the argument list is not an object 引数リストはオブジェクトではありません
|
||||
@msg too many arguments 引数が多すぎます
|
||||
@msg the value is not a constructor 値はコンストラクターではありません
|
||||
@msg cannot convert the object to a primitive value オブジェクトをプリミティブ値に変換できません
|
||||
@msg cannot convert undefined or null to an object undefined または null をオブジェクトに変換できません
|
||||
@msg the right side of 'in' is not an object 'in' の右辺がオブジェクトではありません
|
||||
@msg the right side of 'instanceof' is not a function 'instanceof' の右辺が関数ではありません
|
||||
@msg the function's prototype is not an object 関数のプロトタイプがオブジェクトではありません
|
||||
@msg Error: {e} Error: {e}
|
||||
@msg TypeError: {e} TypeError: {e}
|
||||
@msg ReferenceError: {e} ReferenceError: {e}
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3368,6 +3368,12 @@ fn script_interpreter_core_errors_are_translated() {
|
||||
"cannot assign to property 'a': it is read-only",
|
||||
vec!["'a'"],
|
||||
),
|
||||
// A property named like the reason: the name stays as written, and the reason is translated.
|
||||
(
|
||||
"'use strict'; var o = {}; Object.defineProperty(o, 'it is read-only', {value: 1}); o['it is read-only'] = 2",
|
||||
"cannot assign to property 'it is read-only': it is read-only",
|
||||
vec!["'it is read-only'"],
|
||||
),
|
||||
(
|
||||
"'use strict'; var o = {}; Object.defineProperty(o, 'g', {get: function () { return 1; }}); o.g = 2",
|
||||
"cannot assign to property 'g': it has only a getter",
|
||||
|
||||
Reference in New Issue
Block a user