diff --git a/.eslintrc.json b/.eslintrc.json index c1cd848..a841b53 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -12,6 +12,7 @@ "no-undef": 0, "no-unused-vars": 0, "no-case-declarations": 0, + "no-control-regex": 0, "indent": [ "error", diff --git a/languages/en.json b/languages/en.json index d7ba60a..b746cec 100644 --- a/languages/en.json +++ b/languages/en.json @@ -81,7 +81,7 @@ "updateNotifText": "A new update is available! Newest version: ", - "chineseCharacterAlert": "The file path set contains Chinese characters, this may cause problems!", + "foreignCharacterAlert": "The file path set contains foreign characters, this may cause problems!", "dialogOk": "OK", "dialogNo": "NO", diff --git a/languages/hd.json b/languages/hd.json index dbad1b8..8477de5 100644 --- a/languages/hd.json +++ b/languages/hd.json @@ -81,5 +81,5 @@ "updateNotifText": "नया अपडेट आया है! नया वर्शन: ", - "chineseCharacterAlert": "इस फाइल पथ में चीनी चरक्टेर्स हैं, यह समस्या दे सकता है!" + "foreignCharacterAlert": "इस फाइल पथ में चीनी चरक्टेर्स हैं, यह समस्या दे सकता है!" } diff --git a/languages/id.json b/languages/id.json index 2685f12..41dc557 100644 --- a/languages/id.json +++ b/languages/id.json @@ -81,7 +81,7 @@ "updateNotifText": "Pembaruan baru tersedia! Versi terbaru: ", - "chineseCharacterAlert": "Jalur file yang diatur berisi karakter Cina, ini dapat menyebabkan masalah!", + "foreignCharacterAlert": "Jalur file yang diatur berisi karakter Cina, ini dapat menyebabkan masalah!", "dialogOk": "OK", "dialogNo": "TIDAK", diff --git a/languages/jp.json b/languages/jp.json index 4951772..b57e1fa 100644 --- a/languages/jp.json +++ b/languages/jp.json @@ -81,5 +81,5 @@ "updateNotifText": "新しいバージョンが利用できます。Version: ", - "chineseCharacterAlert": "ファイルパスに漢字やひらがななどの全角文字が含まれているため、正常に動作しない場合があります。" + "foreignCharacterAlert": "ファイルパスに漢字やひらがななどの全角文字が含まれているため、正常に動作しない場合があります。" } diff --git a/languages/pl.json b/languages/pl.json index 0056f92..23a7d67 100644 --- a/languages/pl.json +++ b/languages/pl.json @@ -81,7 +81,7 @@ "updateNotifText": "Nowa wersja jest dostępna! Najnowsza wersja: ", - "chineseCharacterAlert": "Ścieżka pliku zawierająca chińskie symbole może powodować błędy.", + "foreignCharacterAlert": "Ścieżka pliku zawierająca chińskie symbole może powodować błędy.", "dialogOk": "Tak", "dialogNo": "Nie", diff --git a/languages/pt-br.json b/languages/pt-br.json index 08b7d07..6d1bee7 100644 --- a/languages/pt-br.json +++ b/languages/pt-br.json @@ -77,7 +77,7 @@ "updateNotifText": "Uma nova atualização esta disponivel! Nova versão: ", - "chineseCharacterAlert": "O caminho setado contem caracteres chineses, isso pode causar problemas!", + "foreignCharacterAlert": "O caminho setado contem caracteres chineses, isso pode causar problemas!", "dialogOk": "OK", "dialogNo": "Não", diff --git a/languages/vie.json b/languages/vie.json index 9626c7f..226503d 100644 --- a/languages/vie.json +++ b/languages/vie.json @@ -80,7 +80,7 @@ "updateNotifText": "Phiên bản mới nhất đang khả dụng: ", - "chineseCharacterAlert": "Đường dẫn tới tệp tin chứa ký tự phức tạp, có thể gây lỗi!", + "foreignCharacterAlert": "Đường dẫn tới tệp tin chứa ký tự phức tạp, có thể gây lỗi!", "dialogOk": "OK", "dialogNo": "Không", diff --git a/languages/zh-tw.json b/languages/zh-tw.json index bb0f316..c872040 100644 --- a/languages/zh-tw.json +++ b/languages/zh-tw.json @@ -81,7 +81,7 @@ "updateNotifText": "有新的GrassClipper更新可用! 最新版本: ", - "chineseCharacterAlert": "此路徑含有中文字體,這可能會導致問題的發生。", + "foreignCharacterAlert": "此路徑含有中文字體,這可能會導致問題的發生。", "dialogOk": "好的", "dialogNo": "不要", diff --git a/languages/zh.json b/languages/zh.json index 0202466..006ec35 100644 --- a/languages/zh.json +++ b/languages/zh.json @@ -80,5 +80,5 @@ "updateNotifText": "有新版本可用!当前最新的版本是: ", - "chineseCharacterAlert": "当前文件路径含有中文字符,可能会导致一些问题。" + "foreignCharacterAlert": "当前文件路径含有中文字符,可能会导致一些问题。" } diff --git a/resources/js/helpers.js b/resources/js/helpers.js index 558d91a..c54072e 100644 --- a/resources/js/helpers.js +++ b/resources/js/helpers.js @@ -104,16 +104,11 @@ async function openGrasscutterFolder() { } // https://www.jimzhao.us/2015/09/javascript-detect-chinese-character.html -function hasChineseChars(str) { - let re1 = new RegExp(/[\u4E00-\uFA29]/) //Chinese character range - let re2 = new RegExp(/[\uE7C7-\uE7F3]/) //non Chinese character range +function hasForeignChars(str) { + let re1 = /^[\x00-\x7F]+$/g str = str.replace(/\s/g, '') - if (!re1.test(str) || re2.test(str)) { - return false - } - - return true + return !re1.test(str) } function openDialog(title, message, negBtn = false, affirmBtn = closeDialog) { diff --git a/resources/js/index.js b/resources/js/index.js index 0863998..791dbfb 100644 --- a/resources/js/index.js +++ b/resources/js/index.js @@ -42,7 +42,7 @@ async function enableServerButton() { */ async function handleGameNotSet() { // Set buttons to greyed out and disable - document.querySelector('#gamePath').innerHTML = localeObj.folderNotSet + document.querySelector('#gamePath').innerHTML = localeObj.folderNotSet || 'Not set' // Set official server background to default document.querySelector('#firstPanel').style.backgroundImage = 'url("../bg/private/default.png")' @@ -61,7 +61,7 @@ async function handleGameNotSet() { async function handleServerNotSet() { // Set buttons to greyed out and disable - document.querySelector('#serverPath').innerHTML = localeObj.folderNotSet + document.querySelector('#serverPath').innerHTML = localeObj.folderNotSet || 'Not set' // Set official server background to default // document.querySelector('#firstPanel').style.backgroundImage = `url("../bg/private/default.png")` @@ -223,7 +223,7 @@ async function handleFavoriteList() { document.createElement('li') ) - listItem.innerHTML = localeObj.noFavorites + listItem.innerHTML = localeObj.noFavorites || 'No favorites set' } for (const ip of ipArr) { @@ -404,14 +404,14 @@ async function displayServerLaunchSection() { * Set the game folder by opening a folder picker */ async function setGameExe() { - const gameExe = await Neutralino.os.showOpenDialog(localeObj.gameFolderDialog, { + const gameExe = await Neutralino.os.showOpenDialog(localeObj.gameFolderDialog || 'Select game folder', { filters: [ { name: 'Executable files', extensions: ['exe'] } ] }) if (!gameExe[0]) return - if (hasChineseChars(gameExe[0])) displayAlert(localeObj.chineseCharacterAlert) + if (hasForeignChars(gameExe[0])) displayAlert(localeObj.foreignCharacterAlert || 'The file path set contains Chinese characters, this may cause problems!') // Set the folder in our configuration const config = await getCfg() @@ -435,7 +435,9 @@ async function setGrasscutterFolder() { }) if (!folder[0]) return - if (hasChineseChars(folder[0])) displayAlert(localeObj.chineseCharacterAlert) + + console.log(hasForeignChars(folder[0])) + if (hasForeignChars(folder[0])) displayAlert(localeObj.foreignCharacterAlert) // Set the folder in our configuration const config = await getCfg()