Skip to content

Commit

Permalink
Merge pull request #11872 from fabienpuissant/reafctor/improve-regex-…
Browse files Browse the repository at this point in the history
…to-patch-react-i18next

improve regex to patch react i18n files to be more flexible
  • Loading branch information
murdos authored Feb 7, 2025
2 parents 6a213a8 + 0a9a36f commit 7a683e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) {
.add(text(".use(LanguageDetector)"), ".use(initReactI18next).use(LanguageDetector)")
.and()
.in(path(INDEX + "home/infrastructure/primary/HomePage.tsx"))
.add(lineAfterText("import ReactLogo from '@assets/ReactLogo.png';"), "import { useTranslation } from 'react-i18next';")
.add(lineBeforeText("function HomePage"), "import { useTranslation } from 'react-i18next';" + LINE_BREAK)
.add(lineBeforeText("return ("), properties.indentation().times(1) + "const { t } = useTranslation();" + LINE_BREAK)
.add(lineAfterText("</h1>"), LINE_BREAK +
properties.indentation().times(4) + "<p>{t('home.translationEnabled')}</p>")
.and()
.in(path(INDEX + "index.tsx"))
.add(lineAfterText("import './index.css';"), "import './i18n';" + LINE_BREAK)
.add(lineBeforeText("const container = document.getElementById('root');"), "import './i18n';" + LINE_BREAK)
.and()
.in(path(INDEX_TEST + "webapp/unit/home/infrastructure/primary/HomePage.spec.tsx"))
.add(append(), LINE_BREAK + """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import './HomePage.css';

import JHipsterLiteNeonBlue from '@assets/JHipster-Lite-neon-blue.png';
import ReactLogo from '@assets/ReactLogo.png';

import { useTranslation } from 'react-i18next';

function HomePage() {
Expand Down

0 comments on commit 7a683e6

Please sign in to comment.