Registry / productivity / i18next-formatter-stronglist

i18next-formatter-stronglist

JSON →
library1.0.1jsnpmunverified

An i18next formatter that wraps list items in <strong> tags. This package provides a simple formatter for use with i18next and react-i18next's Trans component. When applied, it formats array values by wrapping each element in <strong> tags, useful for emphasizing list items in translations. The package is stable at version 1.0.1. There are no known similar packages providing exactly this functionality for i18next.

npm install i18next-formatter-stronglist
INSTALL
IMPORT
SIG · I18NEXT-FORMATTER-
I
i18next-formatter-stronglist
productivityjavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import stronglist from 'i18next-formatter-stronglist'
import { stronglist } from 'i18next-formatter-stronglist'
The package exports a single function as default export.
i18next
import i18next from 'i18next'
Main i18next instance needed to add a formatter.
Trans
import { Trans } from 'react-i18next'
Trans component from react-i18next is used to render translated content with formatters.

Shows initialization of i18next, adding the stronglist formatter, and using Trans component to render a list with strong tags.

import i18next from 'i18next'; import { initReactI18next } from 'react-i18next'; import stronglist from 'i18next-formatter-stronglist'; i18next.use(initReactI18next).init({ lng: 'en', resources: { en: { translation: { keyname: 'Items: {{list, stronglist}}' } } } }); i18next.services.formatter?.add('stronglist', stronglist); // In your React component: // import { Trans } from 'react-i18next'; // <Trans t={t} i18nKey="keyname" values={{ list: ['apple', 'banana', 'cherry'] }} /> // Renders: Items: <strong>apple</strong>, <strong>banana</strong>, <strong>cherry</strong>
Debug
Known issues
gotchaThe formatter must be added manually via i18next.services.formatter.add after initializing i18next.
fix
Call i18next.services.formatter?.add('stronglist', stronglist) after i18next.init.
affects: >=1.0.0
gotchaThe formatter name 'stronglist' must match exactly in the translation key: {{list, stronglist}}.
fix
Use the exact string 'stronglist' when adding the formatter and in the i18next key.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: i18next.services.formatter is undefined
formatter service may not be available if i18next version is older or not properly initialized.
fix
Ensure i18next version >= 21.0.0 and that you have called i18next.init() before accessing formatter.
Module not found: Can't resolve 'react-i18next'
Missing required peer dependency react-i18next.
fix
Install react-i18next: npm install react-i18next
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
30 hits · last 30 days
node
28
OpenAI (training)
1
Resources
i18next-formatter-stronglist — npm install i18next-formatter-stronglist · libregistry