Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multi-language support #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ on_install() {
unzip -o "$ZIPFILE" -d $TMPDIR >&2
cd $TMPDIR
mv -f mm /data/media/0/
mv language $MODPATH/language
mv License* README* $MODPATH/

set +euxo pipefail
Expand Down
21 changes: 21 additions & 0 deletions language/Chinese
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/sbin/sh
string_info='[信息]'
string_warn='[警告]'
string_used_in_recovery_only='模块只能在Recovery中使用!'
string_no_magisk='未安装Magisk或不支持已安装的版本。'
string_list_installed_modules='列出已安装的模块'
string_toggle='切换'
string_core_only_mode='核心加载模式'
string_magic_mount='魔法挂载'
string_disable='禁用模块'
string_remove='卸载模块'
string_quit='退出'
string_installed_modules='已安装的模块'
string_press_enter='请按 <enter> 键继续或者退出……'
string_goodbye='感谢使用!'
string_input_pattern='请输入模块名称 (例如., .表示所有模块, acc, or fbind|xpo|viper): '
string_toggle_magic_mount='切换魔法挂载状态'
string_toggle_on_off='切换模块启用状态'
string_mark_for_removal='标记为移除'
string_core_only_mode_off='核心加载模式已禁用'
string_core_only_mode_on='核心加载模式已启用'
24 changes: 24 additions & 0 deletions language/Origin
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/sbin/sh
string_info='(i)'
string_warn='(!)'
string_info_mm='Magisk Manager for Recovery Mode (mm) 2019.4.4'
string_info_copyright='Copyright (C) 2017-2019, VR25 @ xda-developers'
string_info_license='License: GPLv3+'
string_used_in_recovery_only='This is meant to be used in recovery environment only!'
string_no_magisk='No Magisk installation found or installed version is not supported.'
string_list_installed_modules='List installed modules'
string_toggle='Toggle'
string_core_only_mode='Core only mode'
string_magic_mount='Magic mount'
string_disable='Disable'
string_remove='Remove'
string_quit='Quit'
string_installed_modules='Installed Modules'
string_press_enter='Press <enter> to continue or \"q <enter>\" to quit... '
string_goodbye='Goodbye.'
string_input_pattern='Input pattern(s) (e.g., a dot for all, acc, or fbind|xpo|viper): '
string_toggle_magic_mount='Toggle Magic Mount'
string_toggle_on_off='Toggle ON/OFF'
string_mark_for_removal='Mark for Removal'
string_core_only_mode_off='Core only mode [OFF]'
string_core_only_mode_on='Core only mode [ON]'
58 changes: 37 additions & 21 deletions mm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
# Copyright (C) 2017-2019, VR25 @ xda-developers
# License: GPLv3+

languagePath=/data/adb/modules/mm
echo -n "
##########################
0) English
1) 简体中文
##########################
"
read language_opt

echo
source "$languagePath/language/Origin"
case $language_opt in
1)
source "$languagePath/language/Chinese"
;;
esac

main() {

Expand All @@ -13,14 +29,14 @@ mountPath=/_magisk
img=/data/adb/magisk.img
[ -f $img ] || img=/data/adb/modules

echo -e "\nMagisk Manager for Recovery Mode (mm) 2019.4.4
Copyright (C) 2017-2019, VR25 @ xda-developers
License: GPLv3+\n"
echo -e "\n$string_info_mm
$string_info_copyright
$string_info_license\n"

trap 'exxit $?' EXIT

if is_mounted /storage/emulated; then
echo -e "(!) This is meant to be used in recovery environment only!\n"
echo -e "$string_warn $string_used_in_recovery_only\n"
exit 1
fi

Expand All @@ -31,7 +47,7 @@ mount /data 2>/dev/null || :
mount /cache 2>/dev/null || :

if [ ! -d /data/adb/magisk ]; then
echo -e "(!) No Magisk installation found or installed version is not supported.\n"
echo -e "$string_warn $string_no_magisk\n"
exit 1
fi

Expand All @@ -52,15 +68,15 @@ options() {

while :; do
echo -n "##########################
l) List installed modules
l) $string_list_installed_modules
##########################
Toggle
c) Core only mode
m) Magic mount
d) Disable
r) Remove
$string_toggle
c) $string_core_only_mode
m) $string_magic_mount
d) $string_disable
r) $string_remove
##########################
q) Quit
q) $string_quit
##########################

?) "
Expand All @@ -70,15 +86,15 @@ q) Quit
case $opt in
m) toggle_mnt;;
d) toggle_disable;;
l) echo -e "Installed Modules\n"; ls_mods;;
l) echo -e "$string_installed_modules\n"; ls_mods;;
r) toggle_remove;;
q) exit 0;;
c) toggle_com;;
esac
break
done

echo -en "\n(i) Press <enter> to continue or \"q <enter>\" to quit... "
echo -en "\n$string_info $string_press_enter"
read opt
[ -z "$opt" ] || exit 0
echo
Expand All @@ -98,7 +114,7 @@ exxit() {
rmdir $mountPath
mount -o remount,ro /
rm -rf $tmpDir
[ ${1:-0} -eq 0 ] && { echo -e "\nGoodbye.\n"; exit 0; } || exit $1
[ ${1:-0} -eq 0 ] && { echo -e "\n$string_goodbye\n"; exit 0; } || exit $1
} 2>/dev/null


Expand All @@ -110,7 +126,7 @@ toggle() {
[ -f $mountPath/$mod/$file ] && echo "$present]" || echo "$absent]"
done

echo -en "\nInput pattern(s) (e.g., a dot for all, acc, or fbind|xpo|viper): "
echo -en "\n$string_input_pattern"
read input
echo

Expand All @@ -124,31 +140,31 @@ toggle() {


toggle_mnt() {
echo -e "Toggle Magic Mount\n"
echo -e "$string_toggle_magic_mount\n"
[ -f $img ] && { toggle auto_mount ON OFF || :; } \
|| toggle skip_mount OFF ON
}


toggle_disable() {
echo -e "Toggle ON/OFF\n"
echo -e "$string_toggle_on_off\n"
toggle disable OFF ON
}


toggle_remove() {
echo -e "Mark for Removal ([X])\n"
echo -e "$string_mark_for_removal ([X])\n"
toggle remove X " "
}


toggle_com() {
if [ -f /cache/.disable_magisk ] || [ -f /data/cache/.disable_magisk ]; then
rm /data/cache/.disable_magisk /cache/.disable_magisk 2>/dev/null || :
echo "(i) Core only mode [OFF]"
echo "$string_info $string_core_only_mode_off"
else
touch /data/cache/.disable_magisk /cache/.disable_magisk 2>/dev/null || :
echo "(i) Core only mode [ON]"
echo "$string_info $string_core_only_mode_on"
fi
}

Expand Down