Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion next-i18next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const nextI18NextConfig: UserConfig = {
i18n: {
locales: ['ko', 'en'],
defaultLocale: 'ko',
localeDetection: false, // λ¦¬ν„°λŸ΄ false
localeDetection: false,
},
reloadOnPrerender: process.env.NODE_ENV === 'development',
localePath: path.resolve('./public/locales'),
Expand Down
5 changes: 5 additions & 0 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const nextConfig: NextConfig = {
};
return config;
},
i18n: {
locales: ['ko', 'en'],
defaultLocale: 'ko',
localeDetection: false,
},
reactStrictMode: true,
images: {
remotePatterns: [
Expand Down
18 changes: 7 additions & 11 deletions src/components/localeSwitcher.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import Link from 'next/link';
import { useRouter } from 'next/router';

const LocaleSwitcher = () => {
const { locale, locales, asPath, pathname, query, push } = useRouter();
const { locale, locales, pathname, query } = useRouter();
const supported = locales ?? ['ko', 'en'];
const nextLocale = supported.find((l) => l !== locale) ?? supported[0];

const handleClick = () => {
push({ pathname, query }, asPath, { locale: nextLocale });
};

return (
<button
className="py-1 px-2 cursor-pointer bg-blue-400 text-white rounded-lg"
onClick={handleClick}
>
{nextLocale.toUpperCase()}
</button>
<Link href={{ pathname, query }} locale={nextLocale}>
<button className="py-1 px-2 bg-blue-400 text-white rounded-lg">
{nextLocale.toUpperCase()}
</button>
</Link>
);
};

Expand Down