mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-23 02:15:44 -05:00
[libcalamares] Special-case startup for some languages
This commit is contained in:
parent
0bb93f4a97
commit
5307976179
3 changed files with 36 additions and 3 deletions
|
@ -54,13 +54,39 @@ specialCase( const CalamaresUtils::Locale::Translation::Id& locale )
|
|||
return { nullptr, nullptr };
|
||||
}
|
||||
|
||||
static QString
|
||||
specialCaseSystemLanguage()
|
||||
{
|
||||
const QByteArray lang_p = qgetenv( "LANG" );
|
||||
if ( lang_p.isEmpty() )
|
||||
return {};
|
||||
QString lang = QString::fromLatin1( lang_p );
|
||||
if ( lang.isEmpty() )
|
||||
return {};
|
||||
|
||||
const QString serbian_latin = QStringLiteral( "sr@latin" );
|
||||
const QString serbian_latin_variant = QStringLiteral( "sr@latn" );
|
||||
if ( ( lang == serbian_latin ) || ( lang == serbian_latin_variant ) )
|
||||
{
|
||||
return serbian_latin;
|
||||
}
|
||||
|
||||
const QString valencian = QStringLiteral( "ca@valencia" );
|
||||
if ( lang == valencian )
|
||||
{
|
||||
return valencian;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
namespace Locale
|
||||
{
|
||||
|
||||
Translation::Translation( QObject* parent )
|
||||
: Translation( { QString() }, LabelFormat::IfNeededWithCountry, parent )
|
||||
: Translation( { specialCaseSystemLanguage() }, LabelFormat::IfNeededWithCountry, parent )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#ifndef LOCALE_TRANSLATION_H
|
||||
#define LOCALE_TRANSLATION_H
|
||||
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <QLocale>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
@ -110,6 +112,12 @@ private:
|
|||
QString m_englishLabel;
|
||||
};
|
||||
|
||||
static inline QDebug&
|
||||
operator<<( QDebug& s, const Translation::Id& id )
|
||||
{
|
||||
return s << id.name;
|
||||
}
|
||||
|
||||
} // namespace Locale
|
||||
} // namespace CalamaresUtils
|
||||
|
||||
|
|
|
@ -184,8 +184,7 @@ installTranslator( const CalamaresUtils::Locale::Translation::Id& locale, const
|
|||
void
|
||||
installTranslator()
|
||||
{
|
||||
// Just wrap it up like an Id
|
||||
installTranslator( { QLocale::system().name() }, QString() );
|
||||
installTranslator( CalamaresUtils::Locale::Translation().id(), QString() );
|
||||
}
|
||||
|
||||
CalamaresUtils::Locale::Translation::Id
|
||||
|
|
Loading…
Add table
Reference in a new issue