Initial Commit

This commit is contained in:
Phillip Stephens 2018-04-30 09:56:14 -07:00
commit 380bb98e33
6 changed files with 146 additions and 0 deletions

View File

@ -0,0 +1,8 @@
bintoc(en_US.cpp en_US.yaml L_en_US)
bintoc(en_GB.cpp en_GB.yaml L_en_GB)
bintoc(ja_JP.cpp ja_JP.yaml L_ja_JP)
add_library(UrdeLocales
en_US.yaml en_US.cpp
en_GB.yaml en_GB.cpp
ja_JP.yaml ja_JP.cpp
locale.hpp locale.cpp)

18
Editor/locale/en_GB.yaml Normal file
View File

@ -0,0 +1,18 @@
en_GB:
color: "Colour"
branch: "Branch"
commit: "Commit"
date: "Date"
new_project: "New Project"
open_project: "Open Project"
extract_game: "Extract Game"
name: "Name"
type: "Type"
size: "Size"
directory: "Directory"
file: "File"
file_name: "File Name"
cancel: "Cancel"
system_locations: "System Locations"
recent_projects: "Recent Projects"
recent_files: "Recent Files"

18
Editor/locale/en_US.yaml Normal file
View File

@ -0,0 +1,18 @@
en_US:
color: "Color"
branch: "Branch"
commit: "Commit"
date: "Date"
new_project: "New Project"
open_project: "Open Project"
extract_game: "Extract Game"
name: "Name"
type: "Type"
size: "Size"
directory: "Directory"
file: "File"
file_name: "File Name"
cancel: "Cancel"
system_locations: "System Locations"
recent_projects: "Recent Projects"
recent_files: "Recent Files"

18
Editor/locale/ja_JP.yaml Normal file
View File

@ -0,0 +1,18 @@
ja_JP:
color: "色"
branch: "分派"
commit: "預ける"
date: "年月日"
new_project: "新しいプロジェクト"
open_project: "プロジェクトを開きます"
extract_game: "ビデオゲームを抽出"
name: "名"
type: "タイプ"
size: "サイズ"
directory: "ディレクトリ"
file: "ファイル"
file_name: "ファイル名"
cancel: "キャンセル"
system_locations: "システムの場所"
recent_projects: "最近使ったプロジェクト"
recent_files: "最近使用したファイル"

69
Editor/locale/locale.cpp Normal file
View File

@ -0,0 +1,69 @@
#include "locale.hpp"
#include <cstring>
#include <clocale>
#include <algorithm>
#undef min
#undef max
extern "C" const uint8_t L_en_US[];
extern "C" size_t L_en_US_SZ;
extern "C" const uint8_t L_en_GB[];
extern "C" size_t L_en_GB_SZ;
extern "C" const uint8_t L_ja_JP[];
extern "C" size_t L_ja_JP_SZ;
namespace urde
{
using namespace std::literals;
static const specter::Locale Locales[] =
{
{"en_US"sv, "US English"sv, L_en_US, L_en_US_SZ},
{"en_GB"sv, "British English"sv, L_en_GB, L_en_GB_SZ},
{"ja_JP"sv, "Japanese"sv, L_ja_JP, L_ja_JP_SZ}
};
std::vector<std::pair<std::string_view, std::string_view>> ListLocales()
{
constexpr size_t localeCount = std::extent<decltype(Locales)>::value;
std::vector<std::pair<std::string_view, std::string_view>> ret;
ret.reserve(localeCount);
for (size_t i=0 ; i<localeCount ; ++i)
{
const specter::Locale& l = Locales[i];
ret.emplace_back(l.name(), l.fullName());
}
return ret;
}
const specter::Locale* LookupLocale(std::string_view name)
{
constexpr size_t localeCount = std::extent<decltype(Locales)>::value;
for (size_t i=0 ; i<localeCount ; ++i)
{
const specter::Locale& l = Locales[i];
if (!name.compare(l.name()))
return &l;
}
return nullptr;
}
const specter::Locale* SystemLocaleOrEnglish()
{
const char* sysLocale = std::setlocale(LC_ALL, nullptr);
size_t sysLocaleLen = std::strlen(sysLocale);
constexpr size_t localeCount = std::extent<decltype(Locales)>::value;
for (size_t i=0 ; i<localeCount ; ++i)
{
const specter::Locale& l = Locales[i];
if (!l.name().compare(0, std::min(l.name().size(), sysLocaleLen), sysLocale))
return &l;
}
return Locales;
}
}

15
Editor/locale/locale.hpp Normal file
View File

@ -0,0 +1,15 @@
#ifndef URDE_LOCALE_HPP
#define URDE_LOCALE_HPP
#include <specter/Translator.hpp>
namespace urde
{
std::vector<std::pair<std::string_view, std::string_view>> ListLocales();
const specter::Locale* LookupLocale(std::string_view name);
const specter::Locale* SystemLocaleOrEnglish();
}
#endif // URDE_LOCALE_HPP