Skip to content

Commit 51171bb

Browse files
authored
Merge pull request #3 from wobedi/docs/readme-flatten-baselocale
docs(readme): document flatten and baseLocale options
2 parents d508e41 + ad6fe35 commit 51171bb

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ npm install @simplelocalize/typesafe-i18n-connector
1414

1515
### Export translations
1616

17-
Reads typesafe-i18n translation files from disk, flattens them into flat key-value JSON files, and writes them to the output directory.
17+
Reads typesafe-i18n translation files from disk, flattens them into flat key-value JSON files (or keeps the nested structure with `flatten: false`), and writes them to the output directory.
1818

1919
```ts
2020
import { exportTranslations } from '@simplelocalize/typesafe-i18n-connector'
@@ -153,11 +153,12 @@ await exportTranslations({
153153
})
154154
```
155155

156-
| Option | Type | Default | Description |
157-
| ------------------ | --------- | ---------------- | ------------------------------------------------------ |
158-
| `outputDir` | `string` | `./locales-json` | Directory to write exported JSON files to |
159-
| `cleanOutputDir` | `boolean` | `true` | Remove output directory before exporting |
160-
| `defaultNamespace` | `string` | `base` | Filename (without `.json`) for root-level translations |
156+
| Option | Type | Default | Description |
157+
| ------------------ | --------- | ---------------- | ----------------------------------------------------------------------------------------------------------------- |
158+
| `outputDir` | `string` | `./locales-json` | Directory to write exported JSON files to |
159+
| `cleanOutputDir` | `boolean` | `true` | Remove output directory before exporting |
160+
| `defaultNamespace` | `string` | `base` | Filename (without `.json`) for root-level translations |
161+
| `flatten` | `boolean` | `true` | Flatten nested keys with dots (e.g. `section.title`). Set to `false` to write nested JSON mirroring the source structure |
161162

162163
### Import options
163164

@@ -170,10 +171,11 @@ await importTranslations({
170171
})
171172
```
172173

173-
| Option | Type | Default | Description |
174-
| ------------------ | -------- | ---------------- | ------------------------------------------------------ |
175-
| `inputDir` | `string` | `./locales-json` | Directory to read JSON files from |
176-
| `defaultNamespace` | `string` | `base` | Filename (without `.json`) for root-level translations |
174+
| Option | Type | Default | Description |
175+
| ------------------ | -------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
176+
| `inputDir` | `string` | `./locales-json` | Directory to read JSON files from |
177+
| `defaultNamespace` | `string` | `base` | Filename (without `.json`) for root-level translations |
178+
| `baseLocale` | `string` | `en` | Locale processed first. Must match your typesafe-i18n base locale — other locales would otherwise have their namespace files silently skipped |
177179

178180
## License
179181

0 commit comments

Comments
 (0)