Skip to content

Commit a622423

Browse files
committed
Docs
1 parent d1144b1 commit a622423

File tree

12 files changed

+703
-58
lines changed

12 files changed

+703
-58
lines changed

README.md

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,15 @@
1-
# Starlight Starter Kit: Basics
1+
# Documentation
22

3-
[![Built with Starlight](https://astro.badg.es/v2/built-with-starlight/tiny.svg)](https://starlight.astro.build)
4-
5-
```
6-
npm create astro@latest -- --template starlight
3+
```bash
4+
git clone https://github.com/LibreTranslate/Documentation
5+
cd Documentation
6+
npm i
7+
npm run dev
78
```
89

9-
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/starlight/tree/main/examples/basics)
10-
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/starlight/tree/main/examples/basics)
11-
[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/withastro/starlight&create_from_path=examples/basics)
12-
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fwithastro%2Fstarlight%2Ftree%2Fmain%2Fexamples%2Fbasics&project-name=my-starlight-docs&repository-name=my-starlight-docs)
13-
14-
> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
15-
16-
## 🚀 Project Structure
17-
18-
Inside of your Astro + Starlight project, you'll see the following folders and files:
19-
20-
```
21-
.
22-
├── public/
23-
├── src/
24-
│ ├── assets/
25-
│ ├── content/
26-
│ │ ├── docs/
27-
│ └── content.config.ts
28-
├── astro.config.mjs
29-
├── package.json
30-
└── tsconfig.json
31-
```
10+
* Open http://localhost:4321
3211

33-
Starlight looks for `.md` or `.mdx` files in the `src/content/docs/` directory. Each file is exposed as a route based on its file name.
34-
35-
Images can be added to `src/assets/` and embedded in Markdown with a relative link.
36-
37-
Static assets, like favicons, can be placed in the `public/` directory.
38-
39-
## 🧞 Commands
12+
## Commands
4013

4114
All commands are run from the root of the project, from a terminal:
4215

@@ -49,6 +22,19 @@ All commands are run from the root of the project, from a terminal:
4922
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
5023
| `npm run astro -- --help` | Get help using the Astro CLI |
5124

52-
## 👀 Want to learn more?
25+
## Translation
26+
27+
Localization for these docs is enabled. In order to add a new language, create a folder in `src/contents/docs/<langcode>` and copy the English versions of `index.mdx`, `guides` and `community` to it. Then add the language to `astro.config.mjs`:
28+
29+
```json
30+
locales: {
31+
// ...
32+
it: {
33+
label: 'Italiano',
34+
},
35+
},
36+
```
37+
38+
## More Information
5339

54-
Check out [Starlight’s docs](https://starlight.astro.build/), read [the Astro documentation](https://docs.astro.build), or jump into the [Astro Discord server](https://astro.build/chat).
40+
Check out [Starlight’s docs](https://starlight.astro.build/), read [the Astro documentation](https://docs.astro.build).

astro.config.mjs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,22 @@ export default defineConfig({
3030
},
3131
{
3232
label: 'Guides',
33-
autogenerate: { directory: 'guides' },
33+
items: [
34+
{ slug: 'guides/installation' },
35+
{ slug: 'guides/api_usage' },
36+
{ slug: 'guides/manage_api_keys' },
37+
{ slug: 'guides/build_from_sources' },
38+
{ slug: 'guides/integrations' },
39+
{ slug: 'guides/contributing' },
40+
]
3441
},
3542
{
3643
label: "Community",
37-
collapsed: true,
44+
collapsed: false,
3845
items: [
39-
{ label: "Forum", link: "https://community.libretranslate.com" },
40-
{ label: "GitHub", link: "https://github.com/LibreTranslate/" },
46+
{ slug: 'community/resources' },
47+
{ slug: 'community/mirrors' },
48+
{ slug: 'community/projects' },
4149
]
4250
},
4351
...openAPISidebarGroups,
@@ -56,6 +64,10 @@ export default defineConfig({
5664
},
5765
},
5866

67+
editLink: {
68+
baseUrl: 'https://github.com/LibreTranslate/Documentation/edit/main/',
69+
},
70+
5971
plugins: [
6072
// Generate the OpenAPI documentation pages.
6173
starlightOpenAPI([
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: Mirrors
3+
description: List of available mirrors for LibreTranslate.
4+
---
5+
6+
This is a list of public LibreTranslate instances. Some require an API key. If you want to add a new URL, please open a pull request.
7+
8+
| URL | API Key Required | Links |
9+
| ------------------------------------------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------- |
10+
| [libretranslate.com](https://libretranslate.com) | ✔️ | [ [Get API Key](https://portal.libretranslate.com) ] [ [Service Status](https://status.libretranslate.com/) ] |
11+
| [translate.flossboxin.org.in](https://translate.flossboxin.org.in/) | | [ [Contact/eMail](mailto:dev@flossboxin.org.in) ] |
12+
| [lt.blitzw.in](https://lt.blitzw.in/) | | |
13+
14+
## TOR/i2p Mirrors
15+
16+
| URL |
17+
| ---------------------------------------------------------------------------------------------------------------------------------------------- |
18+
| [lt.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion](http://lt.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion/) |
19+
| [lt.vern.i2p](http://vernf45n7mxwqnp5riaax7p67pwcl7wcefdcnqqvim7ckdx4264a.b32.i2p/) |
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: Projects
3+
description: List of projects part of LibreTranslate.
4+
---
5+
6+
In addition to [LibreTranslate](https://github.com/LibreTranslate/LibreTranslate) we work on and maintain several projects related to machine translation. Some of them are listed below:
7+
8+
* [LTEngine](https://github.com/LibreTranslate/LTEngine): Machine translation powered by LLMs with a LibreTranslate-compatible API
9+
* [LexiLang](https://github.com/LibreTranslate/LexiLang): Simple, fast dictionary-based language detector for short texts
10+
* [Locomotive](https://github.com/LibreTranslate/Locomotive): Toolkit for training/converting LibreTranslate compatible language models
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Resources
3+
description: List of community resources for LibreTranslate.
4+
---
5+
6+
## Forum
7+
8+
All discussions related to the project take place on the community forum. This is also the best place to ask for help. Come say hi!
9+
10+
https://community.libretranslate.com
11+
12+
## GitHub
13+
14+
The source code for the project is hosted on GitHub. The issue tracker there can be used for reporting problems, but not for asking questions. Use the forum instead.
15+
16+
https://github.com/LibreTranslate/LibreTranslate
17+
18+
## BlueSky
19+
20+
We have a low-volume BlueSky account that we use for broadcasting the latest news from the project.
21+
22+
https://bsky.app/profile/libretranslate.com
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
---
2+
title: API Usage
3+
description: How to translate with LibreTranslate.
4+
---
5+
6+
The examples below use Javascript, but you can use any programming language. [Language bindings](#language-bindings) for many programming languages are also available.
7+
8+
### Simple Translation
9+
10+
Request:
11+
12+
```javascript
13+
const res = await fetch("https://libretranslate.com/translate", {
14+
method: "POST",
15+
body: JSON.stringify({
16+
q: "Hello!",
17+
source: "en",
18+
target: "es",
19+
api_key: "xxxxxx" // can be optional with self-hosting
20+
}),
21+
headers: { "Content-Type": "application/json" },
22+
});
23+
24+
console.log(await res.json());
25+
```
26+
27+
Response:
28+
29+
```javascript
30+
{
31+
"translatedText": "¡Hola!"
32+
}
33+
```
34+
35+
:::note
36+
The `api_key` parameter is only required when using an instance configured with API keys, such as [libretranslate.com](https://libretranslate.com). Self-hosted instances do not require it.
37+
:::
38+
39+
### Auto Detection of Source Language
40+
41+
Request:
42+
43+
```javascript
44+
const res = await fetch("https://libretranslate.com/translate", {
45+
method: "POST",
46+
body: JSON.stringify({
47+
q: "Bonjour!",
48+
source: "auto",
49+
target: "en",
50+
api_key: "xxxxxx"
51+
}),
52+
headers: { "Content-Type": "application/json" },
53+
});
54+
55+
console.log(await res.json());
56+
```
57+
58+
Response:
59+
60+
```javascript
61+
{
62+
"detectedLanguage": {
63+
"confidence": 90.0,
64+
"language": "fr"
65+
},
66+
"translatedText": "Hello!"
67+
}
68+
```
69+
70+
### Translate HTML/Markup
71+
72+
Request:
73+
74+
```javascript
75+
const res = await fetch("https://libretranslate.com/translate", {
76+
method: "POST",
77+
body: JSON.stringify({
78+
q: '<p class="green">Hello!</p>',
79+
source: "en",
80+
target: "es",
81+
format: "html",
82+
api_key: "xxxxxx"
83+
}),
84+
headers: { "Content-Type": "application/json" },
85+
});
86+
87+
console.log(await res.json());
88+
```
89+
90+
Response:
91+
92+
```javascript
93+
{
94+
"translatedText": "<p class=\"green\">¡Hola!</p>"
95+
}
96+
```
97+
98+
### Alternative Translations
99+
100+
Request:
101+
102+
```javascript
103+
const res = await fetch("https://libretranslate.com/translate", {
104+
method: "POST",
105+
body: JSON.stringify({
106+
q: "Hello",
107+
source: "en",
108+
target: "it",
109+
format: "text",
110+
alternatives: 3,
111+
api_key: "xxxxxx"
112+
}),
113+
headers: { "Content-Type": "application/json" },
114+
});
115+
116+
console.log(await res.json());
117+
```
118+
119+
Response:
120+
121+
```javascript
122+
{
123+
"alternatives": [
124+
"Salve",
125+
"Pronto"
126+
],
127+
"translatedText": "Ciao"
128+
}
129+
```
130+
131+
### Language Detection
132+
133+
Request:
134+
135+
```javascript
136+
const res = await fetch("https://libretranslate.com/detect", {
137+
method: "POST",
138+
body: JSON.stringify({
139+
q: "Bonjour!",
140+
}),
141+
headers: { "Content-Type": "application/json" },
142+
});
143+
144+
console.log(await res.json());
145+
```
146+
147+
Response:
148+
149+
```javascript
150+
[{
151+
"confidence": 90.0,
152+
"language": "fr"
153+
}]
154+
```
155+
156+
157+
### Supported Languages
158+
159+
https://libretranslate.com/languages
160+
161+
## Language Bindings
162+
163+
You can use the LibreTranslate API using the following bindings:
164+
165+
- Rust: <https://github.com/DefunctLizard/libretranslate-rs>
166+
- Node.js: <https://github.com/franciscop/translate>
167+
- TypeScript: <https://github.com/tderflinger/libretranslate-ts>
168+
- .Net: <https://github.com/sigaloid/LibreTranslate.Net>
169+
- Go: <https://github.com/SnakeSel/libretranslate>
170+
- Python: <https://github.com/argosopentech/LibreTranslate-py>
171+
- PHP: <https://github.com/jefs42/libretranslate>
172+
- C++: <https://github.com/argosopentech/LibreTranslate-cpp>
173+
- Swift: <https://github.com/wacumov/libretranslate>
174+
- Unix: <https://github.com/argosopentech/LibreTranslate-sh>
175+
- Shell: <https://github.com/Hayao0819/Hayao-Tools/tree/master/libretranslate-sh>
176+
- Java: <https://github.com/suuft/libretranslate-java>
177+
- Ruby: <https://github.com/noesya/libretranslate>
178+
- R: <https://github.com/myanesp/libretranslateR>

0 commit comments

Comments
 (0)