diff --git a/README.md b/README.md index 2b6d2f24..9041af98 100644 --- a/README.md +++ b/README.md @@ -264,12 +264,12 @@ Vercel Postgres can be switched to another Postgres-compatible, pooling provider Partial internationalization (for non-admin, user-facing text) provided for a handful of languages. Configure locale by setting environment variable `NEXT_PUBLIC_LOCALE`. ### Supported Languages -- `US_EN` -- `ES_ES` (coming soon) -- `PT_BR` -- `PT_PT` -- `ID_ID` -- `ZH_CN` +- `us-en` +- `es-es` (coming soon) +- `pt-br` +- `pt-pt` +- `id-id` +- `zh-cn` To add support for a new language, open a PR following instructions in [/src/i18n/index.ts](https://github.com/sambecker/exif-photo-blog/blob/main/src/i18n/index.ts), using [`US_EN`](https://github.com/sambecker/exif-photo-blog/blob/main/src/i18n/locales/us-en.ts) as reference. diff --git a/app/layout.tsx b/app/layout.tsx index e12e3b95..db805fda 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -8,6 +8,7 @@ import { META_DESCRIPTION, NAV_TITLE_OR_DOMAIN, META_TITLE, + HTML_LANG, } from '@/app/config'; import AppStateProvider from '@/state/AppStateProvider'; import ToasterWithThemes from '@/toast/ToasterWithThemes'; @@ -72,7 +73,7 @@ export default function RootLayout({ }) { return ( diff --git a/src/admin/AdminAppConfigurationClient.tsx b/src/admin/AdminAppConfigurationClient.tsx index ffccd45a..88905398 100644 --- a/src/admin/AdminAppConfigurationClient.tsx +++ b/src/admin/AdminAppConfigurationClient.tsx @@ -294,7 +294,7 @@ export default function AdminAppConfigurationClient({ icon={} > diff --git a/src/app/config.ts b/src/app/config.ts index c3a3e0ab..c1064058 100644 --- a/src/app/config.ts +++ b/src/app/config.ts @@ -101,7 +101,11 @@ const SITE_DOMAIN_SHORT = shortenUrl(SITE_DOMAIN); // SITE META -export const APP_LOCALE = process.env.NEXT_PUBLIC_LOCALE || 'US-EN'; +export const APP_LOCALE = (process.env.NEXT_PUBLIC_LOCALE || 'us-en') + // Accepts both `us-en` and `US_EN` + .toLocaleLowerCase() + .replace('_', '-'); +export const HTML_LANG = (APP_LOCALE.split('-')[1] || 'en'); export const NAV_TITLE = process.env.NEXT_PUBLIC_NAV_TITLE;