Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n: Continue Spanish translation, parts 3 and 4 #449

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

hasecilu
Copy link

@hasecilu hasecilu commented Sep 26, 2024

Some fixes were done thanks by using PO file with Poedit. It enhances a lot the workflow for translators. Previously using Neovim to translate was somewhat painful 🤪.


In order to easy the process to find the missing strings on alredy-translated JSON files I made a small script to create a PO file to translate it using Poedit, it tells you of minor issues like extra final point, case dfferences, etc.

The script could be the base for a sane workflow, maybe creating a Makefile or something like that.

Screenshot_2024-09-25_15-47-29

#!/usr/bin/env bash

# --------------------------------------------------------------------------------------------------
#
# Create a PO file to make easier the labor of translation
#
# Info:
# 	https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html
# 	https://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/json2po.html
#
# Dependencies:
# 	jq
# 	translate-toolkit
# 		python-wcwidth
#
# Created by @hasecilu
#
# --------------------------------------------------------------------------------------------------

locales=(cn es ro)

# NOTE: Step 1
# Create PO files from English and localized JSON files as source
for locale in "${locales[@]}"; do
	json2po -t en "${locale}" "po-${locale}"
done

# NOTE: Step 2
# Make the translation

# NOTE: Step 3
# Update the localized JSON file with missing tags
# Needed to then replace with translated strings
for locale in "${locales[@]}"; do
	jq -s '.[0] * .[1]' en/translation.json "${locale}"/translation.json >merged.json
	mv merged.json "${locale}"/translation.json
done

# NOTE: Step 4
# Recover translation from PO files to JSON file
# Remember to set the indentation to 2 spaces
for locale in "${locales[@]}"; do
	po2json -t en "po-${locale}" "${locale}"
done

# NOTE: Step 5
# Remove PO files
for locale in "${locales[@]}"; do
	rm -r "po-${locale}"
done

Some fixes were done thanks by using PO file with Poedit. It enhances a
lot the workflow for translators

---

Step 1: Create PO files from English and localized JSON files as source
$ json2po -t en es po-es

Step 2: Make the translation

Step 3: Recover translation from PO files to JSON file. Remember to set
the indentation to 2 spaces
$ po2json -t en po-es es

Step 4: Update localized JSON file with missing tags from English JSON
$ jq -s '.[0] * .[1]' en/translation.json \
    es/translation.json > merged.json
$ mv merged.json es/translation.json

Step 5: Remove PO files
$ rm -r po-es
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants