コード例 #1
0
/*
 * Initialize translations and add default language
 */
bool lamexp_translation_init(void)
{
	QWriteLocker writeLockTranslations(&g_lamexp_translation.lock);

	if((!g_lamexp_translation.files) && (!g_lamexp_translation.names))
	{
		g_lamexp_translation.files = new QMap<QString, QString>();
		g_lamexp_translation.names = new QMap<QString, QString>();
		g_lamexp_translation.files->insert(LAMEXP_DEFAULT_LANGID, "");
		g_lamexp_translation.names->insert(LAMEXP_DEFAULT_LANGID, "English");
		return true;
	}
	else
	{
		qWarning("[lamexp_translation_init] Error: Already initialized!");
		return false;
	}
}
コード例 #2
0
/*
 * Register a new translation
 */
bool lamexp_translation_register(const QString &langId, const QString &qmFile, const QString &langName, unsigned int &systemId, unsigned int &country)
{
	QWriteLocker writeLockTranslations(&g_lamexp_translation.lock);

	if(qmFile.isEmpty() || langName.isEmpty() || systemId < 1)
	{
		return false;
	}

	if(!g_lamexp_translation.files) g_lamexp_translation.files = new QMap<QString, QString>();
	if(!g_lamexp_translation.names) g_lamexp_translation.names = new QMap<QString, QString>();
	if(!g_lamexp_translation.sysid) g_lamexp_translation.sysid = new QMap<QString, unsigned int>();
	if(!g_lamexp_translation.cntry) g_lamexp_translation.cntry = new QMap<QString, unsigned int>();

	g_lamexp_translation.files->insert(langId, qmFile);
	g_lamexp_translation.names->insert(langId, langName);
	g_lamexp_translation.sysid->insert(langId, systemId);
	g_lamexp_translation.cntry->insert(langId, country);

	return true;
}
コード例 #3
0
ファイル: Translation.cpp プロジェクト: lordmulder/MUtilities
bool MUtils::Translation::insert(const QString &langId, const QString &qmFile, const QString &langName, const quint32 &systemId, const quint32 &country)
{
	QWriteLocker writeLockTranslations(&g_translation_lock);

	const QString key = langId.simplified().toLower();
	if(key.isEmpty() || qmFile.isEmpty() || langName.isEmpty() || (systemId < 1))
	{
		return false;
	}

	if(g_translation_data.isNull())
	{
		g_translation_data.reset(new translation_store_t());
	}

	if(g_translation_data->contains(key))
	{
		qWarning("Translation store already contains entry for '%s', going to replace!", MUTILS_UTF8(key));
	}

	g_translation_data->insert(key, MAKE_ENTRY(langName, qmFile, systemId, country));
	return true;
}