在mac上设置了默认语言为英文,但是想把部分程序设置为中文,所以写了个脚本来批量设置。
_01_change_app_language.sh
#!/bin/bash
echo 'Start at ' $(date "+%Y-%m-%d %H:%M:%S")
APP_DIRS=(
/Applications/Microsoft Excel.app
/Applications/Microsoft Word.app
/Applications/Microsoft PowerPoint.app
/Applications/Microsoft Outlook.app
/Applications/Foxit Reader.app
)
for ((i=0;i<${#APP_DIRS[@]};i++))
do
APP_DIR="${APP_DIRS[$i]}"
echo $APP_DIR
NAME=`mdls -name kMDItemCFBundleIdentifier "$APP_DIR" | awk -F' = ' '{print $2}' | sed -e 's/^"//' -e 's/"$//'`
echo $NAME
defaults write $NAME AppleLanguages '("zh_CN")'
done
echo 'Finished!'
echo ''
定时任务每小时设置一次。
crontab -e
*/60 * * * * sh /xxxx/_01_change_app_language.sh >> /xxxx/_01_change_app_language.sh.log