This document provides examples and explanations for using the Translation Filesystem API. The API allows you to add, remove, list, and purge translations for the FUSE-based translation filesystem.
The API is accessible at http://localhost:6000
. Adjust this if you've configured a different host or port.
Endpoint: /add_translation
Method: POST
Description: Adds a new translation or updates an existing one.
{
"original": "/path/to/original/file.txt",
"translated": "/virtual/path/to/translated/file.txt"
}
curl -X POST http://localhost:6000/add_translation \
-H "Content-Type: application/json" \
-d '{"original": "/documents/english/hello.txt", "translated": "/documents/spanish/hola.txt"}'
{
"status": "success",
"message": "Translation added successfully"
}
Endpoint: /remove_translation
Method: POST
Description: Removes an existing translation.
{
"original": "/path/to/original/file.txt"
}
curl -X POST http://localhost:6000/remove_translation \
-H "Content-Type: application/json" \
-d '{"original": "/documents/english/hello.txt"}'
{
"status": "success",
"message": "Translation removed successfully"
}
Endpoint: /list_translations
Method: GET
Description: Retrieves a list of all current translations.
curl http://localhost:6000/list_translations
{
"translations": [
["/documents/english/hello.txt", "/documents/spanish/hola.txt"],
["/documents/english/goodbye.txt", "/documents/spanish/adios.txt"]
]
}
Endpoint: /purge_all_translations
Method: POST
Description: Removes all existing translations from the system.
curl -X POST http://localhost:6000/purge_all_translations
{
"status": "success",
"message": "All translations purged successfully"
}
If an error occurs, the API will return a JSON response with a status code of 400 or 500, depending on the type of error. The response body will include an "error" field with a description of the error.
Example error response:
{
"status": "error",
"message": "Missing 'original' or 'translated' in request"
}
- Ensure that the FUSE filesystem is mounted and the API server is running before making requests.
- The "original" path should be the actual path on your filesystem, while the "translated" path is the virtual path where you want the translated file to appear.
- You can use the list_translations endpoint to verify that your translations have been added or removed successfully.
- Remember that changes made through the API will be reflected in the mounted filesystem in real-time.
- The purge_all_translations endpoint will remove all translations from the system. Use this with caution, as it cannot be undone.
For any issues or feature requests, please contact the system administrator or file an issue in the project's repository.