modify lang path

This commit is contained in:
Ing 2024-03-06 04:31:04 +08:00
parent 0194be8871
commit 22e2f0bd93
15 changed files with 10 additions and 18 deletions

View File

@ -56,9 +56,10 @@ This project is a system for redpills preinstallation and recovery environmen
xgettext -L Shell --keyword=TEXT *.sh -o lang/rr.pot xgettext -L Shell --keyword=TEXT *.sh -o lang/rr.pot
sed -i 's/charset=CHARSET/charset=UTF-8/' lang/rr.pot sed -i 's/charset=CHARSET/charset=UTF-8/' lang/rr.pot
# You need to replace the language you need and translate the po file. # You need to replace the language you need and translate the po file.
msginit -i lang/rr.pot -l zh_CN.UTF-8 -o lang/zh_CN.po mkdir -p lang/zh_CN/LC_MESSAGES
msginit -i lang/rr.pot -l zh_CN.UTF-8 -o lang/zh_CN/LC_MESSAGES/rr.po
# This process will be automatically processed during packaging. # This process will be automatically processed during packaging.
msgfmt lang/zh_CN.po -o lang/zh_CN.mo msgfmt lang/zh_CN/LC_MESSAGES/rr.po -o lang/zh_CN/LC_MESSAGES/rr.mo
``` ```
* I am not proficient in language, and even my English is very poor. * I am not proficient in language, and even my English is very poor.
Developers who are familiar with various languages are welcome to submit PR. Developers who are familiar with various languages are welcome to submit PR.

View File

@ -1,19 +1,10 @@
[ -z "${WORK_PATH}" -o ! -d "${WORK_PATH}/include" ] && WORK_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/../" >/dev/null 2>&1 && pwd)" [ -z "${WORK_PATH}" -o ! -d "${WORK_PATH}/include" ] && WORK_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/../" >/dev/null 2>&1 && pwd)"
if [ -d "/usr/share/locale" ]; then if type gettext >/dev/null 2>&1; then
for F in $(ls ${WORK_PATH}/lang/*.mo 2>/dev/null); do if [ -d "${WORK_PATH}/lang" ]; then
LANG="$(basename "${F}" .mo)" export TEXTDOMAINDIR="${WORK_PATH}/lang"
LOCALE="${LANG%%_*}" fi
if [ -d "/usr/share/locale/${LANG}" ] || [ ! -d "/usr/share/locale/${LOCALE}" ]; then if [ -f "${PART1_PATH}/.locale" ]; then
mkdir -p "/usr/share/locale/${LANG}/LC_MESSAGES"
install "${F}" "/usr/share/locale/${LANG}/LC_MESSAGES/rr.mo"
else
mkdir -p "/usr/share/locale/${LOCALE}/LC_MESSAGES"
install "${F}" "/usr/share/locale/${LOCALE}/LC_MESSAGES/rr.mo"
fi
done
if [ -f ${PART1_PATH}/.locale ]; then
export LC_ALL="$(cat ${PART1_PATH}/.locale)" export LC_ALL="$(cat ${PART1_PATH}/.locale)"
fi fi

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2186,9 +2186,9 @@ function boot() {
function languageMenu() { function languageMenu() {
rm -f "${TMP_PATH}/menu" rm -f "${TMP_PATH}/menu"
while read L; do while read L; do
A="$(echo "$(strings "${WORK_PATH}/lang/${L}.mo" 2>/dev/null | grep "Last-Translator" | sed "s/Last-Translator://")")" A="$(echo "$(strings "${WORK_PATH}/lang/${L}/LC_MESSAGES/rr.mo" 2>/dev/null | grep "Last-Translator" | sed "s/Last-Translator://")")"
echo "${L} \"${A:-"anonymous"}\"" >>"${TMP_PATH}/menu" echo "${L} \"${A:-"anonymous"}\"" >>"${TMP_PATH}/menu"
done < <(ls ${WORK_PATH}/lang/*.mo 2>/dev/null | sort | sed -r 's/.*\/(.*)\.mo$/\1/') done < <(ls ${WORK_PATH}/lang/*/LC_MESSAGES/rr.mo 2>/dev/null | sort | sed -r 's/.*\/lang\/(.*)\/LC_MESSAGES\/rr\.mo$/\1/')
DIALOG \ DIALOG \
--default-item "${LAYOUT}" --menu "$(TEXT "Choose a language")" 0 0 0 --file "${TMP_PATH}/menu" \ --default-item "${LAYOUT}" --menu "$(TEXT "Choose a language")" 0 0 0 --file "${TMP_PATH}/menu" \