本文整理汇总了C++中QLocale::languageToString方法的典型用法代码示例。如果您正苦于以下问题:C++ QLocale::languageToString方法的具体用法?C++ QLocale::languageToString怎么用?C++ QLocale::languageToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLocale
的用法示例。
在下文中一共展示了QLocale::languageToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
AcceptLanguage::AcceptLanguage(QWidget* parent)
: QDialog(parent)
, ui(new Ui::AcceptLanguage)
{
ui->setupUi(this);
ui->listWidget->setLayoutDirection(Qt::LeftToRight);
Settings settings;
settings.beginGroup("Language");
QStringList langs = settings.value("acceptLanguage", defaultLanguage()).toStringList();
settings.endGroup();
foreach (const QString &code, langs) {
QString code_ = code;
QLocale loc = QLocale(code_.replace(QLatin1Char('-'), QLatin1Char('_')));
QString label;
if (loc.language() == QLocale::C) {
label = tr("Personal [%1]").arg(code);
}
else {
label = QString("%1/%2 [%3]").arg(loc.languageToString(loc.language()), loc.countryToString(loc.country()), code);
}
ui->listWidget->addItem(label);
}
示例2: QObject
QmlUtil::QmlUtil(QObject *parent) :
QObject(parent)
{
QLocale loc = QLocale::system();
QLOG_DEBUG() << "language is " << loc.languageToString(loc.language());
m_dateFormat = "dd.MM.yyyy";//loc.dateFormat(QLocale::ShortFormat);
m_timeFormat = "hh:mm"; //loc.timeFormat(QLocale::ShortFormat);
}
示例3: main
int main(int argc, char *argv[]) {
QDir dir(QDir::homePath());
dir.mkdir(Configuration::CacheDirectory);
qInstallMsgHandler(handleMessage);
QApplication app(argc, argv);
QLocale systemLocale = QLocale::system();
Services::initialize();
Configuration *config = Configuration::getInstance();
config->load();
QTranslator translator;
translator.load(QString(":/translations/qwit_") + (config->language == "system" ? systemLocale.name() : config->language));
app.installTranslator(&translator);
Configuration::TranslationsCodes.push_back("system");
Configuration::TranslationsCountries.push_back(systemLocale.name().mid(3, 2));
Configuration::TranslationsTitles.push_back(app.tr("System (%1, %2)").arg(systemLocale.languageToString(systemLocale.language())).arg(systemLocale.countryToString(systemLocale.country())));
QDir translationsDir(":/translations");
QStringList translationNames = translationsDir.entryList(QStringList("*.qm"), QDir::Files, QDir::Name);
QMutableStringListIterator i(translationNames);
while (i.hasNext()) {
i.next();
QString languageCode = i.value().mid(5, 5);
QLocale locale(languageCode);
Configuration::TranslationsCodes.push_back(languageCode);
Configuration::TranslationsCountries.push_back(languageCode.mid(3, 2));
Configuration::TranslationsTitles.push_back(QString("%1, %2").arg(systemLocale.languageToString(locale.language())).arg(systemLocale.countryToString(locale.country())));
}
MainWindow *mainWindow = MainWindow::getInstance();
if (!config->startMinimized) mainWindow->show();
return app.exec();
}
示例4: getCurrentLanguage
/**
* App::getCurrentLanguage()
*
* Retrieve the language name corresponding to the current locale.
*/
QString ApplicationUI::getCurrentLanguage() {
// TODO get language name from QLocale - we have now more languages
qDebug() << "OpenDataSpaceApp getCurrentLanguage: " << mCurrentLocale;
QLocale *loc = new QLocale(mCurrentLocale);
return loc->languageToString(loc->language());
}
示例5: loadBootData
void PBSystemTab::loadBootData()
{
//Trawl screens directory
QDir screens = QDir(PREFIX + "/share/pcbsd/splash-screens/");
if (! screens.exists())
{
QMessageBox::critical( 0, tr("File not found!"), PREFIX + "/share/pcbsd/splash-screens/ " + tr("doesn't exist!"), QMessageBox::Ok );
return;
}
screens.setFilter(QDir::Files);
QStringList screensList = screens.entryList();
QRegExp screenMatcher = QRegExp("^loading-screen-(([a-z]|[A-Z]|_)+)\\.pcx$");
QStringList langList = QStringList();
QLocale langResolver;
codeMap = QMap<QString, QString>();
bool customPresent = false;
for (QStringList::Iterator it = screensList.begin(); it != screensList.end(); it++)
{
int pos = screenMatcher.indexIn(*it);
if (pos > -1)
{
QString code = screenMatcher.cap(1);
if (code == "custom") { customPresent = true; }
else
{
QLocale lang(code);
QString langName = langResolver.languageToString(lang.language());
if ( langName.isEmpty() )
{
langName = "Splash Screen: " + code;
}
langList += langName;
codeMap[langName] = code;
}
}
}
//Populate select box
langList.sort();
splashSelect->addItems(langList);
int indexMod = 0;
if (customPresent)
{
codeMap[tr("Custom")] = "custom";
splashSelect->addItem(tr("Custom"), 0);
indexMod = 1;
}
//Load current, get info from registry - /PCBSD/splash-screen
QSettings settings;
QString selectedLang = settings.value("/PCBSD/splash-screen", langResolver.language()).toString();
if (selectedLang == "custom") { splashSelect->setCurrentIndex(0); }
else
{
//If we don't have a splash for the user's language, default to english
QLocale tlocale(selectedLang);
QString testLangName = langResolver.languageToString(tlocale.language());
if (codeMap[testLangName] == "") selectedLang = "en";
QLocale tlocale2(selectedLang);
selectedLang = langResolver.languageToString(tlocale2.language());
if ( selectedLang.isEmpty() )
{
selectedLang = "Splash Screen: " + selectedLang;
}
splashSelect->setCurrentIndex(langList.indexOf(selectedLang) + indexMod);
}
if ( checkValue("/boot/loader.conf", "splash_pcx_load=", "YES" ) )
showBootCheck->setChecked(TRUE);
if ( pcbsd::Utils::getConfFileValue(QString(PREFIX + "/share/pcbsd/xstartup/enable-ibus.sh"), QString("FORCEIBUS=") ) == QString("YES"))
checkForceIbus->setChecked(TRUE);
else
checkForceIbus->setChecked(FALSE);
}
示例6: main
int main(int argc, char *argv[])
{
/* // signals handling
for(int i=0; i<NSIG; i++)
signal(i, signalhandler);
*/
struct sigaction act;
#ifdef SA_RESTART
act.sa_flags = SA_RESTART;
#else
act.sa_flags = 0;
#endif
act.sa_handler = sigchld;
if(sigaction(SIGCHLD, &act, NULL) == -1)
perror("sigaction(SIGCLHD)");
act.sa_handler = sigpipe;
if(sigaction(SIGPIPE, &act, NULL) == -1)
perror("sigaction(SIGPIPE)");
act.sa_handler = sigusr1;
if(sigaction(SIGUSR1, &act, NULL) == -1)
perror("sigaction(SIGUSR1)");
QApplication a(argc, argv);
//a.setFont(QFont("helvetica", 12));
QTranslator tor( 0 );
// set the location where your .qm files are in load() below as the last parameter instead of "."
// for development, use "/" to use the english original as
// .qm files are stored in the base project directory.
QLocale localLang;
#ifdef xxLINUX
g_application_path = QString("/usr/share/piaf");
QDir dir("/usr/share/piaf");
#else
QDir dir(QApplication::applicationDirPath());
QString g_application_path = QApplication::applicationDirPath();
#endif
QString translationFile = QString("piaf_") +
localLang.languageToString(localLang.language()) +
QString(".qm");
fprintf(stderr, "Translation file='%s'\n", translationFile.ascii());
tor.load( translationFile,
dir.absolutePath() );
a.installTranslator( &tor );
WorkshopApp * workshop = new WorkshopApp();
a.setMainWidget(workshop);
workshop->show();
/*
if(argc>1)
workshop->openDocumentFile(argv[1]);
else
workshop->openDocumentFile();
*/
return a.exec();
}