Skip to content

Latest commit

 

History

History

runtime

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

kiritan-logo

@kiritan/runtime

English | 日本語

The minimal runtime i18n half of Kiritan — t(key, params), with no build-time dependencies (no remark, no CLI). Safe to use on its own, in any project, without pulling in the rest of Kiritan.

npm GitHub Workflow Status GitHub Node

Install

npm install @kiritan/runtime

Usage

// src/components/Button/Button.i18n.ts
export default {
  submit: { en: "Submit", ja: "送信" },
  cancel: { en: "Cancel", ja: "キャンセル" },
};
import messages from "./Button.i18n";
import { createT } from "@kiritan/runtime";

const { t, setLocale } = createT(messages, { locale: "en", fallbackLocale: "en" });

t("submit"); // "Submit"
setLocale("ja");
t("submit"); // "送信"

t()'s key argument is typed from whatever object you pass to createT — a typo is a compile error, no code generation needed. See docs/DESIGN.md chapter 9 for the full picture, including the colocated / split / centralized / embedded resource placement strategies and %{name} interpolation.

Requirements

  • Node.js >= 22.7

Contributing

Contributions are welcome! See CONTRIBUTING.md for details.

License

Distributed under the WTFPL License.