Skip to content

Commit

Permalink
refactor: Use toLocale{Upper|Lower}Case instead of to{Lower|Upper}Case
Browse files Browse the repository at this point in the history
  • Loading branch information
xdy committed Jan 2, 2022
1 parent 9e412cd commit b632cef
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/module/handlebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function registerHandlebarsHelpers(): void {
return '';
} else {
const thing: string = str;
return str.charAt(0).toUpperCase() + (thing.length > 1 ? thing.slice(1) : "");
return str.charAt(0).toLocaleUpperCase() + (thing.length > 1 ? thing.slice(1) : "");
}
});

Expand Down Expand Up @@ -176,15 +176,15 @@ export default function registerHandlebarsHelpers(): void {
const slice: TwodsixItem[] = <TwodsixItem[]>array?.slice(0);
if (slice) {
sortedArray = slice.sort((a, b) => {
if (a.name?.toLowerCase() == null) {
if (a.name == null) {
return 1;
} else {
if (b.name?.toLowerCase() == null) {
if (b.name == null) {
return -1;
} else if (a.name === b.name) {
return 0;
} else {
return a.name?.toLowerCase().localeCompare(b.name?.toLowerCase());
return a.name?.toLocaleLowerCase().localeCompare(b.name?.toLocaleLowerCase());
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/module/hooks/showWoundIcons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async function applyWoundedEffect(selectedToken: Record<string, any>): Promise<v
async function setEffectState(effectLabel: string, targetToken: Record<string, any>, state: boolean): Promise<void> {
const isAlreadySet = await targetToken.actor.effects.find(eff => eff.data.label === effectLabel);
if ((typeof isAlreadySet !== 'undefined') !== state) {
const targetEffect = CONFIG.statusEffects.find(effect => (effect.id === effectLabel.toLowerCase()));
const targetEffect = CONFIG.statusEffects.find(effect => (effect.id === effectLabel.toLocaleLowerCase()));
await targetToken.toggleEffect(targetEffect);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/module/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//I18n related helper functions

export function advantageDisadvantageTerm(rollType:string):string {
switch (rollType.toLowerCase()) {
switch (rollType.toLocaleLowerCase()) {
case "advantage":
return (<string>game.settings.get('twodsix', 'termForAdvantage'));
case "disadvantage":
Expand Down
4 changes: 2 additions & 2 deletions src/module/sheets/TwodsixActorSheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ export class TwodsixActorSheet extends AbstractTwodsixActorSheet {
} catch (err) {
if (err.name === "TooLowQuantityError") {
const refillAction = ["magazine", "power_cell"].includes((<Consumable>item.data.data).subtype) ? "Reload" : "Refill";
const refillWord = game.i18n.localize(`TWODSIX.Actor.Items.${refillAction}`).toLowerCase();
const refillWord = game.i18n.localize(`TWODSIX.Actor.Items.${refillAction}`).toLocaleLowerCase();
const tooFewString = game.i18n.localize("TWODSIX.Errors.TooFewToReload");
ui.notifications.error(tooFewString.replace("_NAME_", item.name?.toLowerCase() || "???").replace("_REFILL_ACTION_", refillWord));
ui.notifications.error(tooFewString.replace("_NAME_", item.name?.toLocaleLowerCase() || "???").replace("_REFILL_ACTION_", refillWord));
} else {
throw err;
}
Expand Down

0 comments on commit b632cef

Please sign in to comment.