Skip to main content

A package to translate REDCap language libraries

Project description

REDCap Language Library Translator

Overview

The REDCap Language Library Translator is a Python script designed to translate the "default" values in a REDCap JSON file into a user-defined language using the Google Translate API. The script handles large text translations by breaking them into manageable chunks and also manages translation errors by logging them into a separate file.

Features

  • Language Support: Translates "default" values into a wide range of languages.
  • Chunk Processing: Handles large texts by breaking them into smaller chunks.
  • Error Handling: Logs any translation errors into a separate file.
  • JSON Key Updates: Updates the display and key fields in the JSON file to reflect the new language.

Supported Languages

Supported Languages
Afrikaans Haitian Creole Pashto
Amharic Hebrew Persian (Farsi)
Arabic Hindi Polish
Azerbaijani Hungarian Portuguese
Bashkir Icelandic Punjabi
Belarusian Indonesian Queretaro Otomi
Bengali Irish Romanian
Bosnian Italian Russian
Bulgarian Japanese Samoan
Catalan Kannada Scots Gaelic
Cebuano Kazakh Serbian
Chinese (Simplified) Khmer Slovak
Chinese (Traditional) Klingon (TlhIngan Hol) Slovenian
Chuvash Korean Spanish
Croatian Kurdish Swahili
Czech Kyrgyz Swedish
Danish Lao Tajik
Dutch Latvian Tamil
English Lithuanian Telugu
Esperanto Luxembourgish Thai
Estonian Macedonian Tongan
Fijian Malagasy Turkish
Filipino Malay Turkmen
Finnish Maltese Ukrainian
French Mongolian Urdu
Georgian Nepali Uyghur
German Norwegian Uzbek
Greek Odia Vietnamese
Gujarati Yiddish Welsh
Xhosa Yoruba Zulu

REDCap Language Library Translator

How It Works

User Input:

  • The script prompts the user to select the JSON file using a graphical file dialog.
  • The user specifies the target language for translation.

Extract Default Values:

  • The script extracts all "default" and "translation" values from the JSON file.

Create Subfolder:

  • A subfolder is created based on the version of the JSON file and the target language.

Save Extracted Data:

  • The extracted data is saved into a new JSON file within the subfolder.

Translate Values:

  • The script translates the "default" values in the new JSON file.
  • If any translation errors occur, the corresponding key-value pairs are logged into a separate "errors" file.

Update Original JSON:

  • The script updates the original JSON file with the new translated values.
  • The display and key fields are updated to reflect the new language.

Cleanup:

  • The temporary translation file is deleted.

Error Handling

If any errors occur during the translation process, the script logs the corresponding key-value pairs into a separate file named {language}_Error.log within the subfolder. This allows users to review and address translation issues separately.

Contributions

Contributions are welcome! If you have any suggestions or improvements, please submit a pull request or open an issue on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Acknowledgments

The googletrans package for providing translation capabilities. The REDCap community for their support and resources.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

REDCapLLT-3.0.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

REDCapLLT-3.0.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file REDCapLLT-3.0.0.tar.gz.

File metadata

  • Download URL: REDCapLLT-3.0.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for REDCapLLT-3.0.0.tar.gz
Algorithm Hash digest
SHA256 b43e566ad8f4f4f9963d924ccffda9aa4f07e45429abff86aaab413a888c4782
MD5 0c9f9a86e0e51708f1eb9d5589140f1c
BLAKE2b-256 be53b479d025ed05c8bf5f0f0f1ca00155b663ad3f05073c56c70c405c4ca48e

See more details on using hashes here.

File details

Details for the file REDCapLLT-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: REDCapLLT-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for REDCapLLT-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1aa036ecbd41dc288c2ee13f652be3b6228fab97f0122c53d5e43435e74b39a0
MD5 b4dc65d3e3a98d50a3ac3eb928737179
BLAKE2b-256 a896e9b982a620a8d4e95e9e4f2e89e54776385d604196217de29a938a17aa67

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page