Skip to content

Commit eb0bf5e

Browse files
committed
Update docs
1 parent 0bd770f commit eb0bf5e

16 files changed

+144
-83
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@
4141
"@changesets/changelog-github": "^0",
4242
"@changesets/cli": "^2",
4343
"@types/node": "^20",
44-
"@types/react": "^18",
4544
"@types/react-dom": "^18",
45+
"@types/react": "^18",
4646
"@vitest/coverage-v8": "^1",
4747
"husky": "^9",
4848
"lint-staged": "^15",
49+
"prettier": "^3",
4950
"rimraf": "^5",
5051
"tsup": "^8",
5152
"typescript": "^5",

pnpm-lock.yaml

+9-65
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/src/pages/_meta.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"display": "hidden",
44
"type": "page",
55
"theme": {
6+
"layout": "full",
67
"breadcrumb": false,
78
"footer": false,
89
"sidebar": false,

website/src/pages/about.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ list of contributors on
1313

1414
Terai is powered by these incredible open source projects:
1515

16+
- [@legendapp/state](https://rollupjs.org)
17+
- [Node](https://rollupjs.org)
1618
- [React](https://github.com/facebook/react)
17-
- [Tsup](https://github.com/apache/incubator-echarts)
1819
- [Rollup](https://rollupjs.org)
19-
- [Node](https://rollupjs.org)
20+
- [Tsup](https://github.com/apache/incubator-echarts)
2021
- [Typescript](https://rollupjs.org)
2122
- [Vite](https://rollupjs.org)
22-
- [@legendapp/state](https://rollupjs.org)
2323

2424
## License
2525

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"extraction": {
3+
"title": "Extraction"
4+
},
5+
"translation": {
6+
"title": "Translation"
7+
},
8+
"cache": {
9+
"title": "Cache"
10+
},
11+
"code-splitting": {
12+
"title": "Code-Splitting"
13+
},
14+
"formatting": {
15+
"title": "Formatting"
16+
},
17+
"variables": {
18+
"title": "Variables"
19+
},
20+
"ts": {
21+
"title": "ts"
22+
}
23+
}

website/src/pages/docs/concepts/code-splitting.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ that instance are linked.
3434
import { useTs } from './locale'
3535

3636
export function Button() {
37-
const ts = useTs({ chunkId: 'button' })
37+
const { ts } = useTs({ chunkId: 'button' })
3838

3939
return (
4040
<div>
@@ -53,7 +53,7 @@ specific requirements.
5353
import { useTs } from './locale'
5454

5555
export function Header() {
56-
const ts = useTs({ chunkId: 'common' })
56+
const { ts } = useTs({ chunkId: 'common' })
5757

5858
return (
5959
<div>
@@ -67,7 +67,7 @@ export function Header() {
6767
import { useTs } from './locale'
6868

6969
export function Footer() {
70-
const ts = useTs({ chunkId: 'common' })
70+
const { ts } = useTs({ chunkId: 'common' })
7171

7272
return (
7373
<div>
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
11
# Extraction
2+
3+
Keeping your localization system up to date can be a challenging task, especially in large or fast-paced projects. It often involves duplicating work and leaves room for potential errors.
4+
5+
Terai's extraction feature simplifies the process of identifying all the strings that require localization in your project, making them ready for translation.
6+
7+
## Running the `extract` command
8+
9+
To extract strings for localization in your project using Terai, follow these steps:
10+
11+
1. Run the `terai extract` command in your project.
12+
2. Terai will analyze the inputs to your project and search for all instances of `ts` files.
13+
3. Each occurrence of a string will be converted into a unique hash (e.g., 78awdk123) based on its content.
14+
4. The extracted strings will be written to a manifest file (`.terai/locale-manifest.json`).
15+
5. Additionally, the dictionary for your `projectLocale` will be created or updated, as it does not require translation.
16+
17+
![Extract](/extract.gif)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { Steps, Tabs } from 'nextra/components'
2+
3+
# Formatting
4+
5+
Terai provides a set of utils to format numbers, dates, displayNames, lists and relative times.
6+
All functions are based in the `Intl` Web API Standard.
7+
8+
## Usage
9+
10+
Now you can start using terai in your project. Here is the snippet of code that
11+
you can use in some `example.tsx` file.
12+
13+
<Tabs items={['useFormat', 'getFormat']}>
14+
<Tabs.Tab>
15+
```tsx filename="example.tsx" copy
16+
import { useTs, useFormat } from '@terai/vite'
17+
18+
export function Example() {
19+
const { ts } = useTs()
20+
const format = useFormat()
21+
const now = new Date()
22+
23+
return (
24+
<div>
25+
<p>{ts`Now is ${format.date({ value: now })}!`}</p>
26+
</div>
27+
)
28+
}
29+
```
30+
</Tabs.Tab>
31+
<Tabs.Tab>
32+
```sh copy
33+
npm install -D @terai/dev
34+
npm install @terai/vite
35+
npx terai init
36+
````
37+
38+
</Tabs.Tab>
39+
</Tabs>
40+
41+
### Number
42+
43+
This function uses `Intl.NumberFormat` options.
44+
45+
```ts
46+
function format.number(
47+
value: number,
48+
options?: Intl.NumberFormatOptions & {format?: string}
49+
): string
50+
```
51+
52+
```tsx filename="example.tsx" copy
53+
import { useTs, useFormat } from '@terai/vite'
54+
55+
export function Example() {
56+
const { ts } = useTs()
57+
const format = useFormat()
58+
59+
return (
60+
<div>
61+
<p>{ts`Hello, world!`}</p>
62+
</div>
63+
)
64+
}
65+
```
66+
67+
```tsx
68+
function formatDate(
69+
value: number | Date,
70+
options?: Intl.DateTimeFormatOptions & { format?: string }
71+
): string
72+
```

website/src/pages/docs/concepts/translation.mdx

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ steps to configure and use the translator effectively.
1212
### Translator config
1313

1414
First, you need to configure the translator in your `terai.config.ts` file.
15-
While we recommend using our dedicated translation service (link to
16-
documentation), **Terai** also provides integrations with major translation
15+
**Terai** also provides integrations with major translation
1716
service providers.
1817

1918
```tsx

website/src/pages/docs/references/config.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ List of files glob to ignore.
4141
### outDir
4242

4343
- **Type**: `string`
44-
- **Default**: `""`
44+
- **Default**: `"./locale-system"`
4545

4646
The output directory for your locale system.
4747

website/src/pages/docs/usage/node.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Steps, Tabs } from 'nextra/components'
22

3-
# Using terai with Node
3+
# Using Terai with Node
44

55
Setting up terai in a Node project.
66

website/src/pages/docs/usage/react.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Steps, Tabs } from 'nextra/components'
22

3-
# Using terai with React
3+
# Using Terai with React
44

55
Setting up terai in a React project.
66

website/src/pages/docs/usage/vite.mdx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Steps, Tabs } from 'nextra/components'
22

3-
# Using terai with Vite
3+
# Using Terai with Vite
44

5-
Using **terai** in a **Vite** project.
5+
Using **Terai** in a **Vite** project.
66

77
## Installation
88

@@ -41,7 +41,6 @@ Install `terai` and create your `terai.config.ts` file.
4141
bun terai init
4242
```
4343
</Tabs.Tab>
44-
4544
</Tabs>
4645

4746
- [`init`](/docs/references/cli#terai-init): script that creates a

website/src/pages/index.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Terai
1+
# Terai

website/theme.config.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const config: ThemeConfig = {
5757
dark: 235
5858
},
5959
primarySaturation: {
60-
light: 70,
60+
light: 40,
6161
dark: 40
6262
},
6363
footer: {

website/tsconfig.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
"@/*": ["./src/*"]
2323
}
2424
},
25-
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
25+
"include": [
26+
"next-env.d.ts",
27+
"**/*.ts",
28+
"**/*.tsx",
29+
".next/types/**/*.ts",
30+
"src/pages/index.mdx"
31+
],
2632
"exclude": ["node_modules"]
2733
}

0 commit comments

Comments
 (0)