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.

Alle Quell-Dateien

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

Field
Type
Description
api_id
String
Unique identifier of the file as used internally by the API.
name
String
Name of the file, including file format (e.g. <code class="code gray">filename.yml</code>).
keys
Integer
Number of translation keys contained in the file.

Herunterladen einer Quell-Datei

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

Field
Type
Description
api_id
String
Unique identifier of the file as used internally by the API.
name
String
Name of the file, including file format (e.g. filename.yml).
keys
Integer
Number of translation keys contained in the file.
content
Object
Object with the actual translations, grouped by language code (e.g. en, de). Each entry contains key/value pairs for the respective language.

Hochladen einer Quell-Datei

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

Field
Type
Description
filename
String
Name of the file, including file format (e.g. <code class="code gray">filename.yml</code>).
event_id
Integer
API ID of the event in which the file will be uploaded and grouped.
content
String
The complete content of the file as a JSON string. The content must correspond to the selected format (e.g. 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

Field
Type
Description
api_id
String
Unique identifier of the file as used internally by the API.
name
String
Name of the file, including file format (e.g. filename.yml).
project_id
String
API ID of the project in which the file will be uploaded.
last_version.id
String
API ID of the last version of the file.
last_version.number
Integer
The version number of the last version of the file.
last_version.upload
String
Source of the upload, e.g. api, web.