Interactive script to download multiple language files from your organization

Hello, Transifex followera! :man_mage: Today, we’re diving into a magical script that will help you conjure up translation files en masse from your Transifex projects. This handy utility is designed to save you time and effort by automating the bulk download process. So, grab your wands—let’s get casting! :sparkles::crystal_ball::sparkles:

Prerequisites

Before we start casting spells, make sure you have the following:

:key: Transifex API Token: Your enchanted key to unlock and interact with the Transifex API.

:office: Organization Slug: The unique identifier for your Transifex organization—where all your projects and resources reside.

(Optional) :dart: Project Slugs & Resource Slugs: Specify these to target particular projects or resources. This way, you can fetch only the translations you need.

(Optional) :earth_africa: Language Codes: If you need translations for specific languages, make sure to have the language codes handy.

Key Concepts

  • API Token: The magical key for authenticating your requests to the Transifex API. Keep it safe and ready to use. :closed_lock_with_key:
  • Organization Slug: This slug identifies your organization on Transifex, ensuring the script knows where to look for your files. :label:
  • Project Slug: (Optional) A unique identifier for each project within your organization. Specify these if you want to download translations from certain projects only. :open_file_folder:
  • Resource Slug: (Optional) Identifiers for the resources within a project. Use these if you wish to narrow down the downloads to specific files. :page_facing_up:
  • Language Codes: (Optional) Language codes for the translations you need. If not specified, the script will download all available languages. :globe_with_meridians:

:cook: How to Work Your Magic

  1. Run the Script: Execute the script from your terminal:

python transifex_download_utility.py

  1. Provide Required Inputs: The script will prompt you to enter your API token, organization slug, and options for selecting specific projects, resources, and languages. Here’s what you’ll encounter:

Please enter your API token: YOUR_API_TOKEN
Please enter your Organization slug: YOUR_ORG_SLUG
Do you want translations for [a]ll projects or [s]pecific ones? [a/s]: a
Do you want translations for [a]ll languages or [s]pecific ones? [a/s]: s
Please enter the language codes, separate them with a comma (,): en,fr,es
Do you want translations for [a]ll resources or [s]pecific resources? [a/s]: s
Please enter the resource slugs, separate them with a comma (,): resource1,resource2

  1. Download Translations: Based on your input, the script will start downloading the translation files to a directory with the following structure:

organization_slug/project_slug/filename

You will see progress messages indicating the status of each download, including when each project and resource is completed.

:star2: Successful Outputs

Once the script has worked its magic, you’ll see output messages like these:

  • For each project:

Translations-Download for Project PROJECT_SLUG started.

  • For each resource within a project:

`- Translations for Resource: RESOURCE_NAME & language: LANGUAGE_CODE started.

  • Translations for Resource: RESOURCE_NAME & language: LANGUAGE_CODE completed.`
  • When all files for a project are downloaded:

Translations-Download for Project PROJECT_SLUG completed.

:mag: Troubleshooting with Error Logs

Even the best wizards can hit a snag. The script will log the issue if something goes wrong, such as a missing translation file or an error during download. Keep an eye out for these messages:

  • Missing Resources:

No resource found to get l18n format

  • Download Failures:

The file failed to be downloaded: ERROR_MESSAGE

All errors will be recorded in app.log in your script’s directory, so you can review them later.

Final Words of Wisdom

With this script, downloading translations from your Transifex projects should feel like a walk in the enchanted woods! :evergreen_tree: If you run into any issues, consult the error logs—they’re your best guide. And don’t forget to share your success stories or any challenges you face in our community forum.

Ready to work some magic? :woman_mage: Dive into your Transifex projects with this tool and experience the ease of automated translation downloads. Happy translating, and may your workflows be ever-efficient! :sparkles:

1 Like