diff --git a/README.md b/README.md index ad7c1c0ce..04b0d4cd5 100644 --- a/README.md +++ b/README.md @@ -403,9 +403,9 @@ Each `--oem-script` is a bash script the install runs once, as root, in the new The configurator asks for a language first, on the screen that carries the intro and the hidden Ctrl+C entry into preparing the machine for another owner. It offers every language in Omarchy's registry (`default/i18n/locales.json` in the settings package). A language with a catalog in `configs/airootfs/usr/share/omarchy-iso/i18n/` also translates the installer. The others are listed by their English name, the installer stays in English, and the language still goes to the installed system as `/etc/omarchy/language`. The keyboard list then preselects the language's layout from `language-defaults.json`. The timezone list preselects the network's guess, and when that fails, the capital of the language's country from the same file. English, Arabic, Swahili and Tamil have no single home country, so they fall back to the plain timezone search. -Catalogs exist only for languages the live console can draw. The kernel's own console fonts carry just the IBM PC character set, so the installer loads Terminus, patched by `console-font.py` with the half blocks the logo is drawn with. That covers Latin, Greek and Cyrillic. CJK, Arabic, Hebrew, the Indic scripts, Thai and Vietnamese are beyond any 512-glyph console font. +The kernel's own console fonts carry just the IBM PC character set, so the installer loads Terminus, patched by `console-font.py` with the half blocks the logo is drawn with. That covers Latin, Greek and Cyrillic, and those languages run on the plain console. Chinese, Japanese and Korean move the installer into kmscon (`omarchy-iso-kmscon`), which draws the same gum screens with fontconfig and the bundled Noto Sans Mono CJK. The configurator saves the answers so far and exits 75; `.automated_script.sh` starts kmscon on tty1 and runs itself again inside it, from the step after the language, and the rest of the install, the dashboard included, stays there. kmscon reads keys through XKB rather than the console keymap, so it is relaunched with the layout picked on the keyboard screen. Simplified Chinese, Japanese and Korean switch after the language screen, and kmscon draws Han characters in the picked language's forms from the same font collection. When kmscon cannot start, the answers resume on the console in English. zh-CN, ja and ko have catalogs so far, and only x86_64 ships kmscon; elsewhere these languages stay in English. Arabic, Hebrew, the Indic scripts, Thai and Vietnamese are beyond both and stay in English. -To add a string, put it in `en.json` and print it with `t [args]`, where `%1`, `%2` take the arguments. A catalog that lacks the key shows it in English until a translation lands. `test/unit/test_installer_i18n.py` fails on a key English does not have, on placeholders that differ from English, and on a character the patched font cannot draw. The setup form vendored from Omarchy translates its own strings from Omarchy's catalogs, in the language the configurator names in `OMARCHY_FORM_LANGUAGE`, and takes the keyboard default and the offline timezone through `OMARCHY_FORM_KEYBOARD_DEFAULT` and `OMARCHY_FORM_TIMEZONE_FALLBACK`. +To add a string, put it in `en.json` and print it with `t [args]`, where `%1`, `%2` take the arguments. A catalog that lacks the key shows it in English until a translation lands. `test/unit/test_installer_i18n.py` fails on a key English does not have, on placeholders that differ from English, and, outside the kmscon languages, on a character the patched font cannot draw. The setup form vendored from Omarchy translates its own strings from Omarchy's catalogs, in the language the configurator names in `OMARCHY_FORM_LANGUAGE`, and takes the keyboard default and the offline timezone through `OMARCHY_FORM_KEYBOARD_DEFAULT` and `OMARCHY_FORM_TIMEZONE_FALLBACK`. ## Creating the ISO diff --git a/builder/build-iso.sh b/builder/build-iso.sh index 46e1f76f3..38f3040e7 100755 --- a/builder/build-iso.sh +++ b/builder/build-iso.sh @@ -392,8 +392,12 @@ if [[ $OMARCHY_ARCH == aarch64 ]]; then # saves a laptop's signed firmware from Windows with qcom-firmware-extract. arch_packages=("$OMARCHY_KERNEL" archlinuxarm-keyring git gum jq openssl openssh pciutils plymouth ttfx terminus-font tzupdate omarchy-keyring "$OMARCHY_SETTINGS_PACKAGE" lvm2 cryptsetup parted systemd-ukify systemd-stub-omarchy linux-firmware-qcom qcom-firmware-extract python) else - # linux-t2 is the live kernel on a Mac (configs/grub/grub.cfg). - arch_packages=("$OMARCHY_KERNEL" linux-t2 git gum jq openssl plymouth ttfx terminus-font tzupdate omarchy-keyring "$OMARCHY_SETTINGS_PACKAGE" lvm2 cryptsetup parted) + # linux-t2 is the live kernel on a Mac (configs/grub/grub.cfg). kmscon and + # the CJK font carry the installer in the languages the Linux console cannot + # draw (usr/local/bin/omarchy-iso-kmscon); customize_airootfs.sh trims the + # font to the one face kmscon uses. aarch64 goes without until Arch Linux ARM + # builds kmscon, and stays in English for those languages. + arch_packages=("$OMARCHY_KERNEL" linux-t2 git gum jq openssl plymouth ttfx terminus-font tzupdate omarchy-keyring "$OMARCHY_SETTINGS_PACKAGE" lvm2 cryptsetup parted kmscon noto-fonts-cjk) fi live_packages_file="$build_cache_dir/packages.$OMARCHY_ARCH" printf '%s\n' "${arch_packages[@]}" >> "$live_packages_file" diff --git a/configs/airootfs/etc/fonts/conf.d/60-omarchy-iso-cjk.conf b/configs/airootfs/etc/fonts/conf.d/60-omarchy-iso-cjk.conf new file mode 100644 index 000000000..3a485ec55 --- /dev/null +++ b/configs/airootfs/etc/fonts/conf.d/60-omarchy-iso-cjk.conf @@ -0,0 +1,13 @@ + + + + + + monospace + + Adwaita Mono + Noto Sans Mono CJK SC + + + diff --git a/configs/airootfs/root/.automated_script.sh b/configs/airootfs/root/.automated_script.sh index a4301c541..fde5a258b 100644 --- a/configs/airootfs/root/.automated_script.sh +++ b/configs/airootfs/root/.automated_script.sh @@ -10,7 +10,9 @@ # - COLUMNS/LINES so gum picks up real terminal size set -euo pipefail -[[ $(tty) == /dev/tty1 ]] || exit 0 +# Inside kmscon (omarchy-iso-kmscon) this runs again on kmscon's pty, as the +# continuation of the tty1 installer in a language the console cannot draw. +[[ $(tty) == /dev/tty1 || ${OMARCHY_ISO_KMSCON:-} == 1 ]] || exit 0 # The N1x recovery boot entry is a diagnostic shell, never the installer: record # the hardware probe, show how to reach the machine, and leave tty1 at a prompt. @@ -50,7 +52,7 @@ set_tokyo_night_colors() { echo -en "\033[0m" clear } -set_tokyo_night_colors +[[ ${OMARCHY_ISO_KMSCON:-} == 1 ]] || set_tokyo_night_colors mkdir -p /var/log touch "$OMARCHY_INSTALL_LOG_FILE" @@ -126,9 +128,12 @@ warm_offline_mirror() { done < <(du -k "$mirror"/*.pkg.tar.zst 2>/dev/null | sort -rn) } -warm_offline_mirror & -warm_pid=$! -trap 'kill "$warm_pid" 2>/dev/null' EXIT +# Inside kmscon the tty1 run is still warming the cache. +if [[ ${OMARCHY_ISO_KMSCON:-} != 1 ]]; then + warm_offline_mirror & + warm_pid=$! + trap 'kill "$warm_pid" 2>/dev/null' EXIT +fi cd /root # Autoinstall: a cidata drive carrying the configurator's own output files @@ -137,11 +142,34 @@ cd /root if [[ -f /usr/share/omarchy-iso/oem-install ]]; then export OMARCHY_UI_INTERACTIVE=no ./configurator --oem +elif [[ ${OMARCHY_ISO_KMSCON:-} == 1 ]]; then + # The tty1 run already looked for cidata. + ./configurator && status=0 || status=$? + # A retry from the shell left after an abort: that shell, not the kmscon + # wrapper, gets the relaunch request, so end it to end kmscon. + if ((status == 75)) && [[ -n ${OMARCHY_ISO_KMSCON_SHELL:-} ]]; then + kill -HUP "$OMARCHY_ISO_KMSCON_SHELL" 2>/dev/null || true + fi + ((status == 0)) || exit "$status" elif /usr/local/bin/omarchy-cidata-load; then echo "Autoinstall configuration found on cidata drive; skipping the configurator." export OMARCHY_UI_INTERACTIVE=no else - ./configurator + ./configurator && status=0 || status=$? + # 75: the configurator saved its answers and wants kmscon (a CJK language). + # kmscon runs this script again and the whole rest of the install in there; + # it is relaunched when the layout changes. If the configurator in kmscon + # never picked the answers up, the answers resume here in English. + while ((status == 75)); do + rm -f /run/omarchy-iso/kmscon-started + omarchy-iso-kmscon /root/.automated_script.sh || true + if [[ ! -e /run/omarchy-iso/kmscon-resume ]]; then + exit 0 + elif [[ ! -e /run/omarchy-iso/kmscon-started ]]; then + OMARCHY_ISO_NO_KMSCON=1 ./configurator && status=0 || status=$? + fi + done + ((status == 0)) || exit "$status" fi # Deferred-provisioning installs skip the celebration/reboot prompt and reboot on diff --git a/configs/airootfs/root/configurator b/configs/airootfs/root/configurator index a92265388..48180dc4e 100644 --- a/configs/airootfs/root/configurator +++ b/configs/airootfs/root/configurator @@ -233,7 +233,10 @@ language_default() { } set_form_language() { + # The form's text comes from Omarchy's catalogs, which have every language; + # on a console that cannot draw this one it stays English like the rest. OMARCHY_FORM_LANGUAGE=$language + i18n_translated "$language" || OMARCHY_FORM_LANGUAGE=en OMARCHY_FORM_KEYBOARD_DEFAULT=$(language_default keyboard) OMARCHY_FORM_KEYBOARD_DEFAULT=${OMARCHY_FORM_KEYBOARD_DEFAULT:-English (US)} OMARCHY_FORM_TIMEZONE_FALLBACK=$(language_default timezone) @@ -249,8 +252,12 @@ language_label() { # "labelcode" rows, English first and the rest alphabetical by what is shown. language_rows() { - local translated - translated=$(cd "$OMARCHY_ISO_I18N_DIR" && printf '%s\n' *.json | sed 's/\.json$//' | jq -R . | jq -sc .) + local translated code + # Native names only for catalogs this console can draw: a CJK name would be + # boxes here, so Chinese is listed by its English name until kmscon takes over. + translated=$(for code in $(cd "$OMARCHY_ISO_I18N_DIR" && printf '%s\n' *.json | sed 's/\.json$//'); do + i18n_translated "$code" && printf '%s\n' "$code" + done | jq -R . | jq -sc .) jq -r --argjson translated "$translated" ' to_entries | map({code: .key, label: (if (.key | IN($translated[])) then .value.name else .value.englishName end)}) @@ -310,6 +317,7 @@ keyboard_form() { if ((status == OMARCHY_FORM_BACK)); then language_form $defer_provisioning && return 0 + kmscon_for_language continue fi @@ -322,6 +330,50 @@ keyboard_form() { if [[ $(tty 2>/dev/null) == "/dev/tty"* ]]; then loadkeys "$keyboard" 2>/dev/null fi + + # kmscon reads keys through XKB and picks its font once, at its start: + # relaunch it with the layout just picked so the password is typed under the + # layout it will be entered with at boot, and with the Han forms of a + # language picked again on the way back (Chinese, then Japanese). + if [[ ${OMARCHY_ISO_KMSCON:-} == 1 ]] && + [[ $(omarchy-iso-kmscon --xkb "$keyboard") != "${OMARCHY_ISO_KMSCON_XKB:-}" || + $(omarchy-iso-kmscon --face "$language") != "${OMARCHY_ISO_KMSCON_FACE:-}" ]]; then + switch_to_kmscon user + fi +} + +# ── kmscon handoff ────────────────────────────────────────────────────────── +# +# The configurator cannot move its own terminal, so a switch saves the answers +# so far and exits 75; .automated_script.sh starts kmscon, which runs the +# installer again from the saved stage. If kmscon cannot start, the same +# answers resume on this console in English. + +KMSCON_RESUME=${KMSCON_RESUME:-/run/omarchy-iso/kmscon-resume} +KMSCON_SWITCH=75 + +kmscon_available() { + [[ ${OMARCHY_ISO_NO_KMSCON:-} != 1 && ${OMARCHY_ISO_KMSCON:-} != 1 ]] && + [[ $(tty 2>/dev/null) == /dev/tty[0-9]* ]] && command -v kmscon >/dev/null +} + +switch_to_kmscon() { + local resume_stage=$1 + mkdir -p "$(dirname "$KMSCON_RESUME")" + ( + umask 077 + declare -p resume_stage language keyboard keyboard_label keyboard_input_method \ + keyboard_xkb_layout defer_provisioning timezone username password password_hash hostname \ + 2>/dev/null >"$KMSCON_RESUME" + ) + exit $KMSCON_SWITCH +} + +# A language the console cannot draw: carry on in kmscon from the keyboard step. +kmscon_for_language() { + if i18n_needs_kmscon "$language" && kmscon_available; then + switch_to_kmscon keyboard + fi } # Ctrl+C on the first screen offers to prepare the machine for another owner. @@ -883,11 +935,11 @@ run_partition_execute() { # may assume it. It sets created_partition_number rather than printing so # the rollback bookkeeping survives (a $(...) would subshell it away). create_partition "$disk" "$EFI_START_B" "$EFI_END_B" fat32 OMARCHY_EFI || - disk_abort_hook "Could not create the EFI partition on $disk" + disk_abort_hook "$(t partitions.efiFailed "$disk")" efi_part_num="$created_partition_number" create_partition "$disk" "$ROOT_START_B" "$ROOT_END_B" btrfs OMARCHY_ROOT || - disk_abort_hook "Could not create the root partition on $disk" + disk_abort_hook "$(t partitions.rootFailed "$disk")" root_part_num="$created_partition_number" disk_step "flagging partition $efi_part_num as ESP" \ @@ -902,9 +954,9 @@ run_partition_execute() { sync sleep 2 - wait_for_device "$efi_dev" || disk_abort_hook "EFI partition $efi_dev never appeared" + wait_for_device "$efi_dev" || disk_abort_hook "$(t partitions.efiMissing "$efi_dev")" wait_for_device "$root_partition_device" || - disk_abort_hook "Root partition $root_partition_device never appeared" + disk_abort_hook "$(t partitions.rootMissing "$root_partition_device")" # Both partitions are ours and brand new, but the space they occupy may # carry signatures from whatever was deleted to free it. @@ -940,7 +992,7 @@ run_partition_execute() { # full-disk path does the same through archinstall (archinstall_adapter). disk_step "creating the Btrfs filesystem on $root_mapper" \ mkfs.btrfs -K -f -L OMARCHY "$root_mapper" - wait_for_device "$root_mapper" || disk_abort_hook "Root device $root_mapper never appeared" + wait_for_device "$root_mapper" || disk_abort_hook "$(t partitions.deviceMissing "$root_mapper")" mkdir -p /mnt/btrfs-root disk_step "mounting $root_mapper" mount "$root_mapper" /mnt/btrfs-root @@ -969,9 +1021,9 @@ run_partition_execute() { # a failure names the step that broke rather than surfacing later as # "protected mode: /mnt is not a mountpoint". mountpoint -q /mnt || - disk_abort_hook "Target /mnt is not mounted; not starting the installer" + disk_abort_hook "$(t partitions.targetUnmounted)" mountpoint -q "/mnt$esp_mount_in_target" || - disk_abort_hook "ESP is not mounted at /mnt$esp_mount_in_target" + disk_abort_hook "$(t partitions.espUnmounted "/mnt$esp_mount_in_target")" fi local luks_uuid_json="null" luks_uuid @@ -1254,17 +1306,41 @@ if [[ ${1:-} == "--oem" ]]; then defer_provisioning=true fi -# Let the live VT reach its settled width before the first screen so the logo -# isn't measured against the transient 80-column boot console. -wait_for_stable_terminal -i18n_console_font "$(tty 2>/dev/null)" +# Inside kmscon, carry on from where the console run handed over. +resume_stage="" +if [[ -r $KMSCON_RESUME ]]; then + # shellcheck disable=SC1090 + source "$KMSCON_RESUME" + rm -f "$KMSCON_RESUME" + # Tells .automated_script.sh that kmscon got this far; a resume file left + # without it means kmscon failed, and the answers carry on in English. + touch "$(dirname "$KMSCON_RESUME")/kmscon-started" + # Back on the console after kmscon failed: the layout picked in kmscon was + # never loaded here, and the password ahead must be typed under it. + if [[ ${OMARCHY_ISO_KMSCON:-} != 1 && -n ${keyboard:-} && $(tty 2>/dev/null) == "/dev/tty"* ]]; then + loadkeys "$keyboard" 2>/dev/null + fi + i18n_load "$language" + set_form_language +fi + +if [[ -z $resume_stage ]]; then + # Let the live VT reach its settled width before the first screen so the logo + # isn't measured against the transient 80-column boot console. + wait_for_stable_terminal + i18n_console_font "$(tty 2>/dev/null)" -if ! $oem_install; then - greeter - language_form + if ! $oem_install; then + greeter + language_form + fi + + $defer_provisioning || kmscon_for_language fi -$defer_provisioning || keyboard_form +if [[ -z $resume_stage || $resume_stage == keyboard ]]; then + $defer_provisioning || keyboard_form +fi # Normal install: keyboard (loaded above, so the LUKS passphrase is typed under # the right layout) → user → disk → install mode. The user step can unwind to @@ -1327,7 +1403,7 @@ if [[ $install_target == "free_space" ]]; then # terminal while the hash is still running, so a wait on a slow medium # shows movement instead of a frozen step header.) if [[ ${1:-} != "dry" ]]; then - step "Verifying the install medium" + step "$(t verify.title)" if ! verify_error=$(OMARCHY_VERIFY_PROGRESS=/dev/tty OMARCHY_VERIFY_PROGRESS_INDENT="$PADDING_LEFT" \ omarchy-wait-root-image-verify 2>&1 1>/dev/null); then abort "$(head -1 <<<"$verify_error")" diff --git a/configs/airootfs/root/customize_airootfs.sh b/configs/airootfs/root/customize_airootfs.sh index 083720ece..229fd59b4 100755 --- a/configs/airootfs/root/customize_airootfs.sh +++ b/configs/airootfs/root/customize_airootfs.sh @@ -66,6 +66,14 @@ fi rm -rf /usr/share/doc /usr/share/man /usr/share/info /usr/share/gtk-doc /usr/share/gir-1.0 /usr/include find /usr/share/locale -mindepth 1 -maxdepth 1 ! -name 'en*' ! -name locale.alias -exec rm -rf {} + +# kmscon draws the CJK installer with one face: Noto Sans Mono CJK, which lives +# in the Regular collection. The other weights and the serif set are ~280 MB of +# live root nobody sees. +if [[ -d /usr/share/fonts/noto-cjk ]]; then + find /usr/share/fonts/noto-cjk -type f ! -name NotoSansCJK-Regular.ttc -delete + fc-cache -f >/dev/null 2>&1 || true +fi + mirror=/var/cache/omarchy/mirror/offline shipped_list=/usr/share/omarchy-iso/offline-mirror.shipped diff --git a/configs/airootfs/usr/local/bin/omarchy-install-dashboard b/configs/airootfs/usr/local/bin/omarchy-install-dashboard index c9f9e0e7f..074765241 100755 --- a/configs/airootfs/usr/local/bin/omarchy-install-dashboard +++ b/configs/airootfs/usr/local/bin/omarchy-install-dashboard @@ -252,7 +252,7 @@ left_padding() { visible_len() { local text="$1" text="$(printf '%b' "$text" | sed -E $'s/\x1b\\[[0-9;?]*[A-Za-z]//g')" - printf '%s' "${#text}" + display_width "$text" } blank_line() { printf '\r%s\n' "$CLEAR_LINE"; } @@ -524,9 +524,9 @@ render_finish() { # actually happened, so a failed one withdraws the offer instead of # printing a promise the machine is not keeping. if [[ $TARGET_RELEASED == yes ]]; then - center "${DIM}You can now remove the install medium${RESET}" "$CONTENT_WIDTH" + center "${DIM}$(t finish.removeMedium)${RESET}" "$CONTENT_WIDTH" else - center "${DIM}Leave the install medium in until the reboot completes${RESET}" "$CONTENT_WIDTH" + center "${DIM}$(t finish.keepMedium)${RESET}" "$CONTENT_WIDTH" fi } >"$TTY_PATH" @@ -600,7 +600,9 @@ warm_reboot_path() { # render_finish, so the logo effect (up to 8s of it), the timeout in front # of it, the stty that sizes the prompt, and the button gum paints are all # still ahead of the moment the user is invited to pull the stick. - for binary in systemctl ttfx gum timeout stty; do + # kmscon too when it draws this screen: it repaints from the medium-backed + # live root on every frame of the effect and the button. + for binary in systemctl ttfx gum timeout stty ${OMARCHY_ISO_KMSCON:+kmscon}; do path=$(command -v "$binary" 2>/dev/null) || continue cat "$path" >/dev/null 2>&1 || true while IFS= read -r dep; do @@ -651,7 +653,7 @@ reboot_prompt() { # The button is the label with two columns of padding either side. label="$(t finish.reboot)" - prompt_pad=$(( ( $(term_cols) - ${#label} - 8 ) / 2 )) + prompt_pad=$(( ( $(term_cols) - $(display_width "$label") - 8 ) / 2 )) (( prompt_pad < 0 )) && prompt_pad=0 gum confirm \ --padding "0 0 0 $prompt_pad" \ @@ -662,10 +664,20 @@ reboot_prompt() { "" <"$TTY_PATH" >"$TTY_PATH" 2>&1 } +# Cut to width columns, not characters: a CJK character takes two. truncate_for_width() { - local text="$1" width="$2" - if (( ${#text} > width )); then - printf '%s…' "${text:0:$((width - 1))}" + local text="$1" width="$2" cut columns + (( width < 1 )) && width=1 + if (( $(display_width "$text") > width )); then + # A character takes at most two columns, so dropping half the excess never + # cuts too much, and a couple of passes reach the width. + cut=${text:0:$((width - 1))} + columns=$(display_width "$cut") + while (( columns > width - 1 )); do + cut=${cut:0:$((${#cut} - (columns - width + 2) / 2))} + columns=$(display_width "$cut") + done + printf '%s…' "$cut" else printf '%s' "$text" fi diff --git a/configs/airootfs/usr/local/bin/omarchy-iso-kmscon b/configs/airootfs/usr/local/bin/omarchy-iso-kmscon new file mode 100644 index 000000000..3d014b5f2 --- /dev/null +++ b/configs/airootfs/usr/local/bin/omarchy-iso-kmscon @@ -0,0 +1,137 @@ +#!/bin/bash +# +# Runs the installer inside kmscon on this VT, for languages the Linux console +# cannot draw. kmscon renders with fontconfig (the CJK font bundled in the live +# image) and reads keys through XKB, so loadkeys has no effect in it: the +# layout is passed here, from the keymap the configurator saved. +# +# omarchy-iso-kmscon run command in kmscon; returns when it exits +# omarchy-iso-kmscon --xkb print the XKB "layout model variant options" +# for a keymap, "-" for an empty field +# omarchy-iso-kmscon --face print the CJK font family kmscon draws a +# language's Han characters with + +STATE=/run/omarchy-iso + +# Console keymap → XKB settings, from systemd's table (the same one localectl +# and the installed system use). The disk password typed here is typed again +# at boot under the console keymap, so the layouts must place keys alike. +# systemd has no row for the keymaps below; they use the settings +# omarchy-provision-owner (keyboard_xkb_settings) gives the installed system. +# Unknown keymaps fall back to us. +xkb_for_keymap() { + local keymap=${1:-us} layout=- model=- variant=- options=- + local switch=grp:shifts_toggle,grp_led:scroll + case $keymap in + colemak) layout=us variant=colemak ;; + bg-cp1251) layout=bg,us variant=phonetic, options=$switch ;; + cz) layout=cz,us variant=qwerty, options=$switch ;; + de_CH-latin1) layout=ch ;; + kyrgyz) layout=kg,us options=$switch ;; + no-latin1) layout=no ;; + pl) layout=pl ;; + ua) layout=ua,us options=$switch ;; + *) + read -r layout model variant options < <(awk -v k="$keymap" '$1 == k { print $2, $3, $4, $5; exit }' /usr/share/systemd/kbd-model-map) + [[ -n $layout ]] || layout=us + ;; + esac + printf '%s %s %s %s\n' "$layout" "${model:--}" "${variant:--}" "${options:--}" +} + +# Pixel height for about 100 columns (cells are ~0.6 of the height wide) and no +# more than 36 rows, so the 81-column logo fits and a 4K panel isn't 300 columns +# of tiny text. +font_size() { + local w h size + { IFS=, read -r w h /dev/null || { w=1280 h=800; } + size=$((h / 36)) + ((w * 10 / 6 / 100 < size)) && size=$((w * 10 / 6 / 100)) + ((size < 14)) && size=14 + printf '%s' "$size" +} + +# Han characters take a different form in each CJK language, and the bundled +# collection carries every one of them: draw them as the language writes them. +face_for_language() { + case $1 in + ja) printf 'Noto Sans Mono CJK JP' ;; + ko) printf 'Noto Sans Mono CJK KR' ;; + zh-TW) printf 'Noto Sans Mono CJK TC' ;; + *) printf 'Noto Sans Mono CJK SC' ;; + esac +} + +if [[ ${1:-} == "--xkb" ]]; then + xkb_for_keymap "${2:-us}" + exit 0 +fi +if [[ ${1:-} == "--face" ]]; then + face_for_language "${2:-}" + exit 0 +fi + +keymap=us language= +if [[ -r $STATE/kmscon-resume ]]; then + { read -r keymap; read -r language; } < <(bash -c 'source "$1"; printf "%s\n%s\n" "${keyboard:-us}" "${language:-}"' _ "$STATE/kmscon-resume") +fi + +OMARCHY_ISO_KMSCON_FACE=$(face_for_language "$language") +OMARCHY_ISO_KMSCON_XKB=$(xkb_for_keymap "$keymap") +read -r layout model variant options <<<"$OMARCHY_ISO_KMSCON_XKB" +[[ $model == "-" ]] && model="" +[[ $variant == "-" ]] && variant="" +[[ $options == "-" ]] && options="" + +export OMARCHY_ISO_KMSCON=1 +export OMARCHY_ISO_KMSCON_XKB OMARCHY_ISO_KMSCON_FACE +# C.UTF-8 like the live system: bash string lengths count characters, and gum's +# width tables stay on narrow ambiguous-width glyphs, as libtsm draws them. +export LANG=C.UTF-8 +unset LC_ALL +# The console's size, exported on tty1, would stand in for kmscon's grid: +# tput and Python read COLUMNS and LINES before asking the terminal. +unset COLUMNS LINES + +# The script exits 75 to ask for a relaunch (new layout); anything else that is +# not success leaves a shell here, so an abort's message stays readable and the +# installer can be rerun in Chinese. +# The shell keeps this PID, so a retry from it that asks for a relaunch can +# hang it up, which ends kmscon and lets tty1 relaunch it. +inner='"$@"; status=$?; ((status == 0 || status == 75)) && exit $status; export OMARCHY_ISO_KMSCON_SHELL=$$; exec bash -l' + +mkdir -p "$STATE" +exec kmscon \ + --vt="$(tty)" \ + --oneshot \ + --no-reset-env \ + --no-mouse \ + --dpms-timeout=0 \ + --font-engine=pango \ + --font-name="${OMARCHY_ISO_KMSCON_FONT:-Adwaita Mono,$OMARCHY_ISO_KMSCON_FACE,monospace}" \ + --font-size="${OMARCHY_ISO_KMSCON_FONT_SIZE:-$(font_size)}" \ + --xkb-layout="$layout" \ + ${model:+--xkb-model="$model"} \ + ${variant:+--xkb-variant="$variant"} \ + ${options:+--xkb-options="$options"} \ + --palette=custom \ + --palette-black="26, 27, 38" \ + --palette-red="247, 118, 142" \ + --palette-green="158, 206, 106" \ + --palette-yellow="224, 175, 104" \ + --palette-blue="122, 162, 247" \ + --palette-magenta="187, 154, 247" \ + --palette-cyan="125, 207, 255" \ + --palette-light-grey="169, 177, 214" \ + --palette-dark-grey="65, 72, 104" \ + --palette-light-red="247, 118, 142" \ + --palette-light-green="158, 206, 106" \ + --palette-light-yellow="224, 175, 104" \ + --palette-light-blue="122, 162, 247" \ + --palette-light-magenta="187, 154, 247" \ + --palette-light-cyan="125, 207, 255" \ + --palette-white="192, 202, 245" \ + --palette-foreground="169, 177, 214" \ + --palette-background="26, 27, 38" \ + --login -- /bin/bash -c "$inner" _ "$@" \ + >>"$STATE/kmscon.log" 2>&1 diff --git a/configs/airootfs/usr/share/omarchy-iso/i18n.sh b/configs/airootfs/usr/share/omarchy-iso/i18n.sh index b788e23de..1fd7df43b 100644 --- a/configs/airootfs/usr/share/omarchy-iso/i18n.sh +++ b/configs/airootfs/usr/share/omarchy-iso/i18n.sh @@ -24,7 +24,29 @@ i18n_load() { } i18n_translated() { - [[ $1 =~ ^[a-z]{2,3}(-[A-Z]{2})?$ && -r $OMARCHY_ISO_I18N_DIR/$1.json ]] + [[ $1 =~ ^[a-z]{2,3}(-[A-Z]{2})?$ && -r $OMARCHY_ISO_I18N_DIR/$1.json ]] || return 1 + # CJK is beyond any console font: its catalog only applies inside kmscon, + # which draws with real fonts. On the plain VT the language stays English. + i18n_needs_kmscon "$1" && [[ ${OMARCHY_ISO_KMSCON:-} != 1 ]] && return 1 + return 0 +} + +# Languages whose script the Linux console cannot draw and that the ISO has a +# catalog for; picking one moves the installer into kmscon (omarchy-iso-kmscon). +# Without a catalog the installer would stay English there too. +i18n_needs_kmscon() { + [[ ($1 == zh-* || $1 == ja || $1 == ko) && -r $OMARCHY_ISO_I18N_DIR/$1.json ]] +} + +# Terminal columns a string takes: CJK and fullwidth characters take two. +# ${#s} counts characters, which centers Chinese text half a string too far right. +display_width() { + local text=$1 narrow wide + # Escapes, not literal characters: editors may normalize a literal U+F900 + # into U+8C48, which would double everything up to U+FAFF. + printf -v narrow '[^\u1100-\u115F\u2E80-\u3029\u3030-\u303E\u3040-\u3098\u309B-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE4F\uFF00-\uFF60\uFFE0-\uFFE6\U0001F300-\U0001F64F\U0001F900-\U0001F9FF\U00020000-\U0003FFFD]' + wide=${text//$narrow/} + printf '%s' $((${#text} + ${#wide})) } # The kernel's console fonts carry only the IBM PC character set, so a Linux VT diff --git a/configs/airootfs/usr/share/omarchy-iso/i18n/en.json b/configs/airootfs/usr/share/omarchy-iso/i18n/en.json index 93911de69..19a53146e 100644 --- a/configs/airootfs/usr/share/omarchy-iso/i18n/en.json +++ b/configs/airootfs/usr/share/omarchy-iso/i18n/en.json @@ -46,12 +46,20 @@ "space.analyzing": "Analyzing free space on %1", "freeSpace.title": "Install Omarchy in the %1 of free space.", "freeSpace.prompt": "Confirm installing on %1", + "verify.title": "Verifying the install medium", "encryption.hint": "Press Ctrl+C for unencrypted install.", "install.yes": "Yes, install", "install.yesUnencrypted": "Yes, install without encryption", "partitions.creating": "Creating partitions on %1", "partitions.luks": "Setting up LUKS2 on %1", "partitions.btrfs": "Creating Btrfs filesystem and subvolumes", + "partitions.efiFailed": "Could not create the EFI partition on %1", + "partitions.rootFailed": "Could not create the root partition on %1", + "partitions.efiMissing": "EFI partition %1 never appeared", + "partitions.rootMissing": "Root partition %1 never appeared", + "partitions.deviceMissing": "Root device %1 never appeared", + "partitions.targetUnmounted": "Target /mnt is not mounted; not starting the installer", + "partitions.espUnmounted": "ESP is not mounted at %1", "disk.intro": "Let's select where to install Omarchy...", "disk.header": "Select install disk", "tool.title": "Partition tool for %1", @@ -91,6 +99,8 @@ "finish.title": "Installed Omarchy", "finish.titleWithTime": "Installed Omarchy in %1", "finish.reboot": "Reboot Now", + "finish.removeMedium": "You can now remove the install medium", + "finish.keepMedium": "Leave the install medium in until the reboot completes", "finish.fallback": "Finished installing", "failure.title": "Omarchy installation stopped", "failure.status": "Installer exited with status %1", diff --git a/configs/airootfs/usr/share/omarchy-iso/i18n/ja.json b/configs/airootfs/usr/share/omarchy-iso/i18n/ja.json new file mode 100644 index 000000000..54d6f419b --- /dev/null +++ b/configs/airootfs/usr/share/omarchy-iso/i18n/ja.json @@ -0,0 +1,120 @@ +{ + "common.yes": "はい", + "common.back": "戻る", + "common.change": "いいえ、変更する", + "language.header": "言語", + "keyboard.intro": "このマシンをセットアップしましょう…", + "keyboard.anotherOwner": "Ctrl+C で、このマシンを別の所有者向けに準備します。", + "owner.title": "このマシンを別の所有者向けに準備します。", + "owner.detail": "システムは今インストールし、設定は初回起動時に行います。", + "owner.yes": "はい、別の所有者向けに準備する", + "owner.no": "いいえ、設定を続ける", + "owner.prompt": "このマシンを別の所有者向けに準備しますか?", + "user.intro": "ユーザーアカウントを設定しましょう…", + "summary.field": "項目", + "summary.value": "設定値", + "summary.username": "ユーザー名", + "summary.password": "パスワード", + "summary.hostname": "ホスト名", + "summary.timezone": "タイムゾーン", + "summary.keyboard": "キーボード", + "summary.language": "言語", + "summary.prompt": "この内容でよろしいですか?", + "firmware.title": "Windows から Qualcomm ファームウェアを保存しています", + "firmware.saved": "インストール用に Windows からファームウェア %1 個を保存しました。", + "firmware.partial": "Windows からファームウェア %2 個中 %1 個を保存しました。残りはドライバーストアにありませんでした。", + "firmware.none": "このマシンに Windows のファームウェアが見つかりませんでした。", + "firmware.bitlocker": "Windows パーティションは BitLocker で暗号化されています。", + "firmware.bitlockerHint": "ファームウェアを読み取れるよう、Windows で BitLocker をオフにしてください。", + "firmware.degraded": "インストールは続行できますが、GPU アクセラレーション、オーディオ、バッテリー表示が動作しない可能性があります。", + "firmware.extract": "後で、このノート PC と同じ機種の Windows ドライバーストアを使って %1 を実行してください。", + "space.title": "%1 の空き容量が足りません", + "space.detail": "%1 の使用可能な空き容量は %2 です。Omarchy には 32GB 以上必要です。", + "space.hint": "パーティションツールで %1 に 32GB 以上の空きを作ってから、もう一度お試しください。", + "space.openTool": "パーティションツールを開く", + "space.prompt": "インストール方法の選択に戻りますか?", + "bitlocker.checking": "%1 の BitLocker を確認しています", + "bitlocker.found": "%1 に BitLocker の署名が見つかりました。", + "bitlocker.hint": "Windows で BitLocker をオフにし、ドライブの復号が終わるのを待ってから、もう一度お試しください。", + "bitlocker.suspend": "BitLocker を一時停止するだけでは不十分です。ドライブは暗号化されたままです。", + "bitlocker.abort": "中止しました:このディスクでは BitLocker が有効です。", + "bitlocker.quit": "インストーラーを終了", + "esp.checking": "%1 の既存の EFI パーティションを確認しています", + "esp.found": "%1 に Windows の ESP が見つかりました。これには手を加えません。", + "esp.own": "Omarchy は空き領域に専用の EFI パーティションを作成します。", + "esp.new": "空き領域に新しい EFI パーティションを作成します。", + "space.analyzing": "%1 の空き領域を分析しています", + "freeSpace.title": "%1 の空き領域に Omarchy をインストールします。", + "freeSpace.prompt": "%1 へのインストールを確定", + "verify.title": "インストールメディアを検証しています", + "encryption.hint": "暗号化せずにインストールするには Ctrl+C を押してください。", + "install.yes": "はい、インストールする", + "install.yesUnencrypted": "はい、暗号化せずにインストールする", + "partitions.creating": "%1 にパーティションを作成しています", + "partitions.luks": "%1 に LUKS2 を設定しています", + "partitions.btrfs": "Btrfs ファイルシステムとサブボリュームを作成しています", + "partitions.efiFailed": "%1 に EFI パーティションを作成できませんでした", + "partitions.rootFailed": "%1 にルートパーティションを作成できませんでした", + "partitions.efiMissing": "EFI パーティション %1 が現れませんでした", + "partitions.rootMissing": "ルートパーティション %1 が現れませんでした", + "partitions.deviceMissing": "ルートデバイス %1 が現れませんでした", + "partitions.targetUnmounted": "ターゲット /mnt がマウントされていないため、インストーラーを開始しません", + "partitions.espUnmounted": "ESP が %1 にマウントされていません", + "disk.intro": "Omarchy のインストール先を選びましょう…", + "disk.header": "インストール先のディスクを選択", + "tool.title": "%1 のパーティションツール", + "tool.hint": "Omarchy 用に未割り当ての空き領域を作り、変更を書き込んでから終了してください。", + "tool.warning": "ここで Omarchy のパーティションは作成しないでください。対象の領域は空き領域(Free space)のままにしてください。", + "tool.tip": "ヒント:空き領域へのインストールには未割り当て領域が 32GB 以上必要です。ESP がない場合はさらに 2GB 必要です。", + "tool.open": "cfdisk を開く", + "tool.prompt": "%1 のパーティションツールを開きますか?", + "mode.intro": "Omarchy のインストール方法を選びましょう…", + "mode.header": "%1 へのインストール方法を選択", + "mode.fullDisk": "ディスク全体にインストール", + "mode.freeSpace": "空き領域にインストール(既存のデータを残す)", + "mode.otherDisk": "別のディスクを選ぶ", + "overwrite.warning": "すべてが上書きされます。元に戻すことはできません。", + "overwrite.prompt": "%1 の上書きを確定", + "abort.default": "インストールを中止しました", + "abort.retry": "後で次のコマンドを実行すると再試行できます:%1", + "progress.tipLine": "ヒント:%1", + "progress.tip.menu": "Super + Space で Omarchy メニューを開き、アプリや設定などにアクセス", + "progress.tip.keybindings": "Super + K ですべてのキー割り当てを表示", + "progress.tip.superKey": "Super はキーボードの Windows キーまたは Command キーです", + "progress.tip.signPdfs": "PDF の署名には Signed を使います", + "progress.tip.localSend": "LocalSend でスマホやノート PC とファイルを共有", + "progress.tip.webApps": "メニューの「インストール > ウェブアプリ」で任意のサイトをアプリに", + "progress.tip.terminal": "Super + Return でターミナル、Super + Shift + Return でブラウザー", + "progress.tip.media": "画像は Pinta、動画は Kdenlive、文書は LibreOffice で編集", + "progress.tip.ocr": "Super + Ctrl + Print で画面上の文字を OCR で取り込み", + "progress.tip.screenshots": "Print でスクリーンショット、Alt + Print で画面を録画", + "progress.tip.reminders": "Super + Ctrl + R でリマインダーを設定", + "progress.tip.themes": "Omarchy メニューの「外観 > テーマ」でテーマを切り替え", + "progress.tip.transparentBar": "メニューバーをダブルクリックすると透明になります", + "progress.tip.windows": "メニューの「インストール > Windows」で完全な Windows VM を実行", + "progress.tip.clipboard": "Super + Ctrl + V でクリップボードマネージャーを開く", + "progress.tip.workspaces": "Super + 1〜0 でワークスペースを切り替え、Shift 付きでウィンドウも移動", + "progress.tip.colorPicker": "Super + Print で画面上のどこからでも色を取得", + "progress.tip.update": "Omarchy メニューの「更新」でシステムを最新に保てます", + "finish.title": "Omarchy をインストールしました", + "finish.titleWithTime": "Omarchy をインストールしました(所要時間 %1)", + "finish.reboot": "今すぐ再起動", + "finish.removeMedium": "インストールメディアを取り外せます", + "finish.keepMedium": "再起動が終わるまでインストールメディアを取り外さないでください", + "finish.fallback": "インストールが完了しました", + "failure.title": "Omarchy のインストールが停止しました", + "failure.status": "インストーラーがステータス %1 で終了しました", + "failure.logLines": "ログの最後の数行:", + "failure.targetLogLines": "ターゲットのログの最後の数行:", + "failure.help": "ヘルプ:%1", + "failure.menu": "どうしますか?", + "failure.upload": "サポート用にログをアップロード", + "failure.viewLog": "ログ全体を表示", + "failure.shell": "シェルに切り替える", + "failure.reboot": "再起動", + "failure.powerOff": "電源を切る", + "failure.pressEnter": "Enter キーで続行…", + "failure.noUploader": "この環境ではログをアップロードできません。", + "failure.installLog": "インストールログ:%1", + "failure.targetLog": "ターゲットのログ:%1" +} diff --git a/configs/airootfs/usr/share/omarchy-iso/i18n/ko.json b/configs/airootfs/usr/share/omarchy-iso/i18n/ko.json new file mode 100644 index 000000000..9c0b46ba9 --- /dev/null +++ b/configs/airootfs/usr/share/omarchy-iso/i18n/ko.json @@ -0,0 +1,120 @@ +{ + "common.yes": "예", + "common.back": "뒤로", + "common.change": "아니요, 변경하기", + "language.header": "언어", + "keyboard.intro": "컴퓨터 설정을 시작합니다...", + "keyboard.anotherOwner": "Ctrl+C를 누르면 다른 소유자를 위해 이 컴퓨터를 준비합니다.", + "owner.title": "다른 소유자를 위해 이 컴퓨터를 준비합니다.", + "owner.detail": "시스템은 지금 설치하고, 설정은 처음 부팅할 때 진행합니다.", + "owner.yes": "예, 다른 소유자를 위해 준비", + "owner.no": "아니요, 계속 설정", + "owner.prompt": "다른 소유자를 위해 이 컴퓨터를 준비할까요?", + "user.intro": "사용자 계정을 설정합니다...", + "summary.field": "항목", + "summary.value": "값", + "summary.username": "사용자 이름", + "summary.password": "비밀번호", + "summary.hostname": "호스트명", + "summary.timezone": "시간대", + "summary.keyboard": "키보드", + "summary.language": "언어", + "summary.prompt": "이대로 진행할까요?", + "firmware.title": "Windows에서 Qualcomm 펌웨어를 저장하는 중", + "firmware.saved": "설치에 사용할 펌웨어 파일 %1개를 Windows에서 저장했습니다.", + "firmware.partial": "Windows에서 펌웨어 파일 %2개 중 %1개를 저장했습니다. 나머지는 드라이버 저장소에 없었습니다.", + "firmware.none": "이 컴퓨터에서 Windows 펌웨어를 찾지 못했습니다.", + "firmware.bitlocker": "Windows 파티션이 BitLocker로 암호화되어 있습니다.", + "firmware.bitlockerHint": "펌웨어를 읽을 수 있도록 Windows에서 BitLocker를 끄세요.", + "firmware.degraded": "설치는 계속할 수 있지만 GPU 가속, 오디오, 배터리 정보가 작동하지 않을 수 있습니다.", + "firmware.extract": "나중에 같은 모델 노트북의 Windows 드라이버 저장소로 %1을(를) 실행하세요.", + "space.title": "%1의 여유 공간이 부족합니다", + "space.detail": "%1의 사용 가능한 여유 공간은 %2입니다. Omarchy에는 최소 32GB가 필요합니다.", + "space.hint": "파티션 도구를 열어 %1에 32GB 이상의 공간을 확보한 뒤 다시 시도하세요.", + "space.openTool": "파티션 도구 열기", + "space.prompt": "설치 방식 선택으로 돌아갈까요?", + "bitlocker.checking": "%1의 BitLocker를 확인하는 중", + "bitlocker.found": "%1에서 BitLocker 서명이 감지되었습니다.", + "bitlocker.hint": "Windows에서 BitLocker를 끄고 드라이브 암호 해독이 끝날 때까지 기다린 뒤 다시 시도하세요.", + "bitlocker.suspend": "BitLocker를 일시 중단하는 것만으로는 부족합니다. 드라이브는 여전히 암호화되어 있습니다.", + "bitlocker.abort": "중단됨: 이 디스크에 BitLocker가 켜져 있습니다.", + "bitlocker.quit": "설치 프로그램 종료", + "esp.checking": "%1의 기존 EFI 파티션을 확인하는 중", + "esp.found": "%1에서 Windows ESP를 찾았습니다. 그대로 둡니다.", + "esp.own": "Omarchy는 여유 공간에 전용 EFI 파티션을 만듭니다.", + "esp.new": "여유 공간에 새 EFI 파티션을 만듭니다.", + "space.analyzing": "%1의 여유 공간을 분석하는 중", + "freeSpace.title": "%1의 여유 공간에 Omarchy를 설치합니다.", + "freeSpace.prompt": "%1에 설치 확인", + "verify.title": "설치 미디어를 검증하는 중", + "encryption.hint": "암호화 없이 설치하려면 Ctrl+C를 누르세요.", + "install.yes": "예, 설치", + "install.yesUnencrypted": "예, 암호화 없이 설치", + "partitions.creating": "%1에 파티션을 만드는 중", + "partitions.luks": "%1에 LUKS2를 설정하는 중", + "partitions.btrfs": "Btrfs 파일 시스템과 하위 볼륨을 만드는 중", + "partitions.efiFailed": "%1에 EFI 파티션을 만들 수 없습니다", + "partitions.rootFailed": "%1에 루트 파티션을 만들 수 없습니다", + "partitions.efiMissing": "EFI 파티션 %1이(가) 나타나지 않았습니다", + "partitions.rootMissing": "루트 파티션 %1이(가) 나타나지 않았습니다", + "partitions.deviceMissing": "루트 장치 %1이(가) 나타나지 않았습니다", + "partitions.targetUnmounted": "대상 /mnt가 마운트되지 않아 설치 프로그램을 시작하지 않습니다", + "partitions.espUnmounted": "ESP가 %1에 마운트되지 않았습니다", + "disk.intro": "Omarchy를 설치할 위치를 선택합니다...", + "disk.header": "설치할 디스크 선택", + "tool.title": "%1 파티션 도구", + "tool.hint": "Omarchy용 미할당 여유 공간을 만든 뒤 변경 사항을 기록하고 종료하세요.", + "tool.warning": "여기서 Omarchy 파티션을 만들지 마세요. 대상 영역은 여유 공간(Free space)으로 남겨 두세요.", + "tool.tip": "팁: 여유 공간 설치에는 미할당 공간이 최소 32GB 필요하며, ESP가 없으면 2GB가 더 필요합니다.", + "tool.open": "cfdisk 열기", + "tool.prompt": "%1 파티션 도구를 열까요?", + "mode.intro": "Omarchy 설치 방식을 선택합니다...", + "mode.header": "%1에 설치할 방식 선택", + "mode.fullDisk": "디스크 전체에 설치", + "mode.freeSpace": "여유 공간에 설치 (기존 데이터 유지)", + "mode.otherDisk": "다른 디스크 선택", + "overwrite.warning": "모든 내용을 덮어씁니다. 복구할 수 없습니다.", + "overwrite.prompt": "%1 덮어쓰기 확인", + "abort.default": "설치를 중단했습니다", + "abort.retry": "나중에 다음 명령으로 다시 시도할 수 있습니다: %1", + "progress.tipLine": "팁: %1", + "progress.tip.menu": "Super + Space로 Omarchy 메뉴를 열어 앱, 설정 등을 찾을 수 있습니다", + "progress.tip.keybindings": "Super + K로 모든 단축키를 볼 수 있습니다", + "progress.tip.superKey": "Super는 키보드의 Windows 키 또는 Command 키입니다", + "progress.tip.signPdfs": "PDF 서명에는 Signed를 사용하세요", + "progress.tip.localSend": "LocalSend로 휴대폰, 노트북과 파일을 주고받으세요", + "progress.tip.webApps": "메뉴의 설치 > 웹 앱으로 어떤 웹사이트든 앱으로 만들 수 있습니다", + "progress.tip.terminal": "Super + Return은 터미널, Super + Shift + Return은 브라우저를 엽니다", + "progress.tip.media": "이미지는 Pinta, 동영상은 Kdenlive, 문서는 LibreOffice로 편집하세요", + "progress.tip.ocr": "Super + Ctrl + Print로 화면의 글자를 OCR로 가져옵니다", + "progress.tip.screenshots": "Print는 스크린샷, Alt + Print는 화면 녹화입니다", + "progress.tip.reminders": "Super + Ctrl + R로 알림을 설정하세요", + "progress.tip.themes": "Omarchy 메뉴의 모양 > 테마에서 테마를 바꿀 수 있습니다", + "progress.tip.transparentBar": "메뉴 막대를 두 번 클릭하면 투명해집니다", + "progress.tip.windows": "메뉴의 설치 > Windows로 완전한 Windows VM을 실행하세요", + "progress.tip.clipboard": "Super + Ctrl + V로 클립보드 관리자를 엽니다", + "progress.tip.workspaces": "Super + 1~0으로 작업 공간을 바꾸고, Shift를 더하면 창도 함께 옮깁니다", + "progress.tip.colorPicker": "Super + Print로 화면 어디서나 색을 추출합니다", + "progress.tip.update": "Omarchy 메뉴의 업데이트로 시스템을 최신 상태로 유지하세요", + "finish.title": "Omarchy 설치 완료", + "finish.titleWithTime": "Omarchy 설치 완료 (소요 시간 %1)", + "finish.reboot": "지금 다시 시작", + "finish.removeMedium": "이제 설치 미디어를 제거해도 됩니다", + "finish.keepMedium": "다시 시작이 끝날 때까지 설치 미디어를 그대로 두세요", + "finish.fallback": "설치를 마쳤습니다", + "failure.title": "Omarchy 설치가 중단되었습니다", + "failure.status": "설치 프로그램이 상태 %1(으)로 종료되었습니다", + "failure.logLines": "마지막 로그:", + "failure.targetLogLines": "대상 시스템의 마지막 로그:", + "failure.help": "도움말: %1", + "failure.menu": "어떻게 할까요?", + "failure.upload": "지원을 위해 로그 업로드", + "failure.viewLog": "전체 로그 보기", + "failure.shell": "셸로 나가기", + "failure.reboot": "다시 시작", + "failure.powerOff": "전원 끄기", + "failure.pressEnter": "계속하려면 Enter를 누르세요…", + "failure.noUploader": "이 환경에서는 로그를 업로드할 수 없습니다.", + "failure.installLog": "설치 로그: %1", + "failure.targetLog": "대상 시스템 로그: %1" +} diff --git a/configs/airootfs/usr/share/omarchy-iso/i18n/zh-CN.json b/configs/airootfs/usr/share/omarchy-iso/i18n/zh-CN.json new file mode 100644 index 000000000..91043cf75 --- /dev/null +++ b/configs/airootfs/usr/share/omarchy-iso/i18n/zh-CN.json @@ -0,0 +1,120 @@ +{ + "common.yes": "是", + "common.back": "返回", + "common.change": "否,重新修改", + "language.header": "语言", + "keyboard.intro": "开始设置这台电脑……", + "keyboard.anotherOwner": "按 Ctrl+C 可为另一位机主准备这台电脑。", + "owner.title": "这会为另一位机主准备这台电脑。", + "owner.detail": "系统现在安装,设置推迟到首次启动时完成。", + "owner.yes": "是,为另一位机主准备", + "owner.no": "否,继续设置", + "owner.prompt": "为另一位机主准备这台电脑?", + "user.intro": "设置你的用户账号……", + "summary.field": "项目", + "summary.value": "设置", + "summary.username": "用户名", + "summary.password": "密码", + "summary.hostname": "主机名", + "summary.timezone": "时区", + "summary.keyboard": "键盘", + "summary.language": "语言", + "summary.prompt": "以上信息正确吗?", + "firmware.title": "正在从 Windows 保存高通固件", + "firmware.saved": "已从 Windows 保存 %1 个固件文件供安装使用。", + "firmware.partial": "已从 Windows 保存 %1/%2 个固件文件;其余不在驱动存储中。", + "firmware.none": "这台电脑上没有找到 Windows 固件。", + "firmware.bitlocker": "Windows 分区已启用 BitLocker 加密。", + "firmware.bitlockerHint": "请在 Windows 中关闭 BitLocker,以便读取固件。", + "firmware.degraded": "可以继续安装,但 GPU 加速、音频和电池信息可能无法使用。", + "firmware.extract": "之后请用同型号笔记本的 Windows 驱动存储运行 %1。", + "space.title": "%1 上的可用空间不足", + "space.detail": "%1 只有 %2 可用空间;Omarchy 至少需要 32GB。", + "space.hint": "请打开分区工具,在 %1 上腾出至少 32GB,然后重试。", + "space.openTool": "打开分区工具", + "space.prompt": "返回安装方式选择?", + "bitlocker.checking": "正在检查 %1 上的 BitLocker", + "bitlocker.found": "在 %1 上检测到 BitLocker 签名。", + "bitlocker.hint": "请在 Windows 中关闭 BitLocker,等待磁盘解密完成后重试。", + "bitlocker.suspend": "仅暂停 BitLocker 不够——磁盘仍处于加密状态。", + "bitlocker.abort": "已中止:此磁盘启用了 BitLocker。", + "bitlocker.quit": "退出安装程序", + "esp.checking": "正在检查 %1 上已有的 EFI 分区", + "esp.found": "在 %1 找到 Windows ESP——保持不动。", + "esp.own": "Omarchy 将在空闲空间中创建自己的 EFI 分区。", + "esp.new": "将在空闲空间中创建新的 EFI 分区。", + "space.analyzing": "正在分析 %1 上的空闲空间", + "freeSpace.title": "将 Omarchy 安装到 %1 的空闲空间中。", + "freeSpace.prompt": "确认安装到 %1", + "verify.title": "正在校验安装介质", + "encryption.hint": "按 Ctrl+C 改为不加密安装。", + "install.yes": "是,开始安装", + "install.yesUnencrypted": "是,不加密安装", + "partitions.creating": "正在 %1 上创建分区", + "partitions.luks": "正在 %1 上设置 LUKS2 加密", + "partitions.btrfs": "正在创建 Btrfs 文件系统和子卷", + "partitions.efiFailed": "无法在 %1 上创建 EFI 分区", + "partitions.rootFailed": "无法在 %1 上创建根分区", + "partitions.efiMissing": "EFI 分区 %1 一直没有出现", + "partitions.rootMissing": "根分区 %1 一直没有出现", + "partitions.deviceMissing": "根设备 %1 一直没有出现", + "partitions.targetUnmounted": "目标 /mnt 未挂载,不启动安装程序", + "partitions.espUnmounted": "ESP 未挂载到 %1", + "disk.intro": "选择 Omarchy 的安装位置……", + "disk.header": "选择安装磁盘", + "tool.title": "%1 的分区工具", + "tool.hint": "请腾出未分配的空闲空间给 Omarchy,然后写入更改并退出。", + "tool.warning": "不要在这里创建 Omarchy 分区——请把目标区域保留为空闲空间(Free space)。", + "tool.tip": "提示:空闲空间安装至少需要 32GB 未分配空间;如果还没有 ESP,另需 2GB。", + "tool.open": "打开 cfdisk", + "tool.prompt": "打开 %1 的分区工具?", + "mode.intro": "选择 Omarchy 的安装方式……", + "mode.header": "选择在 %1 上的安装方式", + "mode.fullDisk": "整盘安装", + "mode.freeSpace": "安装到空闲空间(保留现有数据)", + "mode.otherDisk": "选择其他磁盘", + "overwrite.warning": "磁盘上的所有内容都将被清空,且无法恢复。", + "overwrite.prompt": "确认清空 %1", + "abort.default": "安装已中止", + "abort.retry": "稍后可运行以下命令重试:%1", + "progress.tipLine": "提示:%1", + "progress.tip.menu": "Super + Space 打开 Omarchy 菜单,可找到应用、设置等", + "progress.tip.keybindings": "Super + K 显示所有快捷键", + "progress.tip.superKey": "Super 就是键盘上的 Windows 键或 Command 键", + "progress.tip.signPdfs": "用 Xournal++ 签署 PDF", + "progress.tip.localSend": "用 LocalSend 与手机和电脑互传文件", + "progress.tip.webApps": "在菜单中选择“安装 > 网页应用”,把任意网站变成应用", + "progress.tip.terminal": "Super + Return 打开终端,Super + Shift + Return 打开浏览器", + "progress.tip.media": "用 Pinta 编辑图片,用 Kdenlive 剪辑视频,用 LibreOffice 处理文档", + "progress.tip.ocr": "Super + Ctrl + Print 通过 OCR 识别屏幕上的文字", + "progress.tip.screenshots": "Print 截图,Alt + Print 录屏", + "progress.tip.reminders": "Super + Ctrl + R 设置提醒", + "progress.tip.themes": "在 Omarchy 菜单的“样式 > 主题”中切换主题", + "progress.tip.transparentBar": "双击菜单栏可使其透明", + "progress.tip.windows": "在菜单中选择“安装 > Windows”运行完整的 Windows 虚拟机", + "progress.tip.clipboard": "Super + Ctrl + V 打开剪贴板管理器", + "progress.tip.workspaces": "Super + 1 到 0 切换工作区,加 Shift 可把窗口一起带过去", + "progress.tip.colorPicker": "Super + Print 从屏幕任意位置取色", + "progress.tip.update": "在 Omarchy 菜单中选择“更新”保持系统最新", + "finish.title": "Omarchy 安装完成", + "finish.titleWithTime": "Omarchy 安装完成,用时 %1", + "finish.reboot": "立即重启", + "finish.removeMedium": "现在可以移除安装介质", + "finish.keepMedium": "重启完成前请勿移除安装介质", + "finish.fallback": "安装完成", + "failure.title": "Omarchy 安装已停止", + "failure.status": "安装程序退出,状态码 %1", + "failure.logLines": "最后几行日志:", + "failure.targetLogLines": "目标系统最后几行日志:", + "failure.help": "获取帮助:%1", + "failure.menu": "接下来要做什么?", + "failure.upload": "上传日志以获取支持", + "failure.viewLog": "查看完整日志", + "failure.shell": "进入命令行", + "failure.reboot": "重启", + "failure.powerOff": "关机", + "failure.pressEnter": "按 Enter 继续……", + "failure.noUploader": "当前环境没有可用的日志上传工具。", + "failure.installLog": "安装日志:%1", + "failure.targetLog": "目标系统日志:%1" +} diff --git a/configs/profiledef.sh b/configs/profiledef.sh index dff5012ca..6f76f3f13 100644 --- a/configs/profiledef.sh +++ b/configs/profiledef.sh @@ -55,6 +55,7 @@ file_permissions=( ["/usr/local/bin/omarchy-install-diagnose-media"]="0:0:755" ["/usr/local/bin/omarchy-luks-calibrate"]="0:0:755" ["/usr/local/bin/omarchy-iso-install"]="0:0:755" + ["/usr/local/bin/omarchy-iso-kmscon"]="0:0:755" ["/usr/local/bin/omarchy-upload-log"]="0:0:755" ["/usr/local/sbin/omarchy-n1x-live-probe"]="0:0:755" ["/var/cache/omarchy/mirror/offline/"]="0:0:775" diff --git a/test/unit/dashboard-release-gate-test.sh b/test/unit/dashboard-release-gate-test.sh index ede6acf35..566e7bbdc 100755 --- a/test/unit/dashboard-release-gate-test.sh +++ b/test/unit/dashboard-release-gate-test.sh @@ -136,14 +136,14 @@ check_has "the failure is logged" "release: could not release $BOX/mnt" "$LOG_OU check_has "the helper's holder diagnosis is forwarded to the log" "holders: init(1)" "$LOG_OUT" # ── What the finish screen promises ────────────────────────────────────────── +# The stand-in jq loads no catalog, so each note shows as its catalog key. scenario render_finish 0 -check_has "a released target invites the medium out" "You can now remove the install medium" "$TTY_OUT" +check_has "a released target invites the medium out" "finish.removeMedium" "$TTY_OUT" scenario render_finish 1 -check_has "a held target asks for the medium to stay" \ - "Leave the install medium in until the reboot completes" "$TTY_OUT" +check_has "a held target asks for the medium to stay" "finish.keepMedium" "$TTY_OUT" check_absent "and never promises the opposite in the same breath" \ - "You can now remove" "$TTY_OUT" + "finish.removeMedium" "$TTY_OUT" # ── What the button does ───────────────────────────────────────────────────── scenario reboot_now 0 diff --git a/test/unit/test_installer_i18n.py b/test/unit/test_installer_i18n.py index 1f4040521..9867adc7c 100644 --- a/test/unit/test_installer_i18n.py +++ b/test/unit/test_installer_i18n.py @@ -11,6 +11,7 @@ import sys import tempfile import types +import unicodedata import unittest from pathlib import Path @@ -39,6 +40,15 @@ from orchestrator.context import validate_language # noqa: E402 +# Catalogs only kmscon draws, with real fonts (i18n_needs_kmscon); the console +# font never has to carry them. +KMSCON_ONLY = re.compile(r"^(zh-[A-Z]{2}|ja|ko)$") + + +def columns(text): + return sum(2 if unicodedata.east_asian_width(c) in "WF" else 1 for c in text) + + def catalogs(): return {path.stem: json.loads(path.read_text()) for path in sorted(I18N.glob("*.json"))} @@ -87,7 +97,7 @@ def test_tips_fit_the_progress_screen_without_truncation(self): for key, tip in catalog.items(): if key.startswith("progress.tip."): with self.subTest(code=code, key=key): - self.assertLessEqual(len(line.replace("%1", tip)), 80) + self.assertLessEqual(columns(line.replace("%1", tip)), 80) def test_codes_are_omarchy_languages(self): registry = omarchy_file("default/i18n/locales.json") @@ -118,7 +128,7 @@ def form_environment(self, *languages): for name in ("language_default", "set_form_language")) steps = "".join(f'language={code}; set_form_language; env | grep "^OMARCHY_FORM_" | sort; echo --;' for code in languages) output = subprocess.run( - ["bash", "-c", f"{functions}\n{steps}"], + ["bash", "-c", f"source {SHARE / 'i18n.sh'}\n{functions}\n{steps}"], env={"PATH": os.environ["PATH"], "LANGUAGE_DEFAULTS": str(SHARE / "language-defaults.json")}, capture_output=True, text=True, check=True, ).stdout @@ -131,7 +141,9 @@ def test_the_setup_form_gets_the_language_and_its_defaults(self): # Picking again replaces the fallback. A language with no home country # falls back to UTC: with no fallback at all, an offline form opens # its timezone search, where Enter takes the first zone, Africa/Abidjan. - self.assertEqual(arabic, {"OMARCHY_FORM_LANGUAGE": "ar", "OMARCHY_FORM_KEYBOARD_DEFAULT": "English (US)", + # A script the console cannot draw keeps the form in English, as the + # rest of the installer is, rather than drawing its headers as boxes. + self.assertEqual(arabic, {"OMARCHY_FORM_LANGUAGE": "en", "OMARCHY_FORM_KEYBOARD_DEFAULT": "English (US)", "OMARCHY_FORM_TIMEZONE_FALLBACK": "UTC"}) self.assertEqual(english["OMARCHY_FORM_TIMEZONE_FALLBACK"], "UTC") self.assertEqual(unknown["OMARCHY_FORM_KEYBOARD_DEFAULT"], "English (US)") @@ -187,6 +199,8 @@ def test_the_live_console_font_draws_every_translated_string(self): module.patch(width, height, glyphs, table) drawable = {codepoint for codepoints in table for codepoint in codepoints} for code, catalog in catalogs().items(): + if KMSCON_ONLY.match(code): + continue text = "".join(catalog.values()) + names.get(code, {}).get("name", "") + UI_GLYPHS missing = sorted({c for c in text if ord(c) > 0x7E and ord(c) not in drawable}) with self.subTest(size=size, code=code): @@ -272,6 +286,68 @@ def test_placeholders_and_english_fallback(self): self.assertEqual(self.lookup('i18n_load ../da; t a.b x y', directory), "Disk x has y") +class KmsconLanguageTest(unittest.TestCase): + def shell(self, script, **env): + return subprocess.run( + ["bash", "-c", f'source "{SHARE}/i18n.sh"; {script}'], + env={"PATH": os.environ["PATH"], "LANG": "C.UTF-8", **env}, + capture_output=True, text=True, check=True, + ).stdout + + def test_cjk_speaks_only_inside_kmscon(self): + # On the Linux console CJK would be boxes, so the installer stays English there. + for code, reboot in (("zh-CN", "立即重启"), ("ja", "今すぐ再起動"), ("ko", "지금 다시 시작")): + with self.subTest(code=code): + script = f"i18n_load {code}; t finish.reboot" + self.assertEqual(self.shell(script), "Reboot Now") + self.assertEqual(self.shell(script, OMARCHY_ISO_KMSCON="1"), reboot) + self.assertEqual(self.shell("i18n_load de; t common.yes"), "Ja") + + def test_display_width_counts_cjk_as_two_columns(self): + # Centering uses it: by characters, Chinese lands half its width too far right. + self.assertEqual(self.shell('display_width "Omarchy 安装完成,用时 1m"'), "25") + self.assertEqual(self.shell('display_width "abc…—·"'), "6") + self.assertEqual(self.shell('display_width "今すぐ再起動 OK"'), "15") + self.assertEqual(self.shell('display_width "지금 다시 시작"'), "14") + # Icon-font glyphs (private use area) stay one column wide. + self.assertEqual(self.shell('display_width "\ue900ab"'), "3") + + @unittest.skipUnless(Path("/usr/share/systemd/kbd-model-map").exists(), "needs systemd's kbd-model-map") + def test_kmscon_types_like_the_boot_keymap(self): + # The disk password typed in kmscon is typed again at boot under the console + # keymap: a keymap systemd's table lacks must not quietly become us, and a + # two-group layout needs its switch or Latin letters cannot be typed. + def xkb(keymap): + return subprocess.run( + ["bash", str(ROOT / "configs/airootfs/usr/local/bin/omarchy-iso-kmscon"), "--xkb", keymap], + capture_output=True, text=True, check=True, + ).stdout.split() + self.assertEqual(xkb("de_CH-latin1")[0], "ch") + self.assertEqual(xkb("colemak")[2], "colemak") + self.assertIn("grp:shifts_toggle", xkb("ua")[3]) + self.assertIn("grp:shifts_toggle", xkb("ru")[3]) + self.assertEqual(xkb("jp106")[:2], ["jp", "jp106"]) + + def test_kmscon_draws_han_in_the_languages_forms(self): + # The configurator relaunches kmscon when this changes, so Chinese picked + # first and Japanese on the way back ends up in Japanese forms. + def face(language): + return subprocess.run( + ["bash", str(ROOT / "configs/airootfs/usr/local/bin/omarchy-iso-kmscon"), "--face", language], + capture_output=True, text=True, check=True, + ).stdout + self.assertEqual(face("ja"), "Noto Sans Mono CJK JP") + self.assertEqual(face("ko"), "Noto Sans Mono CJK KR") + self.assertEqual(face("zh-CN"), "Noto Sans Mono CJK SC") + + def test_only_the_language_screen_picks_the_language(self): + # The language goes to the installed system, so nothing after the + # summary the user confirmed (a timezone, say) may change it. + configurator = (ROOT / "configs/airootfs/root/configurator").read_text() + assignments = re.findall(r"^\s*language=.*$", configurator, re.MULTILINE) + self.assertEqual([line.strip() for line in assignments], ['language="en"', "language=$choice"]) + + class ConsoleFontLoadTest(unittest.TestCase): def test_a_failing_font_probe_never_stops_a_strict_caller(self): with tempfile.TemporaryDirectory() as directory: