fix autofixable ESLint errors and format js files

This commit is contained in:
jalensailin
2023-09-28 22:54:24 -04:00
parent bb32f9e2d6
commit 5d95aeb98b
10 changed files with 1515 additions and 1087 deletions
+17 -19
View File
@@ -1,27 +1,25 @@
/* globals game */
export default class DGUtils {
/**
* Attempt to localize a keyword, and gracefully fallback to something else if the key does not exist.
* This way people using incomplete translations will not as many crashes or bugs when playing against a newly updated system.
*
* @param {String} key - localization key
*
* @param {String} key - localization key
* @param {String} fallback - string to fall back to if translation does not exist for key
* @returns
* @returns
*/
static localizeWithFallback(key, fallback){
static localizeWithFallback(key, fallback) {
try {
let translatedValue = game.i18n.localize(key);
const translatedValue = game.i18n.localize(key);
if (translatedValue != key) {
return translatedValue;
} else {
console.warn(`Untranslated localization key '${key}'.`);
// can't have single quotes in a handlebars string literal input, so sort of hack in an escape character for them.
fallback = fallback.replace("'", "'");
return fallback;
return translatedValue;
}
} catch(ex) {
console.warn(`Untranslated localization key '${key}'.`);
// can't have single quotes in a handlebars string literal input, so sort of hack in an escape character for them.
fallback = fallback.replace("'", "'");
return fallback;
} catch (ex) {
console.warn(ex);
return fallback;
}
@@ -29,12 +27,12 @@ export default class DGUtils {
/**
* Format a number with a leading plus.
*
* @param {Number} number
*
* @param {Number} number
* @returns {String} - the stringified number with a leading plus if applicable
*
*
*/
static formatStringWithLeadingPlus(number){
return number > 0 ? `+${number}` : number.toString() ;
static formatStringWithLeadingPlus(number) {
return number > 0 ? `+${number}` : number.toString();
}
}
}