RazorAutostartEntry => LxQt::AutostartEntry
[lxde/liblxqt.git] / libtranslate.h
CommitLineData
4ef6cee9 1/* BEGIN_COMMON_COPYRIGHT_HEADER
c4af778e 2 * (c)LGPL2+
4ef6cee9 3 *
4 * Razor - a lightweight, Qt based, desktop toolset
5 * http://razor-qt.org
6 *
7 * Copyright: 2011 Razor team
8 * Authors:
626f1f31 9 * Alexander Sokoloff <sokoloff.a@gmail.com>
4ef6cee9 10 *
11 * This program or library is free software; you can redistribute it
12 * and/or modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
c4af778e 14 * version 2.1 of the License, or (at your option) any later version.
4ef6cee9 15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20
21 * You should have received a copy of the GNU Lesser General
22 * Public License along with this library; if not, write to the
23 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301 USA
25 *
26 * END_COMMON_COPYRIGHT_HEADER */
27
28#ifndef LIBTRANSLATE_H
29#define LIBTRANSLATE_H
30
31#include <QtCore/QTranslator>
32#include <QtCore/QCoreApplication>
33#include <QtCore/QLocale>
40fa5922 34#include <QtCore/QSet>
7090400c
AS
35namespace LxQt
36{
4ef6cee9 37
38inline void libTranslate(const QString &name)
39{
40fa5922
AM
40 static QSet<QString> loadedLibs;
41
42 if (loadedLibs.contains(name))
4ef6cee9 43 return;
44
40fa5922
AM
45 loadedLibs.insert(name);
46
4ef6cee9 47 QString locale = QLocale::system().name();
48 QTranslator *translator = new QTranslator(qApp);
49 translator->load(QString("%1/%2_%3.qm").arg(TRANSLATIONS_DIR, name, locale));
50
51 QCoreApplication::installTranslator(translator);
4ef6cee9 52}
53
7090400c 54} // namecpase LxQt
4ef6cee9 55#endif // LIBTRANSLATE_H