Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexandre-fernandez/qwik-translate-routes
Generate translated routes for your qwik project.
https://github.com/alexandre-fernandez/qwik-translate-routes
Last synced: 14 days ago
JSON representation
Generate translated routes for your qwik project.
- Host: GitHub
- URL: https://github.com/alexandre-fernandez/qwik-translate-routes
- Owner: Alexandre-Fernandez
- License: mit
- Created: 2022-09-30T14:10:45.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-30T14:29:57.000Z (about 2 years ago)
- Last Synced: 2024-10-04T20:28:38.401Z (about 1 month ago)
- Language: TypeScript
- Homepage:
- Size: 25.4 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# qwik-translate-routes
> Generate translated routes for your qwik project.
## Installation
```
// npm
npm install -D qwik-translate-routes
// yarn
yarn add -D qwik-translate-routes
// pnpm
pnpm add -D qwik-translate-routes
```## Usage
- Star the [github repo](https://github.com/Alexandre-Fernandez/qwik-translate-routes) 😎
### CLI
```css
npx qwik-translate-routes [path_to_dir] --translations [path_to_translation_dir_or_file]
```### Module
```ts
import { translateDirectoryRecursive } from "qwik-translate-routes"translateDirectoryRecursive("./path/to/dir", [
"./path/to/translation/file/or/dir",
])
```### Translation files
Translation files must be a one level deep `.json` file, using the main directory's directory names as keys and the translation as value.
#### Example
_fr.json_
```json
{
"en": "fr",
"about": "a-propos",
"products": "produits"
}
```This translation file assumes your target directory is called `en` and has subdirectories (nesting doesn't matter) called `about` and `products`.
## Reference
### CLI
| Option | Shortcut | Argument | Description |
| -------------- | -------- | ----------- | --------------------------------------------------------------------------------------------------------------- |
| --translations | -tr | ...string[] | Sets what translations will be used to generate the translated directories, either a path to a dir or 1+ files. |#### Example
```css
npx qwik-translate-routes [path_to_dir] --tr [path_to_italian_translations] [path_to_german_translations]
```### Module
```ts
/**
* @param path A path to the directory to translate recursively (usually
* `src/routes/en`).
* @param translations An array of paths to `.json` translation files or an
* array containing a single path to a translation directory.
*/
export function translateDirectoryRecursive(
path: string,
translations: string[]
) {}
```