mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-14 23:34:08 +00:00
Add helper function for locale (name) enumeration
This commit is contained in:
parent
b5ec57c2b5
commit
0413ada9b5
|
@ -440,6 +440,29 @@ string GenerateTimeDateFilename(const char *extension)
|
|||
return string(file);
|
||||
}
|
||||
|
||||
vector<pair<string, string>> GetLocaleNames()
|
||||
{
|
||||
string path;
|
||||
if (!GetDataFilePath("locale.ini", path))
|
||||
throw "Could not find locale.ini path";
|
||||
|
||||
ConfigFile ini;
|
||||
if (ini.Open(path.c_str(), CONFIG_OPEN_EXISTING) != 0)
|
||||
throw "Could not open locale.ini";
|
||||
|
||||
size_t sections = config_num_sections(ini);
|
||||
|
||||
vector<pair<string, string>> names;
|
||||
names.reserve(sections);
|
||||
for (size_t i = 0; i < sections; i++) {
|
||||
const char *tag = config_get_section(ini, i);
|
||||
const char *name = config_get_string(ini, tag, "Name");
|
||||
names.emplace_back(tag, name);
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
static void create_log_file(fstream &logFile)
|
||||
{
|
||||
stringstream dst;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <util/util.hpp>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "window-main.hpp"
|
||||
|
||||
|
@ -98,5 +99,6 @@ inline OBSApp *App() {return static_cast<OBSApp*>(qApp);}
|
|||
|
||||
inline config_t GetGlobalConfig() {return App()->GlobalConfig();}
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> GetLocaleNames();
|
||||
inline const char *Str(const char *lookup) {return App()->GetString(lookup);}
|
||||
#define QTStr(lookupVal) QString::fromUtf8(Str(lookupVal))
|
||||
|
|
Loading…
Reference in a new issue