[Alfresco] 簡轉繁批次檔內容

No Comments

檔名: cn2tw-bat.sh

#/bin/bash

# check i18n files
files=`sudo find ./ -name *zh_CN.properties`
for file in $files;
do
    sudo  cn2tw.sh $file;
done

# check js files
jsfiles=`sudo find ./ -name *zh_CN.js`
for file in $jsfiles;
do
    sudo  cn2tw.sh $file;
done

# modify files with bad translation
sudo /usr/bin/cn2tw-lang.sh

# check files needs to be modified
echo "-------------------------------------------"
echo "如有檔案被列出, 請修改裡面的 zh_CN 為 zh_TW"
grep zh_CN  `find ./ -name *zh_TW*`
cd /opt/alfresco-community
pwd
sed -i 's/zh_CN/zh_TW/g' ./tomcat/webapps/share/modules/editors/tinymce/langs/zh_TW.js



# restart Alfresco
#echo ""
#echo "------------------------------------------"
echo "Remember to restart Alfresco services"
#service alfresco restart

————————————————————
檔名:cn2tw.sh

#!/bin/bash

#echo "############## 處理編碼 ############"
echo "正在處理 $1"
#echo "已把 $1 轉換為 UTF-8 格式"
native2ascii -reverse "$1" "$1_utf8_cn"

#echo "轉換 $1.utf8_cn 為正體中文,並刪除 $1.utf8_cn "
cconv -f UTF8-CN -t UTF8-TW "$1_utf8_cn" -o "$1_utf8_tw"
rm "$1_utf8_cn"

#echo "轉換 $1.utf8_tw 為unicode, 並刪除 $1.utf8_tw"
native2ascii "$1_utf8_tw" "$1_uni_tw"
rm "$1_utf8_tw"


#echo "############# 處理檔名 ###########"
#echo "更改 $1_uni_tw 的檔名為 zh_TW, 並檢視檔名 "
rename -f  's/zh_CN/zh_TW/' "$1_uni_tw" > filename.txt
uni_tw_filename=`awk '{printf $4}' filename.txt`
echo "$uni_tw_filename"
#rm filename.txt

#echo "修改檔名為 zh_TW, 且無 _uni_tw "
chmod 644 $uni_tw_filename
#chmod 644 $1_uni_tw
echo "$uni_tw_filename"
rename -f 's/_uni_tw//' $uni_tw_filename
#echo "$uni_tw_filename done"
echo "$1 done"

Leave a Reply

Share via
Copy link