Add translation for battlesuit list page

This commit is contained in:
Sakura Knoll
2022-01-03 15:18:47 +09:00 Unverified
parent d5610fc964
commit ac143a81c0
20 changed files with 331 additions and 87 deletions
+8 -14
View File
@@ -1,17 +1,11 @@
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import { useTranslation } from 'next-i18next'
export function getI18NProps(
locale: string = 'en-US',
nameSpaces: string[] = []
) {
return serverSideTranslations(locale, ['common', ...nameSpaces])
export function translate(
targetLocale: string = 'en_US',
localeMap: { [key: string]: string | undefined },
fallback: string
): string {
return localeMap[targetLocale] != null ? localeMap[targetLocale]! : fallback
}
export function generateI18NPaths(paths: { params: any; locale?: string }[]) {
return paths.reduce<{ params: any; locale?: string }[]>((newPaths, path) => {
newPaths.push(path)
newPaths.push({ ...path, locale: 'ko-KR' })
return newPaths
}, [])
}
export { useTranslation }