From d0fdbf4e04505d64888a7625994a15bbadd097dd Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Tue, 27 May 2025 17:49:45 -0500 Subject: [PATCH] Fix en-us labels --- README.md | 4 ++-- src/app/config.ts | 4 ++-- src/i18n/index.ts | 8 ++++---- src/i18n/locales/{us-en.ts => en-us.ts} | 0 src/i18n/state/client.ts | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) rename src/i18n/locales/{us-en.ts => en-us.ts} (100%) diff --git a/README.md b/README.md index f49ba962..488e542e 100644 --- a/README.md +++ b/README.md @@ -264,14 +264,14 @@ 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` +- `en-us` - `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.ts](https://github.com/sambecker/exif-photo-blog/blob/main/src/i18n/locales/us-en.ts) as reference. +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 [en-us.ts](https://github.com/sambecker/exif-photo-blog/blob/main/src/i18n/locales/en-us.ts) as reference. Thank you ❤️ translators: [@sconetto](https://github.com/sconetto) (`pt-br`, `pt-pt`), [@brandnholl](https://github.com/brandnholl) (`id-id`), [@TongEc](https://github.com/TongEc) (`zh-cn`) diff --git a/src/app/config.ts b/src/app/config.ts index c1064058..68c08e32 100644 --- a/src/app/config.ts +++ b/src/app/config.ts @@ -101,8 +101,8 @@ const SITE_DOMAIN_SHORT = shortenUrl(SITE_DOMAIN); // SITE META -export const APP_LOCALE = (process.env.NEXT_PUBLIC_LOCALE || 'us-en') - // Accepts both `us-en` and `US_EN` +export const APP_LOCALE = (process.env.NEXT_PUBLIC_LOCALE || 'en-us') + // Accepts both `en-us` and `EN_US` .toLocaleLowerCase() .replace('_', '-'); export const HTML_LANG = (APP_LOCALE.split('-')[1] || 'en'); diff --git a/src/i18n/index.ts b/src/i18n/index.ts index 96c1981a..958f22ab 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -1,8 +1,8 @@ -import US_EN from './locales/us-en'; +import EN_US from './locales/en-us'; import { enUS, id, ptBR, pt, zhCN } from 'date-fns/locale'; import { APP_LOCALE } from '@/app/config'; -export type I18N = typeof US_EN; +export type I18N = typeof EN_US; export type I18NDeepPartial = { [key in keyof I18N]?: Partial; @@ -10,7 +10,7 @@ export type I18NDeepPartial = { /** * Translation steps for contributors: - * 1. Create new file in `src/i18n/locales` modeled on `us-en.ts`. + * 1. Create new file in `src/i18n/locales` modeled on `en-us.ts`. * 2. Add import to `localeTextImports` * 3. Add date-fn locale to `getDateFnLocale` * 4. Test locally @@ -38,7 +38,7 @@ const getDateFnLocale = (locale: string) => { }; export const getTextForLocale = async (locale: string): Promise => { - const text = US_EN; + const text = EN_US; Object.entries(await localeTextImports[locale.toLocaleLowerCase()]?.() ?? {}) .forEach(([key, value]) => { diff --git a/src/i18n/locales/us-en.ts b/src/i18n/locales/en-us.ts similarity index 100% rename from src/i18n/locales/us-en.ts rename to src/i18n/locales/en-us.ts diff --git a/src/i18n/state/client.ts b/src/i18n/state/client.ts index d2452192..ca02cbb5 100644 --- a/src/i18n/state/client.ts +++ b/src/i18n/state/client.ts @@ -2,8 +2,8 @@ import { createContext, use } from 'react'; import { generateAppTextState } from '.'; -import US_EN from '../locales/us-en'; +import EN_US from '../locales/en-us'; -export const AppTextContext = createContext(generateAppTextState(US_EN)); +export const AppTextContext = createContext(generateAppTextState(EN_US)); export const useAppText = () => use(AppTextContext);