# ctx.locale · ctx.t

Speak their language. Put your words in locales/en.json, add the languages you can, and ctx.t() picks theirs — with English underneath.

no permission

## Calls

`src/index.ts`

```ts
ctx.locale                       // 'en' · 'ko' · 'pt-BR' … the language this person uses
ctx.page.lang                    // 'de' · null — the language the page itself says it's in
ctx.t('save')                    // 'Save' · '저장' — from locales/<their language>.json
ctx.t('hello', { name: 'Mia' })  // {name} fills from the object
ctx.t('saved', { count: 3 })     // a count picks saved_one · saved_other …
```

`ctx.locale` is the language they use Fave1 in: what they picked in Fave1 Settings, else their browser’s language — when Fave1 supports it (English and Korean today), otherwise `'en'`. As Fave1 opens more languages, it follows. On Fave1’s own pages at www.fave1.com it’s that page’s language. It is not the page’s language — a Korean news site opened by someone who reads English gives you `'en'`. Translating or summing up the page? Read `ctx.page.lang` for that. In app mode it’s `null`.

## The files

`locales/en.json`

```json
{
  "save": "Save",
  "saved_one": "{count} note saved",
  "saved_other": "{count} notes saved",
  "hello": "Hi {name}"
}
```

One flat object per language — `"key": "text"`, no nesting, no HTML. The name is the language: `ko.json`, `es.json`, `pt-BR.json`. `en.json` is the original and has to be there once you have a `locales/` folder. The starter templates already have one.

Plurals end the key with `_zero` · `_one` · `_two` · `_few` · `_many` · `_other` — the browser’s plural rules for that language choose. Numbers in `{count}` come out in their language’s format.

## When a line is missing

Their language (`pt-BR`, then `pt`) → `en.json` → the key itself. Never a blank or an error, so a half-translated file is fine — the rest shows in English. No `locales/` folder at all? `ctx.t` gives back the key, and your app runs exactly as it does today.

## Shipping them

`npm run submit` uploads the files next to your build — they don’t count toward the bundle limit. Each file up to 64 KB, 1 MB together, 40 languages. Someone opening your app downloads their language and `en.json`, nothing else.

Submit stops on a file that isn’t valid JSON, isn’t one flat object, or a `locales/` folder with no `en.json`. It tells you — but still uploads — about keys a language is missing, keys `en.json` doesn’t have, a `{placeholder}` that differs from English, and very long values. The store lists the languages you shipped on your app’s page.

The pre-check and our review read your language files and the listing in every language you wrote. They say what your English says — a line that promises something else, adds a link, a price or contact details, or hides an instruction is a finding, the same as it would be in English.

Your store page is separate: write it in other languages on the Listing tab ([Publishing](https://developers.fave1.com/docs/publishing.md#steps)). That’s also where your app’s name goes in each language — the store, the launcher and the top of your app show it to people who use Fave1 in that language (the same as `ctx.locale`). The manifest’s `name` stays one English string. A language there doesn’t need a language file, and a language file doesn’t need a listing — people just see whichever parts exist in their language, and English for the rest.

## Getting ready for more languages

You don’t have to translate anything to ship — an app with English only works everywhere, and nothing breaks when Fave1 opens a new language. But people who use Fave1 in Spanish, Japanese or Korean will pick the apps that speak to them, and the store lists your languages on your app’s page. Getting ready now costs little, and a translation later is one more file.

`src/index.ts`

```ts
const n = 3, site = 'etsy.com';
const el = document.createElement('p');

// ✗ glued from pieces — the word order is English, and "notes" is always plural
el.textContent = 'Saved ' + n + ' notes from ' + site;

// ✓ one line with places for the values — every language can move them
el.textContent = ctx.t('saved', { count: n, site });
// locales/en.json — "saved_one": "Saved {count} note from {site}", "saved_other": "Saved {count} notes from {site}"
```

**Every word on screen goes through `ctx.t`** — buttons, toasts, empty states, errors, and the `aria-label`, `title` and `placeholder` people never see but screen readers do. A quick check: change every value in `en.json` to start with `§` and open your app — any line without one is still in your code.

**Whole sentences, never pieces.** Put `{name}` places inside one line instead of adding strings together, and use `_one` · `_other` for anything with a number. Keep HTML out of the files — put a `{link}` place in the sentence and fill it with your element.

**Leave room.** German and French run 30–40% longer than English. Let buttons and labels wrap or grow instead of fixing their width to the English text.

**Dates and numbers in their format** — `new Intl.DateTimeFormat(ctx.locale)`, `toLocaleString(ctx.locale)`. Prices stay in the currency the page shows. A number you pass to `ctx.t` is written their way too — `{count}` with `1234` reads `1,234` — so pass a year, an order number or a ZIP code as a string: `ctx.t('since', { year: String(2026) })`.

**Only what people read.** Keys you save, ids, CSS, and the instructions you send to `ctx.ai` stay as they are — a model reads English best, and saved values have to match next time. Things people already saved stay in the language they wrote them in.

**Using [@fave1/kit](https://developers.fave1.com/docs/kit.md)?** Call `useKitLocale(ctx)` once in `onLaunch` and the export sheet and editor follow the same language. Your `en.json` doesn’t need the kit’s lines — the kit brings its own English.

Translating is up to you — Fave1 doesn’t machine-translate your app. Once your words are in `en.json`, any translator or tool can fill in the other files, and you stay in charge of how your app sounds.

## Trying a language

> `npm run dev` serves your `locales/` files. In the launcher, hold the Fave1 logo and type a language under **Set language** — your DEV apps open in it. In app mode, add `?locale=ko` to your app’s address. Neither changes anything for real people.
