Quell-Datei
The source file represents a file that serves as the basis for translations or localizations. It contains keys and translations that are necessary for the management and processing of language resources within a project.
LocaleUI merges source files of different languages. LocaleUI checks for identical names or file names that differ only in the language code. If a file with the same name already exists, the new file is merged with the existing one. The API ID of the source file is used to identify the file.
The interface enables all source files in a project to be retrieved. The API ID, name and number of keys are returned for each source file.
Properties:
-
Method:
GET
-
Endpoint:
https://localeui.com/api/v1/projects/[Project API ID]/source_files
- Authentication: Required (bearer token)
-
Path parameters:
-
Project API ID
(String) - The unique API ID of the project
-
Example request:
Command Line$ curl -X GET https://localeui.com/api/v1/projects/[Project API ID]/source_files \ -H "Authorization: Bearer [Your API token]" \ -H "Content-Type: application/json"
Example response:
In response to a valid request to the interface, an array of source files stored in the project is returned. The following data is returned for each source file.
Response 200 OK[ { "api_id": "fil_12345678901234567890", "name": "filename.yml", "keys": 10 }, ... ]
Response field description
api_id
name
keys
The interface makes it possible to retrieve a source file in a project for a stored language. This request can be used to load information about a source file - such as API ID, name and the keys and translations contained in the file.
Properties:
-
Method:
GET
-
Endpoint:
https://localeui.com/api/v1/projects/[Project API ID]/source_files/[Source file API ID]?locale_id=[Locale API ID]
- Authentication: Required (bearer token)
-
Path parameters:
-
Project API ID
(String) - The unique API ID of the project -
Source file API ID
(String) - The unique API ID of the source file -
Locale API ID
(String) - The unique API ID of the locale (language)
-
Example request:
Command line$ curl -X GET https://localeui.com/api/v1/projects/[Project API ID]/source_files/[Source file API ID]?locale_id=[Locale API ID] \ -H "Authorization: Bearer [Your API token]" \ -H "Content-Type: application/json"
Example response:
In response to a valid request to the interface, the requested source file is returned with the content of the requested language. The following data is returned for the requested source file.
Response 200 OK{ "api_id": "fil_12345678901234567890", "name": "filename.yml", "keys": 10, "content": { "en": { "translation_key": "translation", ... } } }
Response field description
api_id
name
filename.yml
).keys
content
en
, de
). Each entry contains key/value pairs for the respective language.The interface enables a source file to be uploaded to a project. The content of the file is imported into localeUI and the translations it contains are imported into the stored languages.
Properties:
-
Method:
POST
-
Endpoint:
https://localeui.com/api/v1/projects/[Project API ID]/source_files
- Authentication: Required (bearer token)
-
Path parameters:
-
Project API ID
(String) - The unique API ID of the project
-
Example request:
Command line$ curl -X POST https://localeui.com/api/v1/projects/[Project API ID]/source_files \ -H "Authorization: Bearer [Your API token]" \ -H "Content-Type: application/json" \ -d '{ "filename": "example.json", "event_id": 1, "content": "{ \"key\": \"value\", ... }" }'
Request parameters
filename
event_id
content
JSON
or YAML
) and be serialized as text.LocaleUI checks whether the file already exists based on the file name. File names that contain language codes in other languages are also taken into account. If the file already exists, a new version of the file is created. If the file is not found, a new file is created in the project.
Example response:
Once a source file has been successfully uploaded, the API returns a JSON object with the most important information about the created file. This includes the unique file ID, the file name, the associated project ID and details of the current version of the file.
Response{ "api_id": "fil_12345678901234567890", "name": "example.json", "project_id": "pro_12345678901234567890", "last_version": { "id": "fiv_12345678901234567891", "number": 1, "upload": "api" } }
Response field description
api_id
name
filename.yml
).project_id
last_version.id
last_version.number
last_version.upload
api
, web
.