From 9a29b80686c46b9c3d7def8d9906deb56e5f8c70 Mon Sep 17 00:00:00 2001 From: Garik Khachatryan Date: Tue, 1 Oct 2024 09:44:59 -0700 Subject: [PATCH] rename to customICUPrefix --- packages/format-po-gettext/README.md | 4 ++-- packages/format-po-gettext/src/po-gettext.test.ts | 6 +++--- packages/format-po-gettext/src/po-gettext.ts | 6 +++--- website/docs/ref/catalog-formats.md | 15 +++++++-------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/packages/format-po-gettext/README.md b/packages/format-po-gettext/README.md index e55045db6..30c6940c0 100644 --- a/packages/format-po-gettext/README.md +++ b/packages/format-po-gettext/README.md @@ -13,7 +13,7 @@ > **Warning** > This formatter is made for compatibility with translation management systems, which do not support ICU expressions in PO files. -> +> > It does not support all features of LinguiJS and should be carefully considered over other formats. > > Not supported features (native gettext doesn't support this): @@ -82,7 +82,7 @@ export type PoGettextFormatterOptions = { * * @default "js-lingui:" */ - customCtxPrefix?: string + customICUPrefix?: string } ``` diff --git a/packages/format-po-gettext/src/po-gettext.test.ts b/packages/format-po-gettext/src/po-gettext.test.ts index e9797693f..564203350 100644 --- a/packages/format-po-gettext/src/po-gettext.test.ts +++ b/packages/format-po-gettext/src/po-gettext.test.ts @@ -242,7 +242,7 @@ msgstr[2] "# dní" ) const defaultPrefix = createFormat() - const customPrefix = createFormat({ customCtxPrefix: "custom-prefix:" }) + const customPrefix = createFormat({ customICUPrefix: "custom-prefix:" }) const defaultCatalog = defaultPrefix.parse( defaultProfile, @@ -259,7 +259,7 @@ msgstr[2] "# dní" .toString() const usingInvalidPrefix = createFormat({ - customCtxPrefix: "invalid-prefix:", + customICUPrefix: "invalid-prefix:", }) mockConsole((console) => { const catalog = usingInvalidPrefix.parse( @@ -277,7 +277,7 @@ msgstr[2] "# dní" }) it("handles custom prefix", () => { - const format = createFormat({ customCtxPrefix: "custom-prefix:" }) + const format = createFormat({ customICUPrefix: "custom-prefix:" }) const catalog: CatalogType = { message_with_id: { diff --git a/packages/format-po-gettext/src/po-gettext.ts b/packages/format-po-gettext/src/po-gettext.ts index 6d57ecafc..63c1fb447 100644 --- a/packages/format-po-gettext/src/po-gettext.ts +++ b/packages/format-po-gettext/src/po-gettext.ts @@ -13,7 +13,7 @@ type POItem = InstanceType export type PoGettextFormatterOptions = PoFormatterOptions & { disableSelectWarning?: boolean - customCtxPrefix?: string + customICUPrefix?: string } // Attempts to turn a single tokenized ICU plural case back into a string. @@ -53,7 +53,7 @@ function serializePlurals( // Depending on whether custom ids are used by the developer, the (potential plural) "original", untranslated ICU // message can be found in `message.message` or in the item's `key` itself. const icuMessage = message.message - const ctxPrefix = options.customCtxPrefix || DEFAULT_CTX_PREFIX + const ctxPrefix = options.customICUPrefix || DEFAULT_CTX_PREFIX if (!icuMessage) { return item @@ -269,7 +269,7 @@ export function formatter( item, pluralForms, po.headers.Language, - options.customCtxPrefix + options.customICUPrefix ) }) diff --git a/website/docs/ref/catalog-formats.md b/website/docs/ref/catalog-formats.md index 4ba666704..fdf2aa314 100644 --- a/website/docs/ref/catalog-formats.md +++ b/website/docs/ref/catalog-formats.md @@ -155,29 +155,29 @@ export type PoGettextFormatterOptions = { * * @default true */ - origins?: boolean + origins?: boolean; /** * Print line numbers in origins * * @default true */ - lineNumbers?: boolean + lineNumbers?: boolean; /** * Disable warning about unsupported `Select` feature encountered in catalogs * * @default false */ - disableSelectWarning?: boolean + disableSelectWarning?: boolean; /** * Overrides the default prefix for icu and plural comments in the final PO catalog. * * @default "js-lingui:" */ - customCtxPrefix?: string -} + customICUPrefix?: string; +}; ``` ### Examples {#po-gettext-examples} @@ -210,19 +210,18 @@ With this format, plural messages are exported in the following ways, depending Note how `msgid` and `msgid_plural` were extracted from the original message. - - Message **with a custom comment prefix**. Some TMS might modify the ICU comment by attempting to split lines to be 80 characters or less, or have trouble reading lingui comments because of the `js-lingui:` prefix. To change the prefix, - set `customCtxPrefix` to modify the prefix for ICU comments. + set `customICUPrefix` to modify the prefix for ICU comments. ```po # with default prefix #. js- #. lingui:icu=%7BanotherCount%2C+plural%2C+one+%7BSingular+case%7D+other+%7BCase+number+%7BanotherCount%7D%7D%7D&pluralize_on=anotherCount - # customCtxPrefix = jsi18n: + # customICUPrefix = jsi18n: #. jsi18n:icu=%7BanotherCount%2C+plural%2C+one+%7BSingular+case%7D+other+%7BCase+number+%7BanotherCount%7D%7D%7D&pluralize_on=anotherCount ```