Interactive script to download multiple source files from your organization

Hello, Transifex Chefs!:fork_and_knife: Today, we’re cooking up a special script to supercharge your localization kitchen. This recipe will help you bulk download source files from your Transifex projects, seasoning your workflow with efficiency and precision. Grab your aprons—let’s start cooking! :spoon::computer::sparkles:

Before we start mixing ingredients, ensure you have:

  • :key: A valid Transifex API token—think of this as your secret sauce!
  • :office: The slug of your Transifex organization—where all your projects live.
  • (Optional) :dart: Slugs of specific projects and resources—pick just the flavors you need!

Key Concepts

API Token: Your secret pass to authenticate and interact with the Transifex API. Ensure it’s valid and keep it secure. :closed_lock_with_key:

Organization Slug: The unique identifier for your Transifex organization. You’ll need this to specify from which organization to download the source files. :label:

Project Slug: (Optional) Unique identifiers for the projects you want to download files from. If not provided, the script can fetch files from all projects. :open_file_folder:

Resource Slug: (Optional) Unique identifiers for the resources within a project. If not provided, the script can fetch all resources. :page_facing_up:

:fried_egg: How to Cook This Recipe

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

python recipe-source.py

  1. Provide required inputs: The script will prompt you to enter your API token, organization slug, and options to specify projects and resources. Example:
Please enter your API token: YOUR_API_TOKEN
Please enter your Organization slug: YOUR_ORG_SLUG
Do you want source files **for** [a]ll projects **or** [s]pecific ones? [a/s]: a
Do you want source files **for** [a]ll resources **or** [s]pecific resources? [a/s]: s
Please enter the resources slugs, separate them **with** a comma (,): resource1,resource2
  1. Download source files: The script will process your input and download the specified source files to a directory structured as:

organization_slug/project_slug/resource_filename.

:star2: Successful Outputs

Upon successful execution, you will see messages indicating the progress and completion of source file downloads:

  • For each project:

Source-Download **for** Project PROJECT_SLUG started.

  • For each resource within a project:
* - Source files **for** Resource: RESOURCE_NAME started.
* - Source files **for** Resource: RESOURCE_NAME completed.
  • When all files for a project are downloaded:

Source-Files-Download **for** Project PROJECT_SLUG completed.

:mag: Error Kitchen Nightmares

If there’s a hiccup, such as a missing ingredient or a burnt file:

  • If no resource is found to get i18n format:

No resource found to get l18n format

  • If the source file fails to download:

The source file failed to be downloaded: ERROR_MESSAGE

Errors will be logged in app.log in your script’s directory—like a recipe journal for troubleshooting!

Final Plating

With this script, your Transifex experience should be as smooth as your favorite gravy! If you encounter any snags, just consult the logs—they’re like your cookbook’s troubleshooting page.

:star2: Ready to get started? Dive into your Transifex projects with this handy tool, and taste the flavor of efficiency! Don’t forget to share your success stories or any questions in our community forum. Happy translating, and enjoy your efficient, new workflow in the Transifex kitchen! :cook:

1 Like