From 4d42cae19e9f823e8bcbf65801e077f2ff458a7b Mon Sep 17 00:00:00 2001 From: zhao Date: Mon, 14 Apr 2025 11:35:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=2005=5Fconvert=5Ftranslation?= =?UTF-8?q?.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhao --- 05_convert_translation.sh | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 05_convert_translation.sh diff --git a/05_convert_translation.sh b/05_convert_translation.sh new file mode 100644 index 0000000..f4fed70 --- /dev/null +++ b/05_convert_translation.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# [CTCGFW]immortalwrt +# Use it under GPLv3, please. +# -------------------------------------------------------- +# Convert translation files zh-cn to zh_Hans +# The script is still in testing, welcome to report bugs. + +po_file="$({ find -type f | grep -E "[a-z0-9]+\.zh\-cn.+po"; } 2>"/dev/null")" +for a in ${po_file}; do + [ -n "$(grep "Language: zh_CN" "$a")" ] && sed -i "s/Language: zh_CN/Language: zh_Hans/g" "$a" + po_new_file="$(echo -e "$a" | sed "s/zh-cn/zh_Hans/g")" + mv "$a" "${po_new_file}" 2>"/dev/null" +done + +po_file2="$({ find -type f | grep "/zh-cn/" | grep "\.po"; } 2>"/dev/null")" +for b in ${po_file2}; do + [ -n "$(grep "Language: zh_CN" "$b")" ] && sed -i "s/Language: zh_CN/Language: zh_Hans/g" "$b" + po_new_file2="$(echo -e "$b" | sed "s/zh-cn/zh_Hans/g")" + mv "$b" "${po_new_file2}" 2>"/dev/null" +done + +lmo_file="$({ find -type f | grep -E "[a-z0-9]+\.zh_Hans.+lmo"; } 2>"/dev/null")" +for c in ${lmo_file}; do + lmo_new_file="$(echo -e "$c" | sed "s/zh_Hans/zh-cn/g")" + mv "$c" "${lmo_new_file}" 2>"/dev/null" +done + +lmo_file2="$({ find -type f | grep "/zh_Hans/" | grep "\.lmo"; } 2>"/dev/null")" +for d in ${lmo_file2}; do + lmo_new_file2="$(echo -e "$d" | sed "s/zh_Hans/zh-cn/g")" + mv "$d" "${lmo_new_file2}" 2>"/dev/null" +done + +po_dir="$({ find -type d | grep "/zh-cn" | sed "/\.po/d" | sed "/\.lmo/d"; } 2>"/dev/null")" +for e in ${po_dir}; do + po_new_dir="$(echo -e "$e" | sed "s/zh-cn/zh_Hans/g")" + mv "$e" "${po_new_dir}" 2>"/dev/null" +done + +makefile_file="$({ find -type f | grep Makefile | sed "/Makefile./d"; } 2>"/dev/null")" +for f in ${makefile_file}; do + [ -n "$(grep "zh-cn" "$f")" ] && sed -i "s/zh-cn/zh_Hans/g" "$f" + [ -n "$(grep "zh_Hans.lmo" "$f")" ] && sed -i "s/zh_Hans.lmo/zh-cn.lmo/g" "$f" +done + +makefile_file="$({ find package -type f | grep Makefile | sed "/Makefile./d"; } 2>"/dev/null")" +for g in ${makefile_file}; do + [ -n "$(grep "golang-package.mk" "$g")" ] && sed -i "s|\.\./\.\.|$\(TOPDIR\)/feeds/packages|g" "$g" + [ -n "$(grep "luci.mk" "$g")" ] && sed -i "s|\.\./\.\.|$\(TOPDIR\)/feeds/luci|g" "$g" +done + +exit 0 \ No newline at end of file