GitHub action to upload changed translation files in the base language from your GitHub repository to Lokalise TMS.
Step-by-step tutorial covering the usage of this action is available on Lokalise Developer Hub. To download translation files from Lokalise to GitHub, use the lokalise-pull-action.
Use this action in the following way:
name: Demo push with tags
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Push to Lokalise
uses: lokalise/[email protected]
with:
api_token: ${{ secrets.LOKALISE_API_TOKEN }}
project_id: LOKALISE_PROJECT_ID
base_lang: BASE_LANG_ISO
translations_path: |
TRANSLATIONS_PATH1
TRANSLATIONS_PATH2
file_format: FILE_FORMAT
additional_params: ADDITIONAL_CLI_PARAMS
You'll need to provide some parameters for the action. These can be set as environment variables, secrets, or passed directly. Refer to the General setup section for detailed instructions.
api_token
— Lokalise API token with read/write permissions.project_id
— Your Lokalise project ID.translations_path
— One or more paths to your translations. For example, if your translations are stored in thelocales
folder at the project root, uselocales
(leave out leading and trailing slashes). Defaults tolocales
.file_format
— Defines the format of your translation files, such asjson
for JSON files. Defaults tojson
. This format determines how translation files are processed and also influences the file extension used when searching for them. However, some specific formats, such asjson_structured
, still use the generic.json
extension. If you're using such a format, make sure to set thefile_ext
parameter explicitly to match the correct extension for your files. Alternatively, configure thename_pattern
parameter.base_lang
— The base language of your project (e.g.,en
for English). Defaults toen
.
file_ext
— Custom file extension to use when searching for translation files (without leading dot). By default, the extension is inferred from the file_format value. However, for certain formats (e.g.,json_structured
), the files may still have a generic extension (e.g.,.json
). In such cases, this parameter allows specifying the correct extension manually to ensure proper file matching. This parameter has no effect when thename_pattern
is provided.additional_params
— Extra parameters to pass to the Lokalise CLI when pushing files. For example, you can use--convert-placeholders
to handle placeholders. You can include multiple CLI arguments as needed. Defaults to an empty string.flat_naming
— Use flat naming convention. Set totrue
if your translation files follow a flat naming pattern likelocales/en.json
instead oflocales/en/file.json
. Defaults tofalse
.name_pattern
— Custom pattern for naming translation files. Overrides default language-based naming. Must include both filename and extension if applicable (e.g., "custom_name.json" or "**.yaml"). Default behavior is used if not set.- When the
name_pattern
is set, the action will respect yourtranslations_path
but won't append any language names as folders. Therefore, if you want to upload all JSON files with custom naming for the English locale, you'll need to providename_pattern: "en/**/custom_*.json"
. To upload all JSON files stored directly undertranslations_path
, you'll setname_pattern: "custom_*.json"
. The latter approach is similar toflat_naming
but enables you to define custom patterns.
- When the
skip_tagging
— Do not assign tags to the uploaded translation keys on Lokalise. Set this totrue
to skip adding tags like inserted, skipped, or updated keys. Defaults tofalse
.rambo_mode
— Always upload all translation files for the base language regardless of changes. Set this totrue
to bypass change detection and force a full upload of all base language translation files. Defaults tofalse
.max_retries
— Maximum number of retries on rate limit errors (HTTP 429). Defaults to3
.sleep_on_retry
— Number of seconds to sleep before retrying on rate limit errors. Defaults to1
.upload_timeout
— Timeout for the upload operation, in seconds. Defaults to120
.upload_poll_timeout
— Timeout for the upload poll operation, in seconds. Defaults to120
.
This action outputs the following values:
initial_run
— Indicates whether this is the first run on the branch. The value istrue
if thelokalise-upload-complete
tag does not exist, otherwisefalse
.files_uploaded
— Indicates whether any files were uploaded to Lokalise. The value istrue
if files were successfully uploaded, otherwisefalse
(e.g., no changes or upload step skipped).
When triggered, this action follows a multi-step process to detect changes in translation files and upload them to Lokalise:
-
Detect changed files:
- The action identifies all changed translation files for the base language specified under the
translations_path
. - Important: Changes are detected only between the latest commit and the one preceding it. This ensures that the action processes incremental changes rather than scanning the entire repository.
- The action identifies all changed translation files for the base language specified under the
-
Upload modified files:
- Any detected changes are uploaded to the specified Lokalise project in parallel, with up to six requests being processed simultaneously.
- Each translation key is tagged with the name of the branch that triggered the workflow for better traceability in Lokalise.
-
Handle initial push:
- If no changes are detected between the last two commits, the action determines if it is running for the first time on the branch:
- First run: The action checks for the presence of a
lokalise-upload-complete
tag.- If the tag is not found, it performs an initial upload, processing all translation files for the base language. This also happens when the
rambo_mode
is set totrue
. - After successfully uploading all files, the action creates a
lokalise-upload-complete
tag to mark the initial setup as complete.
- If the tag is not found, it performs an initial upload, processing all translation files for the base language. This also happens when the
- Subsequent runs: If the tag is found, the action exits without uploading any files, as the initial push has already been completed.
- First run: The action checks for the presence of a
- If no changes are detected between the last two commits, the action determines if it is running for the first time on the branch:
-
Mark completion:
- For the first run on the branch, after completing the initial upload, the action pushes the
lokalise-upload-complete
tag to the remote repository. - Recommendation: Pull the changes to your local repository to ensure the tag is included in your local Git history.
- For the first run on the branch, after completing the initial upload, the action pushes the
For more information on assumptions, refer to the Assumptions and defaults section.
By default, the following command-line parameters are set when uploading files to Lokalise:
--token
— Derived from theapi_token
parameter.--project-id
— Derived from theproject_id
parameter.--file
— The currently uploaded file.--lang-iso
— The language ISO code of the translation file.--replace-modified
--include-path
--distinguish-by-file
--poll
--poll-timeout
— Derived from theupload_poll_timeout
parameter.--tag-inserted-keys
--tag-skipped-keys
--tag-updated-keys
--tags
— Set to the branch name that triggered the workflow.
Apache license version 2