aboutsummaryrefslogtreecommitdiffstats
path: root/locales/README.md
blob: 5a0492019632fd3a1f43ba73ceb6ab8521e9f1a4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Locales

Flat key → string dicts, one file per language: `en.php`, `ja.php`, `zh.php`.
Loaded by `partials/i18n.php` via the `t($key)` helper.

**EN is source of truth.** Missing keys in ja/zh fall back to English, then to
the key string itself. When you add UI strings, add the EN key first and mirror
it in ja/zh in the same change when possible.

## Migration strategy

The existing `foo.php` / `foo_jp.php` / `foo_zh.php` triples are kept as-is.
When you next edit a page triple, collapse it:

1. `require_once __DIR__ . '/partials/i18n.php';` at the top of `foo.php`.
2. Replace the hardcoded English strings with `<?= t('foo.someKey') ?>`.
3. Add matching keys to `locales/{en,ja,zh}.php`.
4. Replace `foo_jp.php` / `foo_zh.php` with a one-line redirect stub:
   `<?php header('Location: /foo.php?lang=jp'); exit;`
   (or leave them until you're ready to migrate routing).

Language detection reads the current filename's `_jp.php` / `_zh.php`
suffix, matching the existing URL scheme. No routing changes required to
start using `t()`.