[libcalamares] Special-case startup for some languages
This commit is contained in:
parent
0bb93f4a97
commit
5307976179
@ -54,13 +54,39 @@ specialCase( const CalamaresUtils::Locale::Translation::Id& locale )
|
|||||||
return { nullptr, nullptr };
|
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 CalamaresUtils
|
||||||
{
|
{
|
||||||
namespace Locale
|
namespace Locale
|
||||||
{
|
{
|
||||||
|
|
||||||
Translation::Translation( QObject* parent )
|
Translation::Translation( QObject* parent )
|
||||||
: Translation( { QString() }, LabelFormat::IfNeededWithCountry, parent )
|
: Translation( { specialCaseSystemLanguage() }, LabelFormat::IfNeededWithCountry, parent )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#ifndef LOCALE_TRANSLATION_H
|
#ifndef LOCALE_TRANSLATION_H
|
||||||
#define LOCALE_TRANSLATION_H
|
#define LOCALE_TRANSLATION_H
|
||||||
|
|
||||||
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -110,6 +112,12 @@ private:
|
|||||||
QString m_englishLabel;
|
QString m_englishLabel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline QDebug&
|
||||||
|
operator<<( QDebug& s, const Translation::Id& id )
|
||||||
|
{
|
||||||
|
return s << id.name;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Locale
|
} // namespace Locale
|
||||||
} // namespace CalamaresUtils
|
} // namespace CalamaresUtils
|
||||||
|
|
||||||
|
@ -184,8 +184,7 @@ installTranslator( const CalamaresUtils::Locale::Translation::Id& locale, const
|
|||||||
void
|
void
|
||||||
installTranslator()
|
installTranslator()
|
||||||
{
|
{
|
||||||
// Just wrap it up like an Id
|
installTranslator( CalamaresUtils::Locale::Translation().id(), QString() );
|
||||||
installTranslator( { QLocale::system().name() }, QString() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CalamaresUtils::Locale::Translation::Id
|
CalamaresUtils::Locale::Translation::Id
|
||||||
|
Loading…
Reference in New Issue
Block a user