diff --git a/README.md b/README.md index 8a84fb2c..27a39ab6 100644 --- a/README.md +++ b/README.md @@ -257,7 +257,7 @@ Vercel Postgres can be switched to another Postgres-compatible, pooling provider 💬   I18N - -Partial internationalization (non-admin, user-facing text) provided for a handful of languages. If you'd like to add support for a new language, open a PR [using `US_EN`](https://github.com/sambecker/exif-photo-blog/main/src/i18n/languages/us-en.ts) for reference. +Partial internationalization (non-admin, user-facing text) provided for a handful of languages. Set your language by setting the environment variable `NEXT_PUBLIC_LOCALE`. If you'd like to add support for a new language, open a PR [using `US_EN`](https://github.com/sambecker/exif-photo-blog/main/src/i18n/locales/us-en.ts) for reference. ### Supported Languages - `US_EN` diff --git a/src/admin/AdminAppConfigurationClient.tsx b/src/admin/AdminAppConfigurationClient.tsx index 7094efe8..7edf8817 100644 --- a/src/admin/AdminAppConfigurationClient.tsx +++ b/src/admin/AdminAppConfigurationClient.tsx @@ -47,6 +47,8 @@ export default function AdminAppConfigurationClient({ hasAuthSecret, hasAdminUser, // Content + locale, + hasLocale, hasDomain, hasNavTitle, hasNavCaption, @@ -289,6 +291,22 @@ export default function AdminAppConfigurationClient({ title="Content" icon={} > + + Store in environment variable + (check README for + {' '} + + supported locales + + ): + {renderEnvVars(['NEXT_PUBLIC_LOCALE'])} + ; } -export const LANGUAGES: Record = { +export const LOCALE_TEXT: Record = { 'pt-br': PT_BR, }; - -export const getTextForLanguage = ( - language = '', + +export const getTextForLocale = ( + locale = '', ): I18N => { const text = US_EN; - Object.entries(LANGUAGES[language.toLocaleLowerCase()] ?? {}) + Object.entries(LOCALE_TEXT[locale.toLocaleLowerCase()] ?? {}) .forEach(([key, value]) => { + // Fall back to English for missing keys text[key as keyof I18N] = { ...text[key as keyof I18N], ...value,