Merge pull request #12 from zenzen-sol/sol/preview-localization-fix

fix: attempt to reverse localization
This commit is contained in:
Sol Irvine 2023-10-09 07:42:35 +09:00 committed by GitHub
commit 4b690be940
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 7 deletions

View File

@ -71,7 +71,7 @@ const noto = Noto_Serif_JP({
}); });
export function generateStaticParams() { export function generateStaticParams() {
return [{ locale: 'en' }, { locale: 'ja' }]; return [{ locale: 'ja' }, { locale: 'en' }];
} }
export default async function RootLayout({ export default async function RootLayout({

View File

@ -1,6 +1,7 @@
import OpengraphImage from 'components/opengraph-image'; import OpengraphImage from 'components/opengraph-image';
export const runtime = 'edge'; export const runtime = 'edge';
export const revalidate = 300; // 5 minutes in seconds
export default async function Image() { export default async function Image() {
return await OpengraphImage(); return await OpengraphImage();

View File

@ -14,7 +14,7 @@ export default async function Cart({ locale }: { locale?: SupportedLocale }) {
const promotedItem: Product | undefined = await getProduct({ const promotedItem: Product | undefined = await getProduct({
handle: 'gift-bag-and-postcard-set', handle: 'gift-bag-and-postcard-set',
language: locale?.toUpperCase() || 'EN' language: locale?.toUpperCase() || 'JA'
}); });
return <CartModal cart={cart} promotedItem={promotedItem} />; return <CartModal cart={cart} promotedItem={promotedItem} />;

View File

@ -19,7 +19,7 @@ export const LanguageControl = ({ lang }: { lang?: SupportedLocale }) => {
const basePathName = () => { const basePathName = () => {
const unjoined = pathName.split('/'); const unjoined = pathName.split('/');
const unjoinedWithoutLocale = removeItem(unjoined, 'ja'); const unjoinedWithoutLocale = removeItem(unjoined, 'en');
return unjoinedWithoutLocale.join('/') || '/'; return unjoinedWithoutLocale.join('/') || '/';
}; };

View File

@ -4,8 +4,8 @@ import 'server-only';
// We enumerate all dictionaries here for better linting and typescript support // We enumerate all dictionaries here for better linting and typescript support
// We also get the default import for cleaner types // We also get the default import for cleaner types
const dictionaries = { const dictionaries = {
en: () => import('./en.json').then((module) => module.default), ja: () => import('./ja.json').then((module) => module.default),
ja: () => import('./ja.json').then((module) => module.default) en: () => import('./en.json').then((module) => module.default)
}; };
export const getDictionary = async (locale: SupportedLocale) => export const getDictionary = async (locale: SupportedLocale) =>

View File

@ -2,10 +2,10 @@ import createMiddleware from 'next-intl/middleware';
export default createMiddleware({ export default createMiddleware({
// A list of all locales that are supported // A list of all locales that are supported
locales: ['en', 'ja'], locales: ['ja', 'en'],
// If this locale is matched, pathnames work without a prefix (e.g. `/about`) // If this locale is matched, pathnames work without a prefix (e.g. `/about`)
defaultLocale: 'en' defaultLocale: 'ja'
}); });
export const config = { export const config = {