mirror of
https://github.com/lltcggie/waifu2x-caffe.git
synced 2025-06-26 05:32:47 +00:00
複数言語に対応作業(途中)
This commit is contained in:
parent
24c42d08b5
commit
ab544430bd
3
bin/lang/LangList.txt
Normal file
3
bin/lang/LangList.txt
Normal file
@ -0,0 +1,3 @@
|
||||
;LangName LangID SubLangID FileName
|
||||
English(US) 0x09 0x01 english.json
|
||||
日本語 0x11 0x01 japanese.json
|
33
bin/lang/ja.json
Normal file
33
bin/lang/ja.json
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"IDC_STATIC_IO_SETTING":"入出力設定",
|
||||
"IDC_STATIC_INPUT_PATH":"入力パス\r\n(フォルダでもOK)",
|
||||
"IDC_BUTTON_INPUT_REF":"参照",
|
||||
"IDC_STATIC_OUTPUT_PATH":"出力パス",
|
||||
"IDC_STATIC_TANS_EXT_LIST":"フォルダ内の変換する拡張子",
|
||||
"IDC_STATIC_OUTPUT_EXT":"出力拡張子",
|
||||
"IDC_STATIC_OUTPUT_QUALITY":"出力画質設定(1~100)",
|
||||
"IDC_STATIC_QUALITY_PROCESS_SETTING":"画質・処理設定",
|
||||
"IDC_STATIC_TRANS_MODE":"変換モード",
|
||||
"IDC_RADIO_MODE_NOISE_SCALE":"ノイズ除去と拡大",
|
||||
"IDC_RADIO_MODE_SCALE":"拡大",
|
||||
"IDC_RADIO_MODE_NOISE":"ノイズ除去",
|
||||
"IDC_RADIO_AUTO_SCALE":"ノイズ除去(自動判別)と拡大",
|
||||
"IDC_STATIC_JPEG_NOISE_LEVEL":"JPEGノイズ除去レベル",
|
||||
"IDC_RADIONOISE_LEVEL1":"レベル1",
|
||||
"IDC_RADIONOISE_LEVEL2":"レベル2",
|
||||
"IDC_STATIC_SCALE_RATE":"拡大率",
|
||||
"IDC_STATIC_MODEL":"モデル",
|
||||
"IDC_RADIO_MODEL_RGB":"2次元イラスト (RGBモデル)",
|
||||
"IDC_RADIO_MODEL_PHOTO":"写真・アニメ (Photoモデル)",
|
||||
"IDC_RADIO_MODEL_Y":"2次元イラスト2 (Yモデル)",
|
||||
"IDC_CHECK_TTA":"TTAモードを使う",
|
||||
"IDC_STATIC_PROCESS_SPEED_SETTING":"処理速度設定",
|
||||
"IDC_STATIC_PROCESSOR":"プロセッサー",
|
||||
"IDC_RADIO_MODE_GPU":"CUDA(使えたらcuDNN)",
|
||||
"IDC_RADIO_MODE_CPU":"CPU",
|
||||
"IDC_STATIC_CROP_SIZE":"分割サイズ",
|
||||
"IDC_BUTTON_CHECK_CUDNN":"cuDNNチェック",
|
||||
"IDC_BUTTON_CANCEL":"キャンセル",
|
||||
"IDC_BUTTON_EXEC":"実行"
|
||||
"IDC_STATIC_LANG_UI":"UIの言語"
|
||||
}
|
Binary file not shown.
@ -15,6 +15,7 @@
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/math/common_factor_rt.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <cblas.h>
|
||||
#include <dlgs.h>
|
||||
@ -38,6 +39,7 @@ const std::pair<int, int> DefaultCommonDivisorRange = {90, 140};
|
||||
|
||||
const TCHAR * const CropSizeListName = TEXT("crop_size_list.txt");
|
||||
const TCHAR * const SettingFileName = TEXT("setting.ini");
|
||||
const TCHAR * const LangListFileName = TEXT("lang/LangList.txt");
|
||||
|
||||
|
||||
#ifdef UNICODE
|
||||
@ -114,6 +116,160 @@ std::vector<int> CommonDivisorList(const int N)
|
||||
return list;
|
||||
}
|
||||
|
||||
class LangStringList
|
||||
{
|
||||
public:
|
||||
struct stLangSetting
|
||||
{
|
||||
std::wstring LangName;
|
||||
WORD LangID;
|
||||
WORD SubLangID;
|
||||
std::wstring FileName;
|
||||
|
||||
stLangSetting() : LangID(0), SubLangID(0)
|
||||
{}
|
||||
};
|
||||
|
||||
private:
|
||||
tstring LangBaseDir;
|
||||
std::vector<stLangSetting> LangList;
|
||||
stLangSetting NowLang;
|
||||
LANGID NowLangID = GetUserDefaultUILanguage();
|
||||
|
||||
private:
|
||||
static std::wstring Utf8ToUtf16(const char *src, int src_size = -1)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = MultiByteToWideChar(CP_UTF8, 0, src, src_size, NULL, 0);
|
||||
if (ret == 0)
|
||||
return std::wstring();
|
||||
|
||||
std::vector<wchar_t> buf(ret);
|
||||
|
||||
ret = MultiByteToWideChar(CP_UTF8, 0, src, src_size, buf.data(), ret);
|
||||
if (ret == 0)
|
||||
return std::wstring();
|
||||
|
||||
if (buf.back() != L'\0')
|
||||
buf.push_back(L'\0');
|
||||
|
||||
return std::wstring(buf.data());
|
||||
}
|
||||
|
||||
static int getNum(const std::string &str)
|
||||
{
|
||||
if (str.length() >= 3 && str.substr(0, 2) == "0x")
|
||||
return strtol(str.c_str(), NULL, 16);
|
||||
else
|
||||
return strtol(str.c_str(), NULL, 10);
|
||||
}
|
||||
|
||||
const stLangSetting& GetLang(const LANGID id) const
|
||||
{
|
||||
const auto Primarylang = PRIMARYLANGID(id);
|
||||
const auto Sublang = SUBLANGID(id);
|
||||
|
||||
int FindPrimary = -1;
|
||||
int FindSub = -1;
|
||||
|
||||
for (size_t i = 0; i < LangList.size(); i++)
|
||||
{
|
||||
const auto &l = LangList[i];
|
||||
|
||||
if (Primarylang == l.LangID)
|
||||
{
|
||||
FindPrimary = (int)i;
|
||||
if (Primarylang == l.SubLangID)
|
||||
{
|
||||
FindSub = (int)i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (FindPrimary >= 0 && FindSub >= 0) // 現在の言語にピッタリ合うやつが見つかった
|
||||
return LangList[FindSub];
|
||||
else if (FindPrimary >= 0) // 現在の言語に属するものが見つかった
|
||||
return LangList[FindPrimary];
|
||||
|
||||
// 見つからなかったから一番最初に書かれているやつにする
|
||||
if (LangList.size() > 0)
|
||||
return LangList[0];
|
||||
|
||||
return stLangSetting();
|
||||
}
|
||||
|
||||
void ReadLangFile(const stLangSetting &lang)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
void SetLangBaseDir(const tstring &LangBaseDir)
|
||||
{
|
||||
this->LangBaseDir = LangBaseDir;
|
||||
}
|
||||
|
||||
bool ReadLangList(const tstring &LangListPath)
|
||||
{
|
||||
std::ifstream ifs(LangListPath);
|
||||
if (ifs.fail())
|
||||
return false;
|
||||
|
||||
LangList.clear();
|
||||
|
||||
std::string str;
|
||||
while (getline(ifs, str))
|
||||
{
|
||||
if (str.length() > 0 && str.front() == ';')
|
||||
continue;
|
||||
|
||||
boost::char_separator<char> sep("\t");
|
||||
boost::tokenizer<boost::char_separator<char>> tokens(str, sep);
|
||||
|
||||
std::vector<std::string> list;
|
||||
for (const auto& t : tokens)
|
||||
list.emplace_back(t);
|
||||
|
||||
if (list.size() != 4)
|
||||
continue;
|
||||
|
||||
stLangSetting ls;
|
||||
ls.LangName = Utf8ToUtf16(list[0].c_str(), list[0].length());
|
||||
ls.LangID = getNum(list[1]);
|
||||
ls.SubLangID = getNum(list[2]);
|
||||
ls.FileName = Utf8ToUtf16(list[1].c_str(), list[1].length());
|
||||
|
||||
LangList.push_back(ls);
|
||||
}
|
||||
|
||||
if (NowLangID != 0)
|
||||
SetLang(NowLangID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetLang(const LANGID id)
|
||||
{
|
||||
NowLang = GetLang(id);
|
||||
NowLangID = id;
|
||||
}
|
||||
|
||||
void SetLang()
|
||||
{
|
||||
SetLang(GetUserDefaultUILanguage());
|
||||
}
|
||||
|
||||
const stLangSetting& GetLang() const
|
||||
{
|
||||
return NowLang;
|
||||
}
|
||||
|
||||
std::wstring GetString(const wchar_t *key) const
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
// ƒ_ƒCƒAƒ<41>ƒO—p
|
||||
class DialogEvent
|
||||
{
|
||||
@ -163,6 +319,8 @@ private:
|
||||
|
||||
eModelType modelType;
|
||||
|
||||
LangStringList langStringList;
|
||||
|
||||
private:
|
||||
template<typename T>
|
||||
static tstring to_tstring(T val)
|
||||
@ -964,6 +1122,12 @@ public:
|
||||
exeDir = exePath.branch_path();
|
||||
}
|
||||
|
||||
{
|
||||
const boost::filesystem::path LangListPath(exeDir / LangListFileName);
|
||||
langStringList.SetLangBaseDir(getTString(exeDir));
|
||||
langStringList.ReadLangList(getTString(LangListPath));
|
||||
}
|
||||
|
||||
const boost::filesystem::path CropSizeListPath(exeDir / CropSizeListName);
|
||||
std::ifstream ifs(CropSizeListPath.wstring());
|
||||
if (ifs)
|
||||
@ -1352,7 +1516,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user