view include/gui/locale.h @ 109:79714c95a145

*: add translation files and locale files I forgot to add these in the last commit :p also now you have to ask cmake to update the translations because before the ts files were not tracked (obviously)
author Paper <mrpapersonic@gmail.com>
date Mon, 06 Nov 2023 01:51:44 -0500
parents
children 39521c47c7a3
line wrap: on
line source

#ifndef __gui__locale_h
#define __gui__locale_h

#include <QLocale>
#include <QTranslator>
#include <vector>
#include <string>
#include <memory>

namespace Locale {

std::string GetLocaleFullName(const QLocale& locale);

class Locale {
public:
	Locale();
	Locale(const std::string& name);
	QLocale GetLocale();
	std::vector<QLocale> GetAvailableLocales();
	void RefreshAvailableLocales(); // why would this ever be called?
	bool IsLocaleAvailable(const QLocale& locale);
	bool SetActiveLocale(const QLocale& locale);

private:
	bool SwitchTranslator(QTranslator& translator, const QString& name);

	QTranslator _translator;
	QTranslator _translator_qt;
	QLocale _locale;
	std::vector<QLocale> _available_translations = {};
};

}

#endif // __gui__locale_h