Create a package to install and apply localization after OS installation

Here is the place were the team and the community projects meet together. Help us to develop SolydXK projects or contribute your ideas for future releases.
vacnt
Posts: 30
Joined: 23 Oct 2014 19:24

Create a package to install and apply localization after OS installation

Postby vacnt » 02 Jan 2017 09:29

When Internet access is unavailable during OS installation, the localization step is skipped, it would be convenient to have a package that performs this step that users can run afterwards.

User avatar
ilu
Posts: 2654
Joined: 09 Oct 2013 12:45

Re: Create a package to install and apply localization after OS installation

Postby ilu » 18 Mar 2017 14:14

This would be nice-to-have, but for the time being you can localize the system with:

Code: Select all

sudo apt-get install console-data  # might already be installed
sudo dpkg-reconfigure locales
sudo dpkg-reconfigure tzdata
sudo dpkg-reconfigure keyboard-configuration
Afterwards you need to choose the right language in your desktop settings. I'll have to check where that's done.

User avatar
Arjen Balfoort
Site Admin
Posts: 9422
Joined: 26 Jan 2013 19:36
Location: Netherlands
Contact:

Re: Create a package to install and apply localization after OS installation

Postby Arjen Balfoort » 18 Mar 2017 16:12

I could add a script to solydxk-system: /usr/bin/localize

Code: Select all

#!/bin/bash

# Make sure console-data is installed
dpkg -l | grep -qw console-data || sudo apt-get install --assume-yes --quiet console-data

# Reconfigure
sudo dpkg-reconfigure locales
sudo dpkg-reconfigure tzdata
sudo dpkg-reconfigure keyboard-configuration

# Install additional packages for new locales
NEWLANGS=$(grep ^[a-z] /etc/locale.gen | grep -v en_US | cut -d'.' -f1)
for L in $NEWLANGS; do
  case "$L" in
    ja_JP)
      sudo apt-get install --assume-yes --quiet fonts-vlgothic fonts-takao xfonts-intl-japanese im-config fcitx-mozc
    ;;
    ko_KR)
      sudo apt-get install --assume-yes --quiet fonts-unfonts* im-config fcitx-hangul
    ;;
    zh_CN)
      sudo apt-get install --assume-yes --quiet fonts-wqy-microhei fonts-wqy-zenhei xfonts-wqy im-config fcitx-sunpinyin
    ;;
    zh_HK)
      sudo apt-get install --assume-yes --quiet fonts-wqy-microhei fonts-wqy-zenhei xfonts-wqy im-config fcitx-sunpinyin fcitx-table-cantonhk
    ;;
    zh_SG)
      sudo apt-get install --assume-yes --quiet fonts-wqy-microhei fonts-wqy-zenhei xfonts-wqy im-config fcitx-sunpinyin
    ;;
    zh_TW)
      sudo apt-get install --assume-yes --quiet libthai0 fonts-thai-tlwg xfonts-thai im-config fcitx-table-thai fcitx-sunpinyin
    ;;
  esac
  
  L=${L,,}
  BASELAN=${L:0:2}
  EXTLAN=${L:3:5}
  if [ "$LAN" == "$EXTLAN" ]; then EXTLAN=''; fi
  
  CHKLAN="$BASELAN$EXTLAN"
  if dpkg -l | grep -q ' kde-runtime '; then
    LAN=$BASELAN
    apt-cache -q show kde-l10n-$CHKLAN >/dev/null 2>&1 && LAN=$CHKLAN
    sudo apt-get install --assume-yes --quiet kde-l10n-$LAN
  fi
  if dpkg -l | grep -q ' calligra '; then
    LAN=$BASELAN
    apt-cache -q show calligra-l10n-$CHKLAN >/dev/null 2>&1 && LAN=$CHKLAN
    sudo apt-get install --assume-yes --quiet calligra-l10n-$LAN
  fi
  
  CHKLAN="$BASELAN-$EXTLAN"
  LAN=$BASELAN
  apt-cache -q show myspell-$CHKLAN >/dev/null 2>&1 && LAN=$CHKLAN
  sudo apt-get install --assume-yes --quiet myspell-$LAN

  if dpkg -l | grep -q ' firefox '; then
    LAN=$BASELAN
    apt-cache -q show firefox-l10n-$CHKLAN >/dev/null 2>&1 && LAN=$CHKLAN
    sudo apt-get install --assume-yes --quiet firefox-l10n-$LAN
  fi
  if dpkg -l | grep -q ' firefox-esr '; then
    LAN=$BASELAN
    apt-cache -q show firefox-esr-l10n-$CHKLAN >/dev/null 2>&1 && LAN=$CHKLAN
    sudo apt-get install --assume-yes --quiet firefox-esr-l10n-$LAN
  fi
  if dpkg -l | grep -q ' thunderbird '; then
    LAN=$BASELAN
    apt-cache -q show thunderbird-l10n-$CHKLAN >/dev/null 2>&1 && LAN=$CHKLAN
    sudo apt-get install --assume-yes --quiet thunderbird-l10n-$LAN
  fi
  if dpkg -l | grep -q ' libreoffice '; then
    LAN=$BASELAN
    apt-cache -q show libreoffice-l10n-$CHKLAN >/dev/null 2>&1 && LAN=$CHKLAN
    sudo apt-get install --assume-yes --quiet libreoffice-l10n-$LAN
    LAN=$BASELAN
    apt-cache -q show libreoffice-help-$CHKLAN >/dev/null 2>&1 && LAN=$CHKLAN
    sudo apt-get install --assume-yes --quiet libreoffice-help-$LAN
  fi
  if dpkg -l | grep -q ' icedove '; then
    LAN=$BASELAN
    apt-cache -q show icedove-l10n-$CHKLAN >/dev/null 2>&1 && LAN=$CHKLAN
    sudo apt-get install --assume-yes --quiet icedove-l10n-$LAN
  fi
  if dpkg -l | grep -q ' iceowl '; then
    LAN=$BASELAN
    apt-cache -q show iceowl-l10n-$CHKLAN >/dev/null 2>&1 && LAN=$CHKLAN
    sudo apt-get install --assume-yes --quiet iceowl-l10n-$LAN
  fi
  if dpkg -l | grep -q ' iceweasel '; then
    LAN=$BASELAN
    apt-cache -q show iceweasel-l10n-$CHKLAN >/dev/null 2>&1 && LAN=$CHKLAN
    sudo apt-get install --assume-yes --quiet iceweasel-l10n-$LAN
  fi

done

echo
echo "Reboot your system for the changes to take effect."
echo


SolydXK needs you!
Development | Testing | Translations

User avatar
ilu
Posts: 2654
Joined: 09 Oct 2013 12:45

Re: Create a package to install and apply localization after OS installation

Postby ilu » 18 Mar 2017 16:24

console-data should be included by default in all images. Without it, keyboard-configuration bugs out silently, leaving you without keyboard and mouse (at least on the RPi). You have to go through dmesg and totally misleading error messages to find the cause.

Arjen, you saw my SolydXRPi bug posting https://forums.solydxk.com/viewtopic.php?f=79&t=6815, didn't you?

User avatar
Arjen Balfoort
Site Admin
Posts: 9422
Joined: 26 Jan 2013 19:36
Location: Netherlands
Contact:

Re: Create a package to install and apply localization after OS installation

Postby Arjen Balfoort » 18 Mar 2017 16:37

Yes I did and have you tried the nightly yet?

Does it mean the localize script I mentioned is not needed?


SolydXK needs you!
Development | Testing | Translations

User avatar
ilu
Posts: 2654
Joined: 09 Oct 2013 12:45

Re: Create a package to install and apply localization after OS installation

Postby ilu » 18 Mar 2017 16:58

No, the script is nice-to-have. And the line with console-data has to stay cause of the old images. I just wanted to remind you, in case you hadn't noticed.
I will try the script with the nightly, just need to free up my sd card first.

User avatar
Arjen Balfoort
Site Admin
Posts: 9422
Joined: 26 Jan 2013 19:36
Location: Netherlands
Contact:

Re: Create a package to install and apply localization after OS installation

Postby Arjen Balfoort » 19 Mar 2017 09:18

I've added the script to solydxk-system and uploaded the package to testing: http://repository.solydxk.nl/pool/testi ... xk-system/

[EDIT]
I've updated the code for /usr/bin/localize here: viewtopic.php?p=64860#p64860


SolydXK needs you!
Development | Testing | Translations


Return to “Suggestions & ideas / Open Projects”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest