BibleTime
btlocalemgr.cpp
Go to the documentation of this file.
1/*********
2*
3* In the name of the Father, and of the Son, and of the Holy Spirit.
4*
5* This file is part of BibleTime's source code, https://bibletime.info/
6*
7* Copyright 1999-2026 by the BibleTime developers.
8* The BibleTime source code is licensed under the GNU General Public License
9* version 2.0.
10*
11**********/
12
13#include "btlocalemgr.h"
14
15#include <QByteArray>
16#include "../../util/btassert.h"
17
18// Sword includes:
19#ifdef __GNUC__
20#pragma GCC diagnostic push
21#pragma GCC diagnostic ignored "-Wextra-semi"
22#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
23#endif
24#include <localemgr.h>
25#ifdef __GNUC__
26#pragma GCC diagnostic pop
27#endif
28
29namespace {
30
31struct BtLocaleMgrImpl final: public sword::LocaleMgr {
32
33 friend sword::LocaleMap const & ::BtLocaleMgr::internalSwordLocales();
34
35};
36
38 auto * btLocaleMgr =
39 dynamic_cast<BtLocaleMgrImpl *>(
40 sword::LocaleMgr::getSystemLocaleMgr());
41 if (!btLocaleMgr) {
42 /* Beware that sword::StringMgr::setSystemStringMgr() also replaces the
43 Sword system locale manager with new sword::LocaleMgr(). */
44 btLocaleMgr = new BtLocaleMgrImpl();
45 sword::LocaleMgr::setSystemLocaleMgr(btLocaleMgr);
46 }
47 return *btLocaleMgr;
48}
49
50} // anonymous namespace
51
52auto BtLocaleMgr::internalSwordLocales() -> sword::LocaleMap const & {
53 auto const & btLocaleMgr = btLocaleMgrInstance();
54 BT_ASSERT(btLocaleMgr.locales);
55 return *btLocaleMgr.locales;
56}
57
59{ return btLocaleMgrInstance().getLocale("locales"); }
60
62{ return btLocaleMgrInstance().getDefaultLocaleName(); }
63
64void BtLocaleMgr::setDefaultLocaleName(QString const & localeName) {
65 static_cast<sword::LocaleMgr &>(btLocaleMgrInstance()).setDefaultLocaleName(
66 localeName.toUtf8().constData());
67}
#define BT_ASSERT(...)
Definition btassert.h:17
QString defaultLocaleName()
sword::SWLocale * localeTranslator()
std::map< sword::SWBuf, sword::SWLocale * > const & internalSwordLocales()
void setDefaultLocaleName(QString const &localeName)
BtLocaleMgrImpl & btLocaleMgrInstance()