alepha@docs:~/docs/reference/primitives$
cat $dictionary.md1 min read
#$dictionary
#Import
typescript
1import { $dictionary } from "alepha/react/i18n";
#Overview
Register a dictionary entry for translations.
It allows you to define a set of translations for a specific language. Entry can be lazy-loaded, which is useful for large dictionaries or when translations are not needed immediately.
#Options
| Option | Type | Required | Description |
|---|---|---|---|
lang |
string |
No | |
name |
string |
No | |
lazy |
Object |
Yes |
#Examples
ts
1import { $dictionary } from "alepha/react/i18n"; 2 3const Example = () => { 4 const { tr } = useI18n<App, "en">(); 5 return <div>{tr("hello")}</div>; // 6} 7 8class App { 9 10 en = $dictionary({11 // { default: { hello: "Hey" } }12 lazy: () => import("./translations/en.ts"),13 });14 15 home = $page({16 path: "/",17 component: Example,18 })19}20 21run(App);