Translate hard-coded strings with react-i18next
ProprietaryReplaces the hard-coded strings that FindHardCodedStrings reports in function components with t("key") calls of react-i18next's useTranslation hook, and adds each new key to the source locale file. A template literal whose interpolations are names becomes t("key", {name}). Keys follow the locale file: the text itself where its keys are mostly their own text, otherwise a generated key, reusing a key whose value is already the text. Only packages that depend on react-i18next and have one English locale file, such as public/locales/en/translation.json, are changed. Sentences that need <Trans>, strings outside function components with a block body, class components, async components, components without 'use client' in a Next.js app router, and components whose t is something else stay as they are.
org. openrewrite. react. i18n. translate-hard-coded-stringsOptional
The source-language locale file to add keys to, where a package has more than one candidate.
mod run . --recipe= org. openrewrite. react. i18n. translate-hard-coded-stringsInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.