Commit 52db8f6e authored by David Gonçalves's avatar David Gonçalves 📖

fixes

parent 46f91efa
desktop.ini
Thumbs.db
swf2exe/Lib/*.exe
!swf2exe/Lib/SA.exe
node_modules
......
......@@ -10,7 +10,7 @@ class File {
static fileSupport() {
// Check for the various File API support.
if (!(window.File && window.FileReader && window.FileList && window.Blob)) {
dialog.err('The File APIs are not fully supported in this browser.', 'Error');
dialog.err('The File APIs are not fully supported in this browser.', lang.lang.error);
}
}
......@@ -19,7 +19,7 @@ class File {
const data = ace.edit("XMLCode").getValue();
if (!data) {
dialog.err('Text area is empty.', 'Error');
dialog.err('Text area is empty.', lang.lang.error);
return null;
}
......@@ -51,7 +51,7 @@ class File {
fs.writeFile(fileName, blob, function(err) {
if (err) {
dialog.err(err, 'Error');
dialog.err(err, lang.lang.error);
}
else {
dialog.info("The file was saved!");
......@@ -72,7 +72,7 @@ class File {
if (file.name.substring(file.name.lastIndexOf(".")) != ".xml") {
file = file_tmp;
$("#fileInput").val("");
dialog.err('XML file only.', 'Error');
dialog.err('XML file only.', lang.lang.error);
return false;
} else {
fileType = "text/xml";
......
......@@ -4,66 +4,75 @@ const $ = require('jquery');
class Languages {
constructor() {
this.lang = [];
}
constructor() {
this._lang_arr = [];
this._lang = null;
}
loadLanguages() {
if (this.lang.length === 0) {
const that = this;
glob.sync( './languages/*.json' ).forEach( function( file ) {
that.lang.push( require(path.resolve( file )) );
});
}
}
loadLanguages() {
if (this._lang_arr.length === 0) {
const that = this;
glob.sync( './languages/*.json' ).forEach( function( file ) {
that._lang_arr.push( require(path.resolve( file )) );
});
}
}
get languages() {
if (this.lang.length === 0) {
return undefined;
}
return this.lang;
}
get lang_arr() {
if (this._lang_arr.length === 0) {
return undefined;
}
return this._lang_arr;
}
setLanguage(l) {
for (let i = 0, len = this.lang.length; i < len; i++) {
if (this.lang[i].language === l) {
break;
}
}
if (i = this.lang.length) return;
get lang() {
return this._lang;
}
let lang = this.lang[i];
setLanguage(l) {
let i;
let len = this._lang_arr.length;
for (i = 0; i < len; i++) {
if (this._lang_arr[i].language === l) {
break;
}
}
if (i === len) return;
$("title").text(lang.title);
$("#title").text(lang.title);
$("#save_as").text(lang.save_as);
$("#generate_exe").text(lang.generate_exe);
$("#replace_story_text").text(lang.replace_story);
$("#xmlopen").text(lang.open_xml);
$("#fontsize_text").text(lang.fontsize);
$("#theme_text").text(lang.theme);
$("#storyname_eng_text").text(lang.storyname_eng);
$("#storyname_chi_text").text(lang.storyname_chi);
$("#engtochi_text").text(lang.engtochi);
$("#editor_ln").text(lang.editor_line);
$("#editor_ch").text(lang.editor_ch);
$("#editor_ttln").text(lang.editor_totalline);
$("#").text(lang.error);
$("#").text(lang.api_error);
$("#").text(lang.empty_textarea_error);
$("#").text(lang.enter_filename_error);
$("#").text(lang.saved);
$("#").text(lang.xml_only_error);
$("#").text(lang.editor_size_lastm);
$("#").text(lang.replace_story_error);
$("#").text(lang.story_engname_error);
$("#").text(lang.story_chiname_error);
$("#").text(lang.empty_story_error);
$("#").text(lang.exists_error);
$("#").text(lang.large_size_error);
$("#").text(lang.save_error);
$("#").text(lang.savename_error);
this._lang = this._lang_arr[i];
}
$("title").text(this._lang.title);
$("#title").text(this._lang.title);
$("#save_as").text(this._lang.save_as);
$("#generate_exe").text(this._lang.generate_exe);
$("#replace_story_text").text(this._lang.replace_story);
$("#xmlopen").text(this._lang.open_xml);
$("#fontsize_text").text(this._lang.fontsize);
$("#theme_text").text(this._lang.theme);
$("#storyname_eng_text").text(this._lang.storyname_eng);
$("#storyname_chi_text").text(this._lang.storyname_chi);
$("#engtochi_text").text(this._lang.engtochi);
$("#editor_ln").text(this._lang.editor_line);
$("#editor_ch").text(this._lang.editor_ch);
$("#editor_ttln").text(this._lang.editor_totalline);
/*
$("#").text(this._lang.error);
$("#").text(this._lang.api_error);
$("#").text(this._lang.empty_textarea_error);
$("#").text(this._lang.enter_filename_error);
$("#").text(this._lang.saved);
$("#").text(this._lang.xml_only_error);
$("#").text(this._lang.editor_size_lastm);
$("#").text(this._lang.replace_story_error);
$("#").text(this._lang.story_engname_error);
$("#").text(this._lang.story_chiname_error);
$("#").text(this._lang.empty_story_error);
$("#").text(this._lang.exists_error);
$("#").text(this._lang.large_size_error);
$("#").text(this._lang.save_error);
$("#").text(this._lang.savename_error);
*/
}
}
module.exports = Languages;
......@@ -89,46 +89,46 @@ function generateExe() {
`;
if (story_number>7 || story_number<1) {
dialog.err("Sorry, you can only replace story 1-7.", 'Error');
dialog.err("Sorry, you can only replace story 1-7.", lang.lang.error);
return;
} else {
story_number=parseInt(story_number);
}
if (story_name == "" || story_name == null) {
dialog.err("Please enter a English name for your story.", 'Error');
dialog.err("Please enter a English name for your story.", lang.lang.error);
return;
}
if (story_nameb5 == "" || story_nameb5 == null) {
dialog.err("Please enter a Chinese name for your story.", 'Error');
dialog.err("Please enter a Chinese name for your story.", lang.lang.error);
return;
}
const data = File.getDataFromEditor();
if (data === undefined || data === null || data === '' || data.length == 0) {
dialog.err("Story cannot be empty.", 'Error');
dialog.err("Story cannot be empty.", lang.lang.error);
return;
}
// TODO: XML validation
fs.exists(target_file, exists => {
if (exists) {
dialog.err("Sorry, the story file already exists.", 'Error');
dialog.err("Sorry, the story file already exists.", lang.lang.error);
return;
}
});
if (data.length > 512 * 1000) {
dialog.err("Sorry, your story is too large.", 'Error');
dialog.err("Sorry, your story is too large.", lang.lang.error);
return;
}
fs.writeFile(target_file, data, err => {
console.log(target_file)
if (err) {
dialog.err("Sorry, there was an error saving your story.", 'Error');
dialog.err("Sorry, there was an error saving your story.", lang.lang.error);
return;
}
create_mod(target_filename);
......@@ -136,7 +136,7 @@ function generateExe() {
//upload storylist
fs.writeFile(target_file_story_list, storylistdata, err => {
if (err) {
dialog.err("Sorry, there was an error saving the story name.", 'Error');
dialog.err("Sorry, there was an error saving the story name.", lang.lang.error);
return;
}
create_mod(target_filename);
......
......@@ -32,5 +32,6 @@ $(document).ready(function () {
// Languages
lang = new Languages();
lang.loadLanguages();
console.log(lang.languages[0].language);
lang.setLanguage("中文");
//console.log(lang.lang_arr[0].language);
});
{
"language" : "中文",
"title": "HF - 線上修改故事",
"save_as": "另存新檔",
"generate_exe": "建立EXE檔",
"replace_story": "取代故事:",
"open_xml":"開啓 .xml 檔案:",
"fontsize":"---字體---",
"theme":"---主題---",
"storyname_eng":"故事名稱(英文):",
"storyname_chi":"故事名稱(中文):",
"engtochi":"英文轉換中文",
"editor_line":"行:",
"editor_ch":"字元:",
"editor_totalline":"總共行數:",
"error":"錯誤",
"api_error":"此瀏覽器不支援所需的APIs.",
"empty_textarea_error":"内容不能爲空白。",
"enter_filename_error":"請輸入檔案名稱",
"saved":"儲存成功!",
"xml_only_error":"只能開啓 XML 檔案。",
"editor_size_lastm":" 位元,最後修改: ",
"replace_story_error":"只能夠替換故事 1-7.",
"story_engname_error":"請爲你的故事填上英文名稱。",
"story_chiname_error":"請爲你的故事填上中文名稱。",
"empty_story_error":"故事不能爲空白。",
"exists_error":"抱歉,此檔案已經存在。",
"large_size_error":"抱歉,你的檔案太大。",
"save_error":"抱歉,儲存故事時發生錯誤。",
"savename_error":"抱歉,儲存故事名稱時發生錯誤。"
"language" : "中文",
"title": "HF - 線上修改故事",
"save_as": "另存新檔",
"generate_exe": "建立EXE檔",
"replace_story": "取代故事:",
"open_xml":"開啓 .xml 檔案:",
"fontsize":"---字體---",
"theme":"---主題---",
"storyname_eng":"故事名稱(英文):",
"storyname_chi":"故事名稱(中文):",
"engtochi":"英文轉換中文",
"editor_line":"行:",
"editor_ch":"字元:",
"editor_totalline":"總共行數:",
"error":"錯誤",
"api_error":"此瀏覽器不支援所需的APIs.",
"empty_textarea_error":"内容不能爲空白。",
"enter_filename_error":"請輸入檔案名稱",
"saved":"儲存成功!",
"xml_only_error":"只能開啓 XML 檔案。",
"editor_size_lastm":" 位元,最後修改: ",
"replace_story_error":"只能夠替換故事 1-7.",
"story_engname_error":"請爲你的故事填上英文名稱。",
"story_chiname_error":"請爲你的故事填上中文名稱。",
"empty_story_error":"故事不能爲空白。",
"exists_error":"抱歉,此檔案已經存在。",
"large_size_error":"抱歉,你的檔案太大。",
"save_error":"抱歉,儲存故事時發生錯誤。",
"savename_error":"抱歉,儲存故事名稱時發生錯誤。"
}
{
"language" : "English",
"title": "HF - Online Story Editor",
"save_as": "Save as...",
"generate_exe": "Generate EXE",
"replace_story": "Replace story:",
"open_xml":"Open .xml file:",
"fontsize":"---Font size---",
"theme":"---Theme---",
"storyname_eng":"Story name(English):",
"storyname_chi":"Story name(Chinese):",
"engtochi":"Eng to Chi",
"editor_line":"Ln:",
"editor_ch":"Ch:",
"editor_totalline":"Total Ln:",
"error":"Error",
"api_error":"The File APIs are not fully supported in this browser.",
"empty_textarea_error":"Text area is empty.",
"enter_filename_error":"Please enter the file name",
"saved":"The file was saved!",
"xml_only_error":"XML file only.",
"editor_size_lastm":" bytes, last modified: ",
"replace_story_error":"Sorry, you can only replace story 1-7.",
"story_engname_error":"Please enter a English name for your story.",
"story_chiname_error":"Please enter a Chinese name for your story.",
"empty_story_error":"Story cannot be empty.",
"exists_error":"Sorry, the story file already exists.",
"large_size_error":"Sorry, your story is too large.",
"save_error":"Sorry, there was an error saving your story.",
"savename_error":"Sorry, there was an error saving the story name."
"language" : "English",
"title": "HF - Online Story Editor",
"save_as": "Save as...",
"generate_exe": "Generate EXE",
"replace_story": "Replace story:",
"open_xml":"Open .xml file:",
"fontsize":"---Font size---",
"theme":"---Theme---",
"storyname_eng":"Story name(English):",
"storyname_chi":"Story name(Chinese):",
"engtochi":"Eng to Chi",
"editor_line":"Ln:",
"editor_ch":"Ch:",
"editor_totalline":"Total Ln:",
"error":"Error",
"api_error":"The File APIs are not fully supported in this browser.",
"empty_textarea_error":"Text area is empty.",
"enter_filename_error":"Please enter the file name",
"saved":"The file was saved!",
"xml_only_error":"XML file only.",
"editor_size_lastm":" bytes, last modified: ",
"replace_story_error":"Sorry, you can only replace story 1-7.",
"story_engname_error":"Please enter a English name for your story.",
"story_chiname_error":"Please enter a Chinese name for your story.",
"empty_story_error":"Story cannot be empty.",
"exists_error":"Sorry, the story file already exists.",
"large_size_error":"Sorry, your story is too large.",
"save_error":"Sorry, there was an error saving your story.",
"savename_error":"Sorry, there was an error saving the story name."
}
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment