/*
***********************************************************************************
fpPS4 Temmie's Launcher
language.js
This file is responible for all functions related to language and contains
the database with all labels and strings for English and all different
languages.
***********************************************************************************
*/
temp_LANGUAGE = {
/*
Lang variables
*/
// Selected lang
selected: {},
/*
Lang functions
*/
// Load selected language
load: function(){
try {
// Get lang data
var getLangFile,
cLang = APP.settings.data.appLanguage,
fileLocation = APP.settings.nwPath + 'App/Lang/' + cLang + '.json';
// Check if lang file exists and if lang isn't english
if (cLang !== 'english' && APP.fs.existsSync(fileLocation) === !0){
// Get selected lang
getLangFile = APP.fs.readFileSync(fileLocation, 'utf8');
this.selected = JSON.parse(getLangFile);
} else {
// Set english as default lang
this.selected = APP.lang.english;
}
// Update GUI
APP.design.updateLang();
} catch (err) {
throw new Error(err);
}
},
// Get variable string
getVariable: function(name, list){
// Fix settings
if (Object.keys(this.selected).length === 0){
this.selected = this.english;
}
// Variables
var lPatch = [],
res = this.selected.variables[name],
cIconStyle = APP.settings.data.input_iconStyle;
// If variable is not found or is a empty string, try get on english
if (res === void 0 || res === ''){
res = this.english.variables[name];
}
// Check if variable exists on default location
if (res !== void 0){
// If list is undefined, set patch list as a empty array
if (list !== void 0){
lPatch = list;
}
// Apply variables
lPatch.forEach(function(fix, entry){
res = res.replace('%VARIABLE_' + entry + '%', fix);
});
// Apply icons
Object.keys(APP.input.commandActions).forEach(function(cId){
res = res.replace(RegExp('%' + cId + '%', 'gi'), '');
});
// Return string
return res;
} else {
// Show error
const msg = 'ERROR - Unable to load string from lang databse! (\"' + name + '\")';
console.error(msg);
window.alert(msg);
}
},
// Get message
getMsgSys: function(name, list, options){
// Fix settings
if (Object.keys(this.selected).length === 0){
this.selected = this.english;
}
// Get current msg list
const cFile = APP.design.msgsys.msgCurrentMsg;
if (cFile !== ''){
// Variables
var lPatch = [],
tempString = '',
res = this.selected.msgsys[name],
cIconStyle = APP.settings.data.input_iconStyle;
// If variable is not found or an empty string, get from english instead
if (res === void 0 || res === ''){
res = this.english.msgsys[name];
}
// Check if message exists
if (res !== void 0){
// If list is undefined, set patch list as a empty array
if (list !== void 0){
lPatch = list;
}
// Get message from temp
tempString = res.message.toString();
// Apply variables
lPatch.forEach(function(fix, entry){
tempString = tempString.replace('%VARIABLE_' + entry + '%', fix);
});
// Apply options
if (options !== void 0){
// Create temp location for options
var tempOptions = '',
appIsLoading = APP.settings.appIsLoading;
// If app is loading and no class were defined, set custom class
if (appIsLoading === !0 && options.class === void 0 || appIsLoading === !0 && options.class === ''){
options.class = 'BTN_GUI_POPUP BTN_GUI_SAFE_MODE';
}
// Check if class is present
if (appIsLoading === !1 && options.class === void 0 || appIsLoading === !1 && options.class === ''){
options.class = 'BTN_GUI_POPUP';
}
// Process options list
options.list.forEach(function(cOption, cIndex){
// Check if action was defined
if (cOption.action === void 0 || cOption.action === ''){
cOption.action = 'return 0;';
}
// Append option
tempOptions = tempOptions + '';
});
// Apply options
tempString = tempString.replace('%OPTIONS%', tempOptions);
}
// Apply icons
Object.keys(APP.input.commandActions).forEach(function(cId){
tempString = tempString.replace(RegExp('%' + cId + '%', 'gi'), '');
});
// Return object
return {title: res.title, message: tempString};
} else {
// Display error message
const err = 'Unable to load selected msgsys data from lang database!\nmsgName: ' + name;
APP.log.add({mode: 'error', data: 'ERROR - (lang) ' + err});
window.alert('ERROR: (lang) ' + err);
}
}
},
/*
Lang default database
PS4
*/
// English (Default)
english: {
/*
langId - Replace this with "_" + lang number matching value on PARAM.SFO TITLE key
[Example: "_08" for Russian]
*/
"langId": '',
"lang": "English",
"author": "TheMitoSan",
"revision": "TheMitoSan",
/*
Variables
*/
"variables": {
/*
GUI
*/
"APP_TOP_BAR_releaseToFullscreen": "Release mouse to enter fullscreen",
/*
Game list
*/
"gameList_entryStatus_ok": "Fine",
"gameList_entryStatus_hb": "Homebrew",
"gameList_entryStatus_mf": "Missing files",
"gameList_entryDumpStatus": "Dump Status",
"gameList_entryVersion": "Version: %VARIABLE_0%",
"gameList_entryVersion_title_ok": "(Dump status: Fine)\nAll required files on sce_sys are present",
"gameList_entryVersion_title_hb": "(Dump status: Homebrew)\nThis entry executable is a executable (.elf) file.",
"gameList_entryVersion_title_mf": "(Dump status: Missing files)\nSome required files are missing on sce_sys.\n\nMissing files:\n%VARIABLE_0%",
"gameList_errorCurrentPathEmpty": "WARN - No items were detected on %VARIABLE_0%!",
"gameList_errorExecutable404": "Unable to locate main executable (eboot.bin) or any .elf file",
"gameList_errorCantAddEntry": "WARN - Unable to add %VARIABLE_0%!\nPath: %VARIABLE_1%\n\n%VARIABLE_2%",
"gameList_errorEntryAlreadyExists": "An entry with same title id already exists on game list! (%VARIABLE_0%)",
"gameList_errorEntryListEmpty": "