-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Change i18n library from next-translate to next-i18next
- Loading branch information
1 parent
4d0b7ef
commit 4112adc
Showing
20 changed files
with
2,404 additions
and
2,180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<SampleLocale /> displayed well 1`] = ` | ||
<div> | ||
<p> | ||
English | ||
| | ||
Korean | ||
| | ||
Japanese | ||
</p> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react' | ||
import { ComponentStory, ComponentMeta } from '@storybook/react' | ||
|
||
import { SampleLocale } from '.' | ||
|
||
export default { | ||
title: 'Components/SampleLocale', | ||
component: SampleLocale, | ||
parameters: { controls: { disabled: true } }, | ||
} as ComponentMeta<typeof SampleLocale> | ||
|
||
const Template: ComponentStory<typeof SampleLocale> = () => <SampleLocale /> | ||
|
||
export const Default = Template.bind({}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { useEffect } from 'react' | ||
import { render, screen } from '@testing-library/react' | ||
import { I18nextProvider } from 'react-i18next' | ||
import i18n from 'utils/i18n' | ||
|
||
import { SampleLocale } from './index' | ||
|
||
interface Props { | ||
readonly locale: 'en' | 'ko' | 'ja' | ||
} | ||
const TestComponent = ({ locale }: Props) => { | ||
useEffect(() => { | ||
i18n.changeLanguage(locale) | ||
}, [locale]) | ||
|
||
return ( | ||
<I18nextProvider i18n={i18n}> | ||
<SampleLocale /> | ||
</I18nextProvider> | ||
) | ||
} | ||
|
||
describe('<SampleLocale />', () => { | ||
it('displayed well', () => { | ||
const { container, rerender } = render(<TestComponent locale="en" />) | ||
|
||
expect( | ||
screen.queryByText('English | Korean | Japanese'), | ||
).toBeInTheDocument() | ||
expect(screen.queryByText('영어 | 한국어 | 일본어')).not.toBeInTheDocument() | ||
expect(screen.queryByText('英語 | 韓国語 | 日本語')).not.toBeInTheDocument() | ||
|
||
expect(container).toMatchSnapshot() | ||
|
||
rerender(<TestComponent locale="ko" />) | ||
expect( | ||
screen.queryByText('English | Korean | Japanese'), | ||
).not.toBeInTheDocument() | ||
expect(screen.queryByText('영어 | 한국어 | 일본어')).toBeInTheDocument() | ||
expect(screen.queryByText('英語 | 韓国語 | 日本語')).not.toBeInTheDocument() | ||
|
||
rerender(<TestComponent locale="ja" />) | ||
expect( | ||
screen.queryByText('English | Korean | Japanese'), | ||
).not.toBeInTheDocument() | ||
expect(screen.queryByText('영어 | 한국어 | 일본어')).not.toBeInTheDocument() | ||
expect(screen.queryByText('英語 | 韓国語 | 日本語')).toBeInTheDocument() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useTranslation } from 'next-i18next' | ||
|
||
export const SampleLocale = () => { | ||
const { t } = useTranslation('common') | ||
|
||
return ( | ||
<p> | ||
{t('English')} | {t('Korean')} | {t('Japanese')} | ||
</p> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
i18n: { | ||
defaultLocale: 'en', | ||
locales: ['en', 'ko', 'ja'], | ||
localeDetection: false, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextTranslate = require('next-translate') | ||
const { i18n } = require('./next-i18next.config') | ||
|
||
module.exports = nextTranslate() | ||
module.exports = { | ||
reactStrictMode: true, | ||
i18n, | ||
} |
Oops, something went wrong.