Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Translations.h « mumble « src - github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2a0b8f3d7b20543a357cb65080b70472088b0b04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2021 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#ifndef MUMBLE_MUMBLE_TRANSLATIONS_H_
#define MUMBLE_MUMBLE_TRANSLATIONS_H_

#include <QStringList>

class QApplication;
class QLocale;
class QTranslator;

namespace Mumble {
namespace Translations {

	/**
	 * A lifetime guard for translators. Basically a smart-pointer for an ensemble of translators
	 */
	struct LifetimeGuard {
		QTranslator *m_bundledTranslator = nullptr;
		QTranslator *m_overwriteTranslator = nullptr;
		QTranslator *m_qtTranslator = nullptr;

		LifetimeGuard() = default;
		LifetimeGuard(LifetimeGuard &&old);
		LifetimeGuard(const LifetimeGuard &) = delete;
		~LifetimeGuard();
	};

	QStringList getDefaultTranslationDirectories();

	QStringList getTranslationDirectories(const QApplication &app, const QStringList &extraDirectories);

	/**
	 * Installs translators for the given locale to the given application. If extraDirectories are provided,
	 * they will be used for the overwrite translator.
	 *
	 * @returns The lifetime guard of the created translators. This object must not be destroyed before
	 *   the given application has terminated.
	 */
	LifetimeGuard installTranslators(const QLocale &locale, QApplication &app, const QStringList &extraDirectories);

}; // namespace Translations
}; // namespace Mumble

#endif // MUMBLE_MUMBLE_TRANSLATIONS_H_