/// \brief Create the manager and load the defaults variables
LanguagesManager::LanguagesManager()
{
	ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start");
	//load the overall instance
	resources=ResourcesManager::getInstance();
	options=OptionEngine::getInstance();
	plugins=PluginsManager::getInstance();
	//load the rest
	QStringList resourcesPaths=resources->getReadPath();
	int index=0;
	while(index<resourcesPaths.size())
	{
		QString composedTempPath=resourcesPaths.at(index)+"Languages"+QDir::separator();
		QDir LanguagesConfiguration(composedTempPath);
		if(LanguagesConfiguration.exists())
			languagePath<<composedTempPath;
		index++;
	}
	//load the plugins
	plugins->lockPluginListEdition();
	qRegisterMetaType<PluginsAvailable>("PluginsAvailable");
	connect(this,SIGNAL(previouslyPluginAdded(PluginsAvailable)),		this,SLOT(onePluginAdded(PluginsAvailable)),Qt::QueuedConnection);
	connect(plugins,SIGNAL(onePluginAdded(PluginsAvailable)),		this,	SLOT(onePluginAdded(PluginsAvailable)),Qt::QueuedConnection);
	connect(plugins,SIGNAL(onePluginWillBeRemoved(PluginsAvailable)),	this,	SLOT(onePluginWillBeRemoved(PluginsAvailable)),Qt::DirectConnection);
	connect(plugins,SIGNAL(pluginListingIsfinish()),			this,	SLOT(allPluginIsLoaded()),Qt::QueuedConnection);
	QList<PluginsAvailable> list=plugins->getPluginsByCategory(PluginType_Languages);
	foreach(PluginsAvailable currentPlugin,list)
		emit previouslyPluginAdded(currentPlugin);
	plugins->unlockPluginListEdition();
	//load the GUI option
	QList<QPair<QString, QVariant> > KeysList;
	KeysList.append(qMakePair(QString("Language"),QVariant("en")));
	KeysList.append(qMakePair(QString("Language_autodetect"),QVariant(true)));
	options->addOptionGroup("Language",KeysList);
//	connect(this,	SIGNAL(newLanguageLoaded(QString)),			plugins,SLOT(refreshPluginList(QString)));
//	connect(this,	SIGNAL(newLanguageLoaded(QString)),			this,SLOT(retranslateTheUI()));
	connect(options,SIGNAL(newOptionValue(QString,QString,QVariant)),	this,	SLOT(newOptionValue(QString)),Qt::QueuedConnection);
	connect(this,	SIGNAL(newLanguageLoaded(QString)),			plugins,SIGNAL(newLanguageLoaded()),Qt::QueuedConnection);
}
/// \brief Create the manager and load the defaults variables
LanguagesManager::LanguagesManager()
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
    //load the rest
    QStringList resourcesPaths=ResourcesManager::resourcesManager->getReadPath();
    int index=0;
    while(index<resourcesPaths.size())
    {
        QString composedTempPath=resourcesPaths.at(index)+"Languages"+QDir::separator();
        QDir LanguagesConfiguration(composedTempPath);
        if(LanguagesConfiguration.exists())
            languagePath<<composedTempPath;
        index++;
    }
    //load the plugins
    PluginsManager::pluginsManager->lockPluginListEdition();
    connect(this,&LanguagesManager::previouslyPluginAdded,		this,	&LanguagesManager::onePluginAdded,Qt::QueuedConnection);
    connect(PluginsManager::pluginsManager,&PluginsManager::onePluginAdded,this,	&LanguagesManager::onePluginAdded,Qt::QueuedConnection);
    #ifndef ULTRACOPIER_PLUGIN_ALL_IN_ONE
    connect(PluginsManager::pluginsManager,&PluginsManager::onePluginWillBeRemoved,	this,	&LanguagesManager::onePluginWillBeRemoved,Qt::DirectConnection);
    #endif
    connect(PluginsManager::pluginsManager,&PluginsManager::pluginListingIsfinish,		this,	&LanguagesManager::allPluginIsLoaded,Qt::QueuedConnection);
    QList<PluginsAvailable> list=PluginsManager::pluginsManager->getPluginsByCategory(PluginType_Languages);
    foreach(PluginsAvailable currentPlugin,list)
        emit previouslyPluginAdded(currentPlugin);
    PluginsManager::pluginsManager->unlockPluginListEdition();
    //load the GUI option
    QList<QPair<QString, QVariant> > KeysList;
    KeysList.append(qMakePair(QString("Language"),QVariant("en")));
    KeysList.append(qMakePair(QString("Language_force"),QVariant(false)));
    OptionEngine::optionEngine->addOptionGroup("Language",KeysList);
//	connect(this,	&LanguagesManager::newLanguageLoaded,			plugins,&PluginsManager::refreshPluginList);
//	connect(this,	&LanguagesManager::newLanguageLoaded,			this,&LanguagesManager::retranslateTheUI);
    connect(OptionEngine::optionEngine,&OptionEngine::newOptionValue,				this,	&LanguagesManager::newOptionValue,Qt::QueuedConnection);
    connect(this,	&LanguagesManager::newLanguageLoaded,			PluginsManager::pluginsManager,&PluginsManager::newLanguageLoaded,Qt::QueuedConnection);
}