Wiki

Clone wiki

kindle-touch-l10n / MigrationOfFrameworkResourcesToUTF8

(not so obvious) prerequisites

  • Transifex client fork from https://bitbucket.org/ive_found/transifex-client (support of wildcard at resources list and 'delete' command were introduced at v0.6 and fork adds missing ability for deleting whole resource)
  • Python 2.6 or Python 2.7 for running migration Python tools (not Python 3.x)

Transifex client supports wildcard at resources list, i.e. using of star character as resource name. Backslash before star is required for avoiding of wildcard expansion in [Linux] shell. Backslash is maybe not needed in Windows command shell.

Make an announcement on Framework translation project

We are planning to change the type of the underlying resources from PROPERTIES to MOZILLAPROPERTIES. The advantage of MOZILLAPROPERTIES is that it encodes localized strings in UTF-8 encoding  (instead of ISO-8859-1 encoding with Unicode-escaped sequences), which allows for easy local editing of the underlying text file also for non-latin character sets, like cyrillic, greek, hebrew, etc.

However, a migration to this new format has to temporarily delete, and then re-upload all existing resources. Don't worry, all of your translations will be backed up before the migration, and restored afterwards, so not a single bit of your current contributions will be lost.

The transition period starts at: Jan XX, 2012 YY:00 UTC.
The transition period ends at:   Jan ZZ, 2012 WW:00 UTC.

Please DO NOT upload ANY translations DURING the transition period. Such contributions might silenty get lost. You have been warned.

While we do not expect other delays during the transition period, we can not entirely preclude them from happening. In case the transition takes longer than expected, please check http://www.mobileread.com/forums/showthread.php?p=1923544 for the current state of affairs.

Thanks for your understanding and your patience.

Make a new branch at Git repo, named framework-rc-migration and switch to it

git checkout -b framework-rc-migration

Backup all current translations of Framework project

We don't need to pull semi-translated files for ALL resources, mentioned at .tx/config, but only for Framework ones. It requires to pass Framework resources IDs as parameters to --resources option

Option -all means that client pulls even new files for given resources.

tx pull --all --resource=kindle-touch-framework.\*

Check somehow (?) that backup is complete and commit current state

git add src/5.0.0/framework/*
git commit -am "[framework-rc-migration] Backup of current state"
git push origin framework-rc-migration

Delete all Framework resources on transifex.net

Transifex client has delete command.

Without --force option client will not delete resources because they are 1) associated with a translation teams, 2) not empty.

tx delete --force --resource=kindle-touch-framework.\*

Change encoding of Framework resources

Replacing of PROPERTIES to MOZILLAPROPERTIES here is not strictly needed, because all content of .tx/config about kindle-touch-framework project will be replaced on some next step. But this relevant change of metadata is just a good thing IMHO.

java -jar tool/kt-10n.jar iso2utf -f -s src/5.0.0/framework/ -t src/5.0.0/framework/
sed -ie 's/^type = PROPERTIES/type = MOZILLAPROPERTIES/g' .tx/config
git commit -am "[framework-rc-migration] Change encoding of resources to UTF-8" 
git push

Delete existing source files

Those with names *_en_US.properties

find src/5.0.0/framework -name '*_en_US.properties' -exec git rm '{}' \;

Dont't commit yet!

Add resources extracted with kt10n.jar tool

cp -r /tmp/extracted/* src/5.0.0/framework
python tool/one-time/print_tx_config_snippet_for_framework_resources.py --src-dir=src --fw-version=5.0.0 --default-source-lang=en > /tmp/tx_config_snippet
Open .tx/config in text editor.
Delete all resources of project kindle-touch-framework.
Copy/paste snippet from /tmp/tx_config_snippet.

Then commit current state

git add src/5.0.0/framework/*
git commit -am "[framework-rc-migration] Replace old source files and add some new" 
git push

Push resources to Transifex

tx push --source --translations --resource=kindle-touch-framework.\*

Delete non-translated and semi-translated files from repository

rm -rf src/5.0.0/framework/*
tx pull --source --all --minimum=perc=100 --resource=kindle-touch-framework.\*

(also updated .tx/config to make en_US the source files)

and commit current state

git commit -am "[framework-rc-migration] Remove non- and semi-translated resources"
git push

Merge migration branch into master and delete obsolete migration branch

The --no-ff flag causes the merge to always create a new commit object, even if the merge could be performed with a fast-forward. This avoids losing information about the historical existence of a migration branch and groups together all commits that together formed the migration.

git checkout master
git merge --no-ff framework-rc-migration
git branch -d framework-rc-migration
git push origin master

Change name of Framework resource on Transifex.net to human-readable form

python tool/one-time/update_framework_resources_names_on_server.py --tx-config=.tx/config

Tool will request username and password of Transifex account (it's required for using of Transifex API). (For reasons beyond me, 3 resources consistently resulted in a 500 Error when trying to change them. I manually updated these.)

Congratulations!

Updated