Exemple #1
0
/* The meego desktop files are using the qt translation system to get
 * localized strings using catalog and string ids. QApplication and
 * MLocale are needed for loading the translation catalogs. The
 * returned string is a multi-string one which has parts of different
 * length separated by '\x9C' unicode escape sequences.
 *
 * FIXME: This is insane, try to get rid of at least some of the extra
 * layers here.
 */
gchar *
tracker_meego_translate (const gchar *catalogue,
                         const gchar *id)
{
	/* Get the system default locale */
	MLocale locale;

	/* Load the catalog from disk if not already there */
	if(!locale.isInstalledTrCatalog (catalogue)) {
		locale.installTrCatalog (catalogue);
		MLocale::setDefault (locale);
	}

	gchar *ret = g_strdup (qtTrId (id).toUtf8 ().data ());

	/* We only want the first string of the multi-string, so if
	 * the separator character is found (encoded as C2:9C in UTF-8),
	 * we just end the string in that point */
	gchar *next_string = strstr (ret, "\xC2\x9C");
	if (next_string) {
		*next_string = '\0';
	}

	return ret;
}
void
ResetWidget::clearActivated ()
{
    MDialog   *dialog;
    MLocale    locale;
    QString    question;

    if (m_ResetBusinessLogic->isUsbConnected ()) {
        showMassStorageWarning ();
        return;
    }

    //% "Clear all user data and restore original settings?"
    question = qtTrId("qtn_rset_clear_query").arg(locale.formatNumber(15));
    question.replace ("\\n", "<br>");
    question.replace ("\n", "<br>");

    //% "Clear all data?"
    dialog = new MMessageBox (qtTrId ("qtn_rset_clear_query_title"),
                              question, M::YesButton | M::NoButton);
    connect (dialog, SIGNAL (accepted ()), SLOT (clearConfirmed ()));
    connect (dialog, SIGNAL (rejected ()), SLOT (operationCancelled ()));

    dialog->appear (MApplication::instance ()->activeWindow (),
                    MSceneWindow::DestroyWhenDone);
}
Exemple #3
0
/*
 * MeeGo general functions...
 */
gchar *
tracker_meego_get_locale (void)
{
	/* Get the system default locale */
	MLocale locale;

	return g_strdup (locale.name ().toAscii ().data ());
}
ServiceHelper::ServiceHelper(Accounts::Service service, QObject *parent)
    : QObject(parent),
    d_ptr(new ServiceHelperPrivate(service))
{
    Q_D(ServiceHelper);
    QString catalog = d->service.trCatalog();
    if (!catalog.isEmpty()) {
        MLocale locale;
        locale.installTrCatalog(catalog);
        MLocale::setDefault(locale);
    }
}
void System::loadLocales () {

    MLocale locale;
    // Translation path needs to be added translation to work with
    // non-meegotouch apps. We don't know if the translation path has been
    // added before calling this library, hence adding it again
    MLocale::addTranslationPath ("/usr/share/l10n/meegotouch");
    locale.installTrCatalog ("common");
    // Install actuall application catalog
    locale.installTrCatalog ("transfer");
    // Install application catalog (engineering english)
    locale.installTrCatalog ("libwebupload");
    MLocale::setDefault (locale);
}
void TestBirthdayPlugin::testLocaleChange()
{
    MGConfItem store(QLatin1String("/meegotouch/i18n/language"));
    store.set(QLatin1String("en"));

    // Leave the time to react to locale change
    loopWait(1000);

    // Use the C locale so it can be changed to a different locale later.
    MLocale locale;
    QVERIFY2(locale.isValid(), "Invalid locale");

    if (not locale.isInstalledTrCatalog(QLatin1String("calendar"))) {
        locale.installTrCatalog(QLatin1String("calendar"));
    }

    locale.connectSettings();
    MLocale::setDefault(locale);

    // Open calendar database, which should have been created by the birthday plugin.
    mKCal::ExtendedCalendar::Ptr calendar =
        mKCal::ExtendedCalendar::Ptr(new mKCal::ExtendedCalendar(KDateTime::Spec::LocalZone()));
    mKCal::ExtendedStorage::Ptr storage =
        mKCal::ExtendedCalendar::defaultStorage(calendar);
    storage->open();
    QVERIFY2(not storage->notebook(calNotebookId).isNull(), "No calendar database found");

    // Check if locale name for calendar matches calendar name.
    //QVERIFY2(locale.isInstalledTrCatalog(QLatin1String("calendar")), "Calendar locale catalog not installed");
    const QString cLocaleCalendarName = qtTrId("qtn_caln_birthdays");
    QCOMPARE(storage->notebook(calNotebookId)->name(), cLocaleCalendarName);

    // Change locale and check name again.
    store.set(QLatin1String("fi"));

    loopWait(calendarTimeout);

    const QString finnishLocaleCalendarName = qtTrId("qtn_caln_birthdays");

    QVERIFY2(storage->notebook(calNotebookId)->name() != cLocaleCalendarName, "Calendar name was not updated on locale change");
    QCOMPARE(storage->notebook(calNotebookId)->name(), finnishLocaleCalendarName);

    // Close the calendar.
    QVERIFY2(storage->close(), "Error closing the calendar");
}
void MAppletSettings::init(const QString &metaDataFileName, const QString &appletId)
{
    Q_D(MAppletSettings);
    QString appletBaseName = QFileInfo(metaDataFileName).baseName();
    QFileInfo fileInfo(QDir(QString(APPLET_SETTINGS_DIR)), appletBaseName);
    QString settingsFileStub = fileInfo.absoluteFilePath();

    d->instanceSettingsFileName = settingsFileStub + "-instance.xml";
    d->globalSettingsFileName = settingsFileStub + "-global.xml";

    d->instanceGConfPrefix = QString("/apps/") + appletId;
    d->globalGConfPrefix = QString("/apps/") + appletBaseName;

    // Load the applet's translation catalog for translating settings titles
    MAppletMetaData metaData(metaDataFileName);
    MLocale locale;
    locale.installTrCatalog(metaData.resourceIdentifier());
    MLocale::setDefault(locale);
}
Exemple #8
0
QString MStringSearchPrivate::searchCollatorLocaleName(const QString &pattern, const MLocale &locale) const
{
    QString categoryCollateName = locale.categoryName(MLocale::MLcCollate);
    if(!categoryCollateName.startsWith("zh")) {
        return categoryCollateName;
    }
    else {
        QString categoryCollateCountry
            = locale.categoryCountry(MLocale::MLcCollate);
        if((locale.collation() == MLocale::PinyinCollation
            ||
            ((categoryCollateCountry == "CN"
              || categoryCollateCountry == "SG")
             && locale.collation() == MLocale::DefaultCollation))
           && !containsHani(pattern))
            return QString("zh_CN@collation=pinyinsearch");
        else
            return categoryCollateName;
    }
}
/*!
 * Updates the label that shows the auto PSM slider value or shows the 'off'
 * string when the auto power save mode is disabled.
 */
void
SliderContainer::updateSliderValueLabel (int index)
{
    /*
     * We want to show something, but this should never happen.
     */
    if (index < 0 || index >= m_SliderValues.size())
        index = 0;

    if (index >= 0 && index < m_SliderValues.size()) {
        MLocale locale;
        QString theString = locale.formatPercent(
                m_SliderValues[index].toDouble() / 100.0, 0);

        /*
         * This is what the UI spec uses...
         * m_PSMSlider->setHandleLabel(
         *        QString ("%L1%").arg(m_SliderValues[index]));
         */
        m_PsmValueLabel->setText (theString);
        m_PSMSlider->setHandleLabel(theString);
    }
}
Exemple #10
0
M_EXPORT int main (int argc, char **argv) {

    bool run_standalone = true;
    
    QCoreApplication::setApplicationName (QLatin1String ("Share UI"));
    QCoreApplication::setOrganizationName (QLatin1String ("MeeGo"));    
    
    // Let's use custom logging
    Logger logger;    

    // Use dynamic memory control to make sure free is successfull before we
    // print out bye message.
    MApplication * app = MComponentCache::mApplication (argc, argv);

    // Load the translation catalog. The engineering english catalog is per
    // application/package, and gets loaded automatically. In the device, there
    // will be only one translation catalog for share-ui, webupload-engine and
    // transfer-ui, and we need to explicitly load it
    MLocale locale;
    locale.installTrCatalog ("transfer");
    MLocale::setDefault (locale);

    Service * service = new Service();

    for(int i = 1; i < argc; i++) {
        if (strcmp(argv[i], "--service") == 0) {
            run_standalone = false;
        } else if (strcmp(argv[i], "--help") == 0) {
            std::cout << "Share UI command line usage is" << std::endl;
            std::cout << "\tshare-ui <file list>" << std::endl;
            exit(0);
        }
    }

    if (run_standalone == true) {
        QStringList itemList;

        for (int i = 1; i < argc; i++) {
            if(argv[i][0] == '-') {
                // This is probably some kind of argument, like -software
                continue;
            }
            
            QString input = argv[i];
            
            if (input.startsWith ("data:") == true) {
                qDebug() << "Received data URI" << input;
                itemList << input;
            } else {
                QFileInfo fileInfo (input);
                QString fileUri = fileInfo.canonicalFilePath();
                if (fileUri.isEmpty ()) {
                    qDebug() << "Received Tracker IRI (?)" << input;
                    itemList << input;
                } else {
                    fileUri.prepend("file://");
                    qDebug() << "Received file path uri" << fileUri;
                    itemList << fileUri;
                }
            }
        }

        service->share (itemList);
        
    } else {

        new ShareUiInterfaceAdaptor (service);

        QDBusConnection connection = QDBusConnection::sessionBus();
        bool retA = connection.registerService("com.nokia.ShareUi");
        bool retB = connection.registerObject("/", service);
        qDebug() << "Setup dbus connection" << retA << retB;
    }
    
    int mainRes = app->exec();  
    qDebug() << "app returned" << mainRes;
    
    delete service;
    delete app;
    
    qDebug() << "Clean shutdown of Share UI application";
    return mainRes;
}
void Sysuid::loadTranslations()
{
    MLocale locale;

    // Install real translations
    locale.installTrCatalog("usb");
    locale.installTrCatalog("reset");
    locale.installTrCatalog("energy");
    locale.installTrCatalog("shutdown");
    locale.installTrCatalog("profiles");
    locale.installTrCatalog("screenlock");
    locale.installTrCatalog("status");
    locale.installTrCatalog("notification");
    locale.installTrCatalog("connectivity");
    locale.installTrCatalog("volume");
    locale.installTrCatalog("memory-usage");
    locale.installTrCatalog("cellular-adaptation");

    // and the engineering english ones
    locale.installTrCatalog("systemui");

    MLocale::setDefault(locale);
}