translation: Handle renaming of Chinese locales in Django
Horizon is switching Chinese locales from zh-cn/zh-tw to zh-hans/zh-hant in horizon and horizon plugins. This change follows Django change which happend more than five years ago and the new language code form is commonly used. Language codes in Zanata are not changed, so we need to covert the relevant language codes in propose_translation_update.sh. It allows us to avoid doing it manually and also allows us to switch these language codes almost once across horizon and plugins. The detail is explained in the mailing list post. http://lists.openstack.org/pipermail/openstack-discuss/2021-February/020169.html Change-Id: I1420508f0513c52866aa637784a51f7c22f6d204
This commit is contained in:
parent
8a6fe25654
commit
b515ef9819
@ -614,6 +614,11 @@ function filter_commits {
|
||||
REAL_CHANGE=1
|
||||
fi
|
||||
done
|
||||
# If renamed files exist, we need to commit the change.
|
||||
# This happens only when locales are changed.
|
||||
for f in $(git diff --cached --name-only --diff-filter=R); do
|
||||
REAL_CHANGE=1
|
||||
done
|
||||
|
||||
# If no file has any real change, revert all changes.
|
||||
if [ $REAL_CHANGE -eq 0 ] ; then
|
||||
|
@ -169,6 +169,7 @@ function handle_python_django_project {
|
||||
|
||||
setup_project "$project" "$ZANATA_VERSION"
|
||||
pull_from_zanata "$project"
|
||||
rename_django_chinese_locales "$project" "$BRANCH"
|
||||
handle_python_django $project python
|
||||
handle_python_django $project django
|
||||
handle_project_doc $project
|
||||
@ -190,6 +191,44 @@ function handle_project_doc {
|
||||
git_add_po_files doc/source/locale
|
||||
}
|
||||
|
||||
# Rename existing Chinese locales in the project repository
|
||||
# (zh_CN -> zh_Hans, zh_TW -> zh_Hant)
|
||||
# NOTE: This is expected to call after pulling translations from zanata.
|
||||
function rename_django_chinese_locales {
|
||||
local project=$1
|
||||
local branch=$2
|
||||
local module_name module_names
|
||||
local old_locale new_locale
|
||||
|
||||
# Renaming Chinese locales is unnecessary for Victoria or earlier.
|
||||
# TODO(amotoki): Once all stable branches support the new Chinese locales
|
||||
# in horizon and its plugins, this branch check can be dropped.
|
||||
case "$branch" in
|
||||
stable/ussuri|stable/victoria) return ;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
declare -A locale_rename_map=(
|
||||
["zh_CN"]="zh_Hans"
|
||||
["zh_TW"]="zh_Hant"
|
||||
)
|
||||
|
||||
module_names=$(get_modulename $project django)
|
||||
for module_name in $module_names; do
|
||||
for old_locale in "${!locale_rename_map[@]}"; do
|
||||
new_locale=${locale_rename_map[$old_locale]}
|
||||
rm -rf $module_name/locale/$new_locale
|
||||
if [ -d $module_name/locale/$old_locale ]; then
|
||||
mv $module_name/locale/$old_locale $module_name/locale/$new_locale
|
||||
fi
|
||||
if git ls-files | grep -q $module_name/locale/$old_locale; then
|
||||
git rm -r $module_name/locale/$old_locale
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# Handle either python or django proposals
|
||||
function handle_python_django {
|
||||
local project=$1
|
||||
|
Loading…
Reference in New Issue
Block a user