Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(editor): align the Spanish and British quote pairs with CLDR
Elian Dorandb704351c31a
diff --git a/apps/client/src/widgets/type_widgets/text/quotes.spec.ts b/apps/client/src/widgets/type_widgets/text/quotes.spec.tsindex 5ee5b5768a..ee89780144 100644--- a/apps/client/src/widgets/type_widgets/text/quotes.spec.ts+++ b/apps/client/src/widgets/type_widgets/text/quotes.spec.ts@@ -57,10 +57,23 @@ describe("resolveQuoteStyle", () => {expect(resolveQuoteStyle("de-AT")).toEqual(resolveQuoteStyle("de"));expect(resolveQuoteStyle("fr-CA")).toEqual(resolveQuoteStyle("fr"));- // en-GB inverts the levels, so it must not collapse into `en`.- expect(resolveQuoteStyle("en-GB")).toEqual({ primary: ["‘", "’"], secondary: ["“", "”"] });expect(resolveQuoteStyle("en-US")).toEqual({ primary: ["“", "”"], secondary: ["‘", "’"] });- expect(resolveQuoteStyle("en-GB")).not.toEqual(resolveQuoteStyle("en"));++ // A region that has an entry of its own keeps it instead of collapsing into the base+ // language. Brazilian vs European Portuguese is the pair that still differs.+ expect(resolveQuoteStyle("pt-BR")).toEqual({ primary: ["“", "”"], secondary: ["‘", "’"] });+ expect(resolveQuoteStyle("pt-BR")).not.toEqual(resolveQuoteStyle("pt"));+ });++ it("follows CLDR where a prescriptive rule and common usage disagree", () => {+ // Spanish: the RAE prescribes guillemets, CLDR and everyday writing use the curly pair.+ expect(resolveQuoteStyle("es")).toEqual({ primary: ["“", "”"], secondary: ["‘", "’"] });++ // en-GB: traditional British style inverts the two levels, and CKEditor's own+ // `quotesPrimaryEnGb` still does, but CLDR has en-GB on doubles — so it matches `en`. The+ // entry is kept rather than deleted so that agreeing reads as a decision, not an omission.+ expect(resolveQuoteStyle("en-GB")).toEqual({ primary: ["“", "”"], secondary: ["‘", "’"] });+ expect(resolveQuoteStyle("en-GB")).toEqual(resolveQuoteStyle("en"));});it("normalizes the locale ids Trilium stores, matching the date and number formatters", () => {diff --git a/apps/client/src/widgets/type_widgets/text/quotes.ts b/apps/client/src/widgets/type_widgets/text/quotes.tsindex 822ce2a804..588a81e054 100644--- a/apps/client/src/widgets/type_widgets/text/quotes.ts+++ b/apps/client/src/widgets/type_widgets/text/quotes.ts@@ -22,6 +22,11 @@ export interface QuoteStyle {* falls through to CKEditor's default, which is a better outcome than a confident guess. That* currently means the right-to-left content locales (`ar`, `he`, `ku`, `fa`, `ug`), where usage* varies by register and interacts with bidirectional text.+ *+ * Every entry here agrees with CLDR's `delimiters` data for the corresponding locale, which is the+ * tie-breaker where a prescriptive rule and common usage disagree — Spanish being the case in point,+ * where the RAE prescribes guillemets but CLDR (and everyday writing) uses the curly pair. The one+ * intentional departure is French, whose narrow no-break spaces CLDR does not model in this field.*/const QUOTE_STYLES: Record<string, QuoteStyle> = {// “…” / ‘…’ — the same pair CKEditor defaults to, restated so these locales resolve explicitly@@ -33,9 +38,12 @@ const QUOTE_STYLES: Record<string, QuoteStyle> = {ko: { primary: ["“", "”"], secondary: ["‘", "’"] },zh: { primary: ["“", "”"], secondary: ["‘", "’"] },"pt-br": { primary: ["“", "”"], secondary: ["‘", "’"] },-- // British usage inverts the two levels.- "en-gb": { primary: ["‘", "’"], secondary: ["“", "”"] },+ es: { primary: ["“", "”"], secondary: ["‘", "’"] },+ // Listed although it now matches `en`, so that the agreement reads as a decision rather than an+ // omission: British usage traditionally inverts the two levels — which is what CKEditor's own+ // `quotesPrimaryEnGb` still does — but CLDR has en-GB on double quotes, following the publishers+ // that moved. Restoring the inverted pair wants evidence, not just the memory of the old rule.+ "en-gb": { primary: ["“", "”"], secondary: ["‘", "’"] },// „…“ — the closing mark is the raised one, not a mirror of the opening.de: { primary: ["„", "“"], secondary: ["‚", "‘"] },@@ -53,8 +61,9 @@ const QUOTE_STYLES: Record<string, QuoteStyle> = {// length-constrained, so the space rides along with the mark it belongs to.fr: { primary: ["« ", " »"], secondary: ["“", "”"] },- es: { primary: ["«", "»"], secondary: ["“", "”"] },it: { primary: ["«", "»"], secondary: ["“", "”"] },+ // Portugal. Brazilian usage is the curly pair above, under `pt-br` — CLDR models the split the+ // other way round, keeping Brazil in plain `pt` and Portugal in `pt-PT`.pt: { primary: ["«", "»"], secondary: ["“", "”"] },// Corner brackets, used by Japanese and by traditional (but not simplified) Chinese.