alepha@docs:~/docs/.content/release/framework/docs/reference/primitives$
cat $dictionary.md | pretty
1 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

tsx
 1import { run } from "alepha"; 2import { $dictionary, useI18n } from "alepha/react/i18n"; 3import { $page } from "alepha/react/router"; 4  5const Example = () => { 6  const { tr } = useI18n<App, "en">(); 7  return <div>{tr("hello")}</div>; // "Hey" 8}; 9 10class App {11  en = $dictionary({12    // { default: { hello: "Hey" } }13    lazy: () => import("./translations/en.ts"),14  });15 16  home = $page({17    path: "/",18    component: Example,19  });20}21 22run(App);