Sometimes incorrect language code has been made available for translation which should be changed to a new one due to new knowledge. This page contains tips and instructions how to do such moves to ensure smooth transitions. This page assumes we are renaming
Prepare the target software
The target software should be able to redirect old language codes to new ones. In case of MediaWiki, there is
languages/messages/MessagesSrc.php must have
$fallback = 'tgt'; and
languages/messages/MessagesTgt.php should have
$fallback = 'src';. Also all languages having
src in their fallback chain should be updated to include
tgt as well. These can be removed once move is over.
Prevent concurrent translation updates
To avoid unexpected processing of translation updates during move, run the following command when using
bash shell to take an exclusive translation synchronization lock. Don't forget the dot at the beginning, otherwise the lock will not be held.
This lock will be held for duration of the session, e.g. until you exit
screen where you used it, or log out from the ssh session if you took the lock outside of it.
Perform rename on repos
For each project, using mediawiki as an example.
l10n-bot repomulti update mediawiki
php /srv/mediawiki/targets/production/extensions/Translate/scripts/export-rename-language.php --group=core --target=. --source-language src --target-language tgt # Check matches
repomulti status mediawiki
repomulti commit mediawiki
Perform rename on wiki
cd /srv/mediawiki/targets/productions/extensions/ReplaceText/maintenance # Get list of namespaces: php replaceAll.php --listns # Preview php replaceAll.php --dry-run --ns 8,9,1206,1207 --regex --rename '/src$' '/tgt' # Do it, 646 is FuzzyBot php replaceAll.php --ns 8,9,1206,1207 --regex --rename --user 646 --yes --summary="Your summary here" '/src$' '/tgt'
This will take a while.
Release translation synchronization lock
The lock will prevent all translation exports and imports, so it is important to release it after you have completed by closing any screens and logging out of the ssh session.
Verify and cleanup
After this and repo updates are finished and merged, you can run
autoimport-mediawiki – there shouldn't be any changes but something might have got out of sync over time that shows up now.
Finally the caches may need to be purged if didn't happen automatically:
# Review find /resources/caches/translatewiki.net -name "src.cdb" # Just Do It find /resources/caches/translatewiki.net -name "src.cdb" -delete
You want to restrict this to only relevant groups in case the language code is also used in other projects where it was not renamed by changing the path to
/resources/caches/translatewiki.net/translate_groupcache-message group id