Add some special-casing for different quirks in langpack names.

pull/2/head
Simon Quigley 1 year ago
parent 383aecd4cf
commit d402c2e8d1

@ -3,10 +3,27 @@
LANGUAGE_CODE=$1 LANGUAGE_CODE=$1
COUNTRY_CODE=$2 COUNTRY_CODE=$2
LOCALE="${LANGUAGE_CODE}_${COUNTRY_CODE}.UTF-8" LOCALE="${LANGUAGE_CODE}_${COUNTRY_CODE}.UTF-8"
ONLY_LXQT=$3 LIBREOFFICE_CODE=$3
ONLY_LXQT=$4
# Special handling for language packs for Chinese
if [[ "$LANGUAGE_CODE" == "zh" ]]; then
if [[ "$COUNTRY_CODE" == "CN" || "$COUNTRY_CODE" == "SG" || "$COUNTRY_CODE" == "MY" ]]; then
LANG_PACK_SUFFIX="zh-hans"
else
LANG_PACK_SUFFIX="zh-hant"
fi
else
LANG_PACK_SUFFIX="$LANGUAGE_CODE"
fi
if [ -z "$ONLY_LXQT" ]; then if [ -z "$ONLY_LXQT" ]; then
apt-get -y install language-pack-gnome-$LANGUAGE_CODE language-pack-kde-$LANGUAGE_CODE apt-get -y install language-pack-gnome-$LANG_PACK_SUFFIX language-pack-kde-$LANG_PACK_SUFFIX
# Install LibreOffice language pack only if LIBREOFFICE_CODE is provided
# and it's not English without a specific variant
if [[ "$LANGUAGE_CODE" != "en" ]] || [[ "$LANGUAGE_CODE" == "en" && ( "$COUNTRY_CODE" == "GB" || "$COUNTRY_CODE" == "ZA" ) ]]; then
apt-get -y install libreoffice-l10n-$LIBREOFFICE_CODE
fi
fi fi
update-locale LANGUAGE=$LOCALE LANG=$LOCALE LC_ALL=$LOCALE update-locale LANGUAGE=$LOCALE LANG=$LOCALE LC_ALL=$LOCALE

@ -443,12 +443,23 @@ void InstallerPrompt::onLanguageConfirm() {
ui->changingLanguageLabel->setText(tr("Changing language...")); ui->changingLanguageLabel->setText(tr("Changing language..."));
} }
// Some of the LibreOffice language packs need special-casing, do that here
QString libreOfficeLang;
if (localeParts[0] == "zh") {
libreOfficeLang = (countryCode == "CN" || countryCode == "SG" || countryCode == "MY") ? "zh-cn" : "zh-tw";
} else {
static const QMap<QString, QString> localeMap = {
{"en_GB", "en-gb"}, {"en_ZA", "en-za"}, {"pa_IN", "pa-in"}, {"pt_BR", "pt-br"}
};
libreOfficeLang = localeMap.value(localeParts.join('_'), languageCode);
}
// Construct the command to run the script with parameters // Construct the command to run the script with parameters
QProcess *process = new QProcess(this); QProcess *process = new QProcess(this);
QStringList arguments; QStringList arguments;
process->setProgram("/usr/libexec/change-system-language"); process->setProgram("/usr/libexec/change-system-language");
arguments << languageCode << countryCode; arguments << languageCode << countryCode << libreOfficeLang;
if (only_lxqt) arguments << "1"; if (only_lxqt) arguments << "1";
process->setArguments(arguments); process->setArguments(arguments);

Loading…
Cancel
Save