forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrings.h
55 lines (40 loc) · 1.34 KB
/
strings.h
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
49
50
51
52
53
54
55
// Aseprite
// Copyright (C) 2016-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifndef APP_I18N_STRINGS_INCLUDED
#define APP_I18N_STRINGS_INCLUDED
#pragma once
#include <set>
#include <string>
#include <unordered_map>
#include "obs/signal.h"
#include "strings.ini.h"
namespace app {
class Preferences;
class Extensions;
// Singleton class to load and access "strings/en.ini" file.
class Strings : public app::gen::Strings<app::Strings> {
public:
static void createInstance(Preferences& pref,
Extensions& exts);
static Strings* instance();
const std::string& translate(const char* id) const;
std::set<std::string> availableLanguages() const;
std::string currentLanguage() const;
void setCurrentLanguage(const std::string& langId);
obs::signal<void()> LanguageChange;
private:
Strings(Preferences& pref,
Extensions& exts);
void loadLanguage(const std::string& langId);
void loadStringsFromDataDir(const std::string& langId);
void loadStringsFromExtension(const std::string& langId);
void loadStringsFromFile(const std::string& fn);
Preferences& m_pref;
Extensions& m_exts;
mutable std::unordered_map<std::string, std::string> m_strings;
};
} // namespace app
#endif