void pTranslationDialog::on_twLocales_itemSelectionChanged() { if ( mTranslationManager ) { mTranslationManager->setCurrentLocale( selectedLocale() ); mTranslationManager->reloadTranslations(); setLocale( selectedLocale() ); } }
QString LocaleManager::unitForLocale(const QString &locale) { QString selectedLocale(locale); for (int i = 0; i < m_localeTable.size(); ++i) { if (m_localeTable[i].m_locale==selectedLocale) return m_localeTable[i].m_unit; } //qDebug()<<"No definition for locale: "<<selectedLocale; //No, we don't translate these, they are internal use that don't get to the GUI if (m_sysLocale.measurementSystem()==0) return "mm"; else return "in"; qFatal("Unit not found in LocaleManager"); return ""; }
void pTranslationDialog::on_tbReload_clicked() { // reload translations if needed if ( mTranslationManager && mTranslationManager->availableLocales().isEmpty() ) { mTranslationManager->reloadTranslations(); } // keep current locale const QString currentLocale = selectedLocale(); // clear items ui->twLocales->clear(); mRootItems.clear(); // create new ones if ( mTranslationManager ) { foreach ( const QLocale& _locale, mTranslationManager->availableQLocales() ) { const QLocale locale = _locale.language() == QLocale::C ? QLocale( QLocale::English ) : _locale; QTreeWidgetItem* rootItem = this->rootItem( QLocale( locale.language() ) ); if ( rootItem->data( 0, Qt::UserRole ).toString() == locale.name() ) { continue; } rootItem->addChild( newItem( locale ) ); } } // sort items ui->twLocales->sortByColumn( 0, Qt::AscendingOrder ); // restore locale QAbstractItemModel* model = ui->twLocales->model(); QModelIndex index = model->match( model->index( 0, 0 ), Qt::UserRole, currentLocale, 1, Qt::MatchFixedString | Qt::MatchWrap ).value( 0 ); if ( !index.isValid() ) { index = model->match( model->index( 0, 0 ), Qt::UserRole, currentLocale, 1, Qt::MatchStartsWith | Qt::MatchWrap ).value( 0 ); } ui->twLocales->setCurrentIndex( index ); }
void LocaleManager::printSelectedForLocale(const QString& locale) { QString selectedLocale(locale); for (int i = 0; i < m_localeTable.size(); ++i) { if (m_localeTable[i].m_locale==selectedLocale) { qDebug()<<m_localeTable[i].m_locale.leftJustified(6) << ": " << m_localeTable[i].m_unit << ": " << m_localeTable[i].m_pageSize; return; } } qDebug()<<"No definition for locale: "<<selectedLocale; selectedLocale="default"; for (int i = 0; i < m_localeTable.size(); ++i) { if (m_localeTable[i].m_locale==selectedLocale) { qDebug()<<m_localeTable[i].m_locale.leftJustified(6) << ": " << m_localeTable[i].m_unit << ": " << m_localeTable[i].m_pageSize; return; } } }