このコミットが含まれているのは:
2026-10-17 23:01:24 +09:00
コミット 91296f7477
21個のファイルの変更、664行の追加、113行の削除
+56
ファイルの表示
@@ -0,0 +1,56 @@
import { createInstance } from 'i18next'
import { initReactI18next } from 'react-i18next'
import ainuNavigation from '@/locales/ain-Kana/navigation.json'
import nipponeseNavigation from '@/locales/ja/navigation.json'
import type { LocaleCode } from '@/lib/locales'
export const i18n = createInstance ()
void i18n.use (initReactI18next).init ({
lng: 'ja',
fallbackLng: 'ja',
supportedLngs: ['ja', 'ain-Kana'],
load: 'currentOnly',
initAsync: false,
defaultNS: 'navigation',
ns: ['navigation'],
resources: {
ja: { navigation: nipponeseNavigation },
'ain-Kana': { navigation: ainuNavigation } },
interpolation: { escapeValue: false },
returnNull: false,
returnEmptyString: false,
saveMissing: import.meta.env.DEV,
missingKeyHandler: (languages, namespace, key) => {
console.warn ('[i18n] missing key', { languages, namespace, key })
},
react: { useSuspense: false } })
export const untranslatedKeys = (
locale: LocaleCode,
namespace = 'navigation',
): string[] => {
const collect = (resource: Record<string, unknown>, prefix = ''): string[] =>
Object.entries (resource).flatMap (([key, value]) => {
const path = prefix ? `${ prefix }.${ key }` : key
return (value != null && typeof value === 'object')
? collect (value as Record<string, unknown>, path)
: [path]
})
const baseline = i18n.getResourceBundle ('ja', namespace) ?? { }
return collect (baseline).filter (key => {
const value = i18n.getResource (locale, namespace, key)
return typeof value !== 'string' || value.length === 0
})
}
if (import.meta.env.DEV)
{
const missing = untranslatedKeys ('ain-Kana')
if (missing.length > 0)
console.warn ('[i18n] ain-Kana: untranslated navigation keys', missing)
}