fix autofixable ESLint errors and format js files
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user