i18next-shopify
The i18next-shopify preset supports i18next-shopify, the i18next plugin for the Shopify message format.
Detection
The preset applies when the project depends on @shopify/i18next-shopify.
import { i18nextShopify } from '@x18n/cli/presets'
import { defineConfig } from '@x18n/core'
export default defineConfig({
presets: [i18nextShopify()],
})What it adds
The preset includes everything of the react-i18next preset. If the react-i18next preset also applies, x18n adds the shared plugins one time.
The Shopify format keeps plural and ordinal forms as nested keys. The preset adds the derived keys {key}.plural, {key}.zero, {key}.one, {key}.two, {key}.few, {key}.many, {key}.other, and {key}.0 to {key}.9. New files use nested keys.
Locale files
The preset adds no resource patterns. Set resources in the config, or let x18n guess the locale directories:
import { defineConfig } from '@x18n/core'
export default defineConfig({
resources: [{ pattern: 'locales/{locale}.json' }],
})Supported syntax
The calls of react-i18next. For this file, t('cart.items', { count }) uses cart.items.one and cart.items.other, so the unused-key check reports neither:
{
"cart": {
"items": {
"one": "{count} item",
"other": "{count} items"
}
}
}Placeholders
Braces: {name}. The placeholders of i18next stay: {{name}} and $t(key).
Extraction templates
The templates of react-i18next.