Skip to content

Internationalization (i18n): support English and Japanese #4

Description

@nyatinte

AS IS

All user-facing strings are hardcoded in English throughout the codebase:

  • UI prompts: "Select package", "Select script" (src/ui.ts)
  • Cancellation message: "Cancelled." (src/ui.ts)
  • Error messages: "No packages match: ...", "Multiple packages match: ...", "No scripts in ..." (src/index.ts)
  • Workspace error: "Run prw from workspace root." (src/workspace.ts)

Japanese-speaking users see English-only output with no way to change it.

TO BE

Detect locale from the environment (via `LANG` / `LC_ALL` env vars or `Intl.DateTimeFormat().resolvedOptions().locale`) and display messages in the matching language. Fall back to English if the locale is not supported.

Supported locales in v1:

  • en (English) — default/fallback
  • ja (Japanese)

Example (Japanese locale):

```
パッケージを選択:
❯ @myapp/web apps/web
@myapp/api apps/api

スクリプトを選択:
❯ dev next dev
build tsc && next build
```

Implementation notes:

  • Introduce a src/i18n.ts module exporting a typed message catalog and a `t(key)` helper
  • All hardcoded strings in `ui.ts`, `index.ts`, and `workspace.ts` replaced with `t()` calls
  • The active locale is resolved once at startup and passed down (or stored as a module-level singleton)
  • No runtime dependencies required — plain object lookup is sufficient

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions