Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
This is the documentation repository of LibreTranslate, a free and open source translation API.

# Where to find contents

- `src/docs`: directory with documentation pages in mdx and markdown format

# Rules

- The tone of translation should be technical. The context of translation is that of drone mapping software and photogrammetry.
- When updating translations, always look at the current git diff to see which sections were changed. If there are no active changes in the current branch, compare against the latest commit (git diff HEAD~1 HEAD)
- Never edit or commit any file in `src/content/docs/api`, `src/content/docs/reference`, `src/content/docs/tutorials`, `src/content/index.mdx` or `src/content/*.md`. These are the original English pages
- Always preserve images in the proper places.
- Each translation for other languages, like Italian or Spanish, needs to be added as subfolder in `src/content/docs/[langcode]`, where `langcode` is the 2 letter ISO 639 language code. For example, Italian docs go in `src/content/docs/it/`.
- Each translation must have an `index.mdx` and copies of each subfolder (`api`, `reference`, `tutorials`) and a copy of each markdown file in each subfolder. Always verify that the number of pages match.
- Always create/update ALL the markdown files when asked to add or update a translation.
- Always translate from English, never from another language.
- Always verify all translations for accuracy and completeness in all markdown files, then fix all inaccuracies and fill any missing section, if any.
- When translating internal links, we always reference them with the appropriate URL that maps to a markdown file of the translation.
- Never modify any other file other than those in `src/content` or `astro.config.mjs` without explicit permission.
- When translating, always check that all the sidebar items in `astro.config.mjs` have a proper translation item in the `translations` key.
- At the top of markdown documents, make sure to always fill in the template preamble `---` with `title: <translated title>` and `template: doc`

# How to build / check that the website builds

```bash
nvm use 22
npm run build
```

The outputs will be in `dist/`.

# Glossaries / Nuances

These words / sentences should be treated carefully:

## Machine

Should be interpreted as "computer" or "system" (not a literal machine).

E.g. in Spanish use "equipo" or "computadora", not "máquina".
161 changes: 135 additions & 26 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ export default defineConfig({
components: {
EditLink: './src/components/EditLink.astro',
},
defaultLocale: 'root',
locales: {
// English docs at the root of `src/content/docs/`
root: {
label: 'English',
lang: 'en'
},
// Italian docs in `src/content/docs/it/`
it: {
label: 'Italiano',
lang: 'it'
}
},
plugins: [
// Generate the OpenAPI documentation pages.
starlightOpenAPI([
Expand Down Expand Up @@ -56,132 +69,228 @@ export default defineConfig({
sidebar: [
{
label: 'Installation',
translations: {
it: "Installazione"
},
slug: 'installation'
},
{
label: 'Ground Control Points',
translations: {
it: "Punti di Controllo a Terra"
},
slug: 'ground-control-points'
},
{
label: 'Multispectral and Thermal',
translations: {
it: "Multispettrale e Termico"
},
slug: 'multispectral'
},
{
label: 'Tutorials',
translations: {
it: "Tutorial"
},
items: [
{
label: 'Creating Quality Orthophotos',
slug: 'tutorials/creating-high-quality-orthophotos'
slug: 'tutorials/creating-high-quality-orthophotos',
translations: {
it: "Creazione di Ortofoto di Qualità"
}
},
{
label: 'Digital Elevation Models',
slug: 'tutorials/creating-digital-elevation-models'
slug: 'tutorials/creating-digital-elevation-models',
translations: {
it: "Modelli Digitali di Elevazione"
}
},
{
label: '3D Viewer',
slug: 'tutorials/potree-3d-viewer'
slug: 'tutorials/potree-3d-viewer',
translations: {
it: "Visualizzatore 3D"
}
},
{
label: 'Measuring Stockpiles',
slug: 'tutorials/measuring-stockpile-volume'
slug: 'tutorials/measuring-stockpile-volume',
translations: {
it: "Misurazione di Cumuli"
}
},
{
label: 'Large Datasets',
slug: 'tutorials/large-datasets'
slug: 'tutorials/large-datasets',
translations: {
it: "Grandi Set di Dati"
}
},
{
label: 'Using Docker',
slug: 'tutorials/using-docker'
slug: 'tutorials/using-docker',
translations: {
it: "Uso di Docker"
}
},
{
label: 'Using Podman',
slug: 'tutorials/using-podman'
slug: 'tutorials/using-podman',
translations: {
it: "Uso di Podman"
}
},
{
label: 'Calibrating the Camera',
slug: 'tutorials/calibrating-the-camera'
slug: 'tutorials/calibrating-the-camera',
translations: {
it: "Calibrazione della Fotocamera"
}
},
{
label: 'Using Image Masks',
slug: 'tutorials/using-image-masks'
slug: 'tutorials/using-image-masks',
translations: {
it: "Uso di Maschere di Immagine"
}
},
{
label: 'Using Singularity',
slug: 'tutorials/using-singularity'
slug: 'tutorials/using-singularity',
translations: {
it: "Uso di Singularity"
}
},
{
label: 'Options Selection Guide',
slug: 'tutorials/options-selection-guide'
slug: 'tutorials/options-selection-guide',
translations: {
it: "Guida alla Selezione delle Opzioni"
}
},
]
},
{
label: 'Flying Tips',
slug: 'flying-tips'
slug: 'flying-tips',
translations: {
it: "Consigli di Volo"
}
},
{
label: 'Options & Flags',
slug: 'options-flags'
slug: 'options-flags',
translations: {
it: "Opzioni e Flag"
}
},
{
label: 'Mission Planning',
slug: 'mission-planning'
slug: 'mission-planning',
translations: {
it: "Pianificazione della Missione"
}
},
{
label: 'Frequently Asked Questions',
slug: 'faq'
slug: 'faq',
translations: {
it: "Domande Frequenti"
}
},
{
label: 'Support the Project',
slug: 'support-the-project'
slug: 'support-the-project',
translations: {
it: "Sostieni il Progetto"
}
},
{
label: 'Feedback & Feature Requests',
slug: 'feedback-feature-requests'
slug: 'feedback-feature-requests',
translations: {
it: "Feedback e Richieste di Funzionalità"
}
},
{
label: 'Developers',
translations: {
it: "Sviluppatori"
},
items: [
{
label: 'Contributing',
slug: 'contributing'
slug: 'contributing',
translations: {
it: "Contribuire"
}
},
{
label: 'Architecture',
slug: 'architecture'
slug: 'architecture',
translations: {
it: "Architettura"
}
},
{
label: 'Roadmap',
slug: 'roadmap'
slug: 'roadmap',
translations: {
it: "Roadmap"
}
},
{
label: 'Plugin Development Guide',
slug: 'plugin-development-guide'
slug: 'plugin-development-guide',
translations: {
it: "Guida allo Sviluppo di Plugin"
}
},
]
},
{
label: 'API',
translations: {
it: "API"
},
items: [
{
label: 'Quickstart',
slug: 'api/quickstart'
slug: 'api/quickstart',
translations: {
it: "Avvio Rapido"
}
},
{
label: 'Authentication',
slug: 'api/authentication'
slug: 'api/authentication',
translations: {
it: "Autenticazione"
}
},
{
label: 'Task',
slug: 'api/task'
slug: 'api/task',
translations: {
it: "Task"
}
},
{
label: 'Permissions',
slug: 'api/permissions'
slug: 'api/permissions',
translations: {
it: "Permessi"
}
},
{
label: 'Handling Errors',
slug: 'api/handlingerrors'
slug: 'api/handlingerrors',
translations: {
it: "Gestione degli Errori"
}
},
...openAPISidebarGroups
]
Expand Down
57 changes: 57 additions & 0 deletions src/content/docs/it/api/authentication.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: Autenticazione
template: doc
---

### Nozioni di Base sull'Autenticazione

> Ottenere il token di autenticazione:

```bash
curl -X POST -d "username=testuser&password=testpass" http://localhost:8000/api/token-auth/

{"token":"eyJ0eXAiO..."}
```

> Utilizzare il token di autenticazione:

```bash
curl -H "Authorization: JWT <your_token>" http://localhost:8000/api/projects/

{"count":13, ...}
```

> Utilizzare il token di autenticazione tramite querystring (meno sicuro):

```bash
curl http://localhost:8000/api/projects/?jwt=<your_token>

{"count":13, ...}
```


`POST /api/token-auth/`

Campo | Tipo | Descrizione
----- | ---- | -----------
username | string | Nome utente
password | string | Password

Per accedere all'API è necessario fornire un nome utente e una password validi. Puoi creare gli utenti dalla pagina di Amministrazione di WebODM.

Se l'autenticazione ha esito positivo, ti verrà rilasciato un token. Tutte le chiamate API devono includere il seguente header:

Header |
------ |
Authorization: JWT `your_token` |

Il token scade dopo un determinato periodo di tempo. Consulta [Scadenza del Token](#scadenza-del-token) per maggiori informazioni.

Poiché a volte le applicazioni non consentono di modificare gli header, è anche possibile autenticarsi aggiungendo il parametro querystring `jwt` a un URL protetto. Questo metodo è meno sicuro, quindi se possibile passa il token tramite header.


### Scadenza del Token

Per impostazione predefinita il token scade dopo sei ore. Il tempo di scadenza è definito nel modulo settings di Django in WebODM. Se compili WebODM dai sorgenti o lo esegui in modo nativo, il tempo di scadenza può essere modificato tramite la variabile `JWT_AUTH['JWT_EXPIRATION_DELTA']`. In caso contrario, ad esempio se utilizzi le immagini docker, dovrai richiedere un nuovo token quando un token scade.

Puoi capire che un token è scaduto se una qualsiasi chiamata API restituisce un codice di stato `403` con il corpo JSON `{'detail': 'Signature has expired.'}`.
19 changes: 19 additions & 0 deletions src/content/docs/it/api/handlingerrors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Gestione degli Errori
template: doc
---

Tutte le chiamate API utilizzano i codici di stato descritti nella [Guida ai Codici di Stato del Django REST Framework](http://www.django-rest-framework.org/api-guide/status-codes/), ma in generale è sufficiente verificare i codici di stato di successo (`200` o `204`), gestire il caso speciale della [Scadenza del Token](/it/api/authentication/#scadenza-del-token) (`403`) e segnalare un errore in tutti gli altri casi.

### Codici di Stato di Errore

Questo non è un elenco esaustivo, ma i codici di errore più comuni sono riportati di seguito.

Codice di Stato | Descrizione
----------- | -----------
401 | Non autenticato
403 | Accesso negato (token scaduto?)
400 | Richiesta malformata
404 | Non trovato

Per motivi di sicurezza, a volte un'operazione che dovrebbe restituire `403` restituisce `404`, per evitare di rivelare ID e altre informazioni a potenziali malintenzionati.
Loading
Loading