This is for GRUB to perform language translation, hence the name "internationalization" or i18n. To support this, we need to take note of a few things.
GRUB use UTF-8 encoding internally by by default.
This might be false on systems configured with legacy charset but as long as the charset used is superset of ASCII you should be able to access ASCII-named files. And it’s recommended to configure your system to use UTF-8 to access the filesystem, convmv may help with migration.
terminfo
as either ASCII, UTF-8 or “visual UTF-8”. Last one is against the specification but results in correct rendering of right-to-left on some readers which don’t have own bidi implementation.So no dead keys or advanced input method. Also there is no keymap change hotkey. In practice it makes difficult to enter any text using non-Latin alphabet. Moreover all current input consumers are limited to ASCII.
GRUB supports being translated. For this you need to have language *.mo files in $prefix/locale, load gettext module and set “lang” variable.
Regexps work on unicode characters, however no attempt at checking cannonical equivalence has been made. Moreover the classes like [:alpha:] match only ASCII subset.
test
(see test) tests <, >, <=, >=, -pgt and -plt compare the strings in the lexicographical order of unicode code-points, replicating the behavior of test from coreutils. environment variables and commands are listed in the same order.From poly-light repository (https://github.com/shvchk/poly-light/blob/master/theme.txt):
# Global properties
title-text: ""
desktop-image: "background.png"
desktop-color: "#000000"
terminal-font: "Unifont Regular 18"
terminal-box: "terminal_box_*.png"
terminal-left: "0"
terminal-top: "0"
terminal-width: "100%"
terminal-height: "100%"
terminal-border: "0"
# Boot menu
+ boot_menu {
left = 15%
top = 20%
width = 70%
height = 60%
item_font = "Unifont Regular 18"
item_color = "#777777"
selected_item_color = "#444444"
item_height = 40
item_spacing = 4
item_pixmap_style = "item_*.png"
selected_item_pixmap_style = "selected_item_*.png"
}
# Countdown message
+ label {
left = 0
top = 100%-48
width = 100%
align = "center"
id = "__timeout__"
# DE
# text = "Start in %d Sekunden."
# EN
text = "Booting in %d seconds"
# ES
# text = "Arranque en %d segundos"
# FR
# text = "Démarrage automatique dans %d secondes"
# IT
# text = "Avvio in %d secondi"
# NO
# text = "Starter om %d sekunder"
# PT
# text = "Arranque automático dentro de %d segundos"
# RU
# text = "Загрузка выбранного пункта через %d сек."
# UA
# text = "Автоматичне завантаження розпочнеться через %d сек."
# zh_CN
# text = "在 %d 内启动"
color = "#777777"
font = "Unifont Regular 18"
}
# Navigation keys hint
+ label {
left = 0
top = 100%-24
width = 100%
align = "center"
# DE
# text = "System mit ↑ und ↓ auswählen und mit Enter bestätigen."
# EN
text = "Use ↑ and ↓ keys to change selection, Enter to confirm"
# ES
# text = "Use las teclas ↑ y ↓ para cambiar la selección, Enter para confirmar"
# FR
# text = "Choisissez le système avec les flèches du clavier (↑ et ↓), puis validez avec la touche Enter (↲)"
# IT
# text = "Usa i tasti ↑ e ↓ per cambiare la selezione, premi Invio ↲ per confermare"
# NO
# text = "Bruk ↑ og ↓ for å endre menyvalg, velg med Enter"
# PT
# text = "Use as teclas ↑ e ↓ para mudar a seleção, e ENTER para confirmar"
# RU
# text = "Используйте клавиши ↑ и ↓ для изменения выбора, Enter для подтверждения"
# UA
# text = "Використовуйте ↑ та ↓ для вибору, Enter для підтвердження"
# zh_CN
# text = "使用 ↑ 和 ↓ 键移动选择条,Enter 键确认"
color = "#777777"
font = "Unifont Regular 18"
}
Install.sh script:
...
declare -A LANGS=(
[Chinese]=zh_CN
[English]=EN
[French]=FR
[German]=DE
[Italian]=IT
[Norwegian]=NO
[Portuguese]=PT
[Russian]=RU
[Spanish]=ES
[Ukrainian]=UA
)
LANG_NAMES=($(echo ${!LANGS[*]} | tr ' ' '\n' | sort -n))
...
if [[ "$LANG" != "English" ]]; then
echo "Changing language to ${LANG}"
sed -i -r \
-e '/^\s+# EN$/{n;s/^(\s*)/\1# /}' \
-e '/^\s+# '"${LANGS[$LANG]}"'$/{n;s/^(\s*)#\s*/\1/}' \
${THEME}-master/theme.txt
fi
...