Fix en-us labels
This commit is contained in:
parent
bdba4c8c7d
commit
d0fdbf4e04
@ -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`)
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -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<I18N[key]>;
|
||||
@ -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<I18N> => {
|
||||
const text = US_EN;
|
||||
const text = EN_US;
|
||||
|
||||
Object.entries(await localeTextImports[locale.toLocaleLowerCase()]?.() ?? {})
|
||||
.forEach(([key, value]) => {
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user