Skip to content

Commit

Permalink
Add base English localization
Browse files Browse the repository at this point in the history
  • Loading branch information
DFreds committed Jun 30, 2023
1 parent c852b71 commit e7e187e
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 50 deletions.
48 changes: 47 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
@@ -1 +1,47 @@
{}
{
"EffectsPanel.SettingPlayer": "Player",
"EffectsPanel.SettingTrustedPlayer": "Trusted Player",
"EffectsPanel.SettingAssistantGM": "Assistant GM",
"EffectsPanel.SettingGameMaster": "Game Master",
"EffectsPanel.SettingNone": "None",
"EffectsPanel.SettingDialog": "Dialog",
"EffectsPanel.SettingDelete": "Delete",
"EffectsPanel.SettingDisable": "Disable",

"EffectsPanel.SettingShowDisabledEffects": "Show Disabled Effects",
"EffectsPanel.SettingShowDisabledEffectsHint": "If enabled, disabled effects will be shown in the panel with a grey tint.",
"EffectsPanel.SettingShowPassiveEffects": "Show Passive Effects",
"EffectsPanel.SettingShowPassiveEffectsHint": "If enabled, passive effects will be shown in the panel.",
"EffectsPanel.SettingShowDurationOverlays": "Show Duration Overlays",
"EffectsPanel.SettingShowDurationOverlaysHint": "If enabled, an overlay icon will be shown over each effect to indicate its duration.",
"EffectsPanel.SettingPassiveEffectsRightClickBehavior": "Passive Effects Right-Click Behavior",
"EffectsPanel.SettingPassiveEffectsRightClickBehaviorHint": "This defines the behavior when right-clicking a passive effect.",
"EffectsPanel.SettingTemporaryEffectsRightClickBehavior": "Temporary Effects Right-Click Behavior",
"EffectsPanel.SettingTemporaryEffectsRightClickBehaviorHint": "This defines the behavior when right-clicking a temporary effect.",
"EffectsPanel.SettingViewPermission": "View Permission",
"EffectsPanel.SettingViewPermissionHint": "This defines the minimum permission level to see the effects panel. Setting this to None will never show the effects panel.",
"EffectsPanel.SettingViewDetailsPermission": "View Details Permission",
"EffectsPanel.SettingViewDetailsPermissionHint": "This defines the minimum permission level to see the details of the effects in the panel such as the duration and description. Setting this to None will never show any details.",

"EffectsPanel.Unlimited": "Unlimited",
"EffectsPanel.Expired": "Expired",

"EffectsPanel.OneYear": "1 year",
"EffectsPanel.OneWeek": "1 week",
"EffectsPanel.OneTurn": "1 turn",
"EffectsPanel.OneSecond": "1 second",

"EffectsPanel.ManyYears": "{years} years",
"EffectsPanel.ManyWeeks": "{weeks} weeks",
"EffectsPanel.ManyDays": "{days} days",
"EffectsPanel.ManyHours": "{hours} hours",
"EffectsPanel.ManyMinutes": "{minutes} minutes",
"EffectsPanel.ManyTurns": "{turns} turns",
"EffectsPanel.ManySeconds": "{seconds} seconds",

"EffectsPanel.DeleteOrDisableEffect": "Delete or Disable Effect",
"EffectsPanel.DeleteOrDisableEffectContent": "Delete or disable {effect}",
"EffectsPanel.Delete": "Delete",
"EffectsPanel.Enable": "Enable",
"EffectsPanel.Disable": "Disable"
}
16 changes: 12 additions & 4 deletions scripts/app/effects-panel-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,19 @@ export default class EffectsPanelController {

async _handleEffectChange(effect, rightClickBehavior) {
if (rightClickBehavior === Constants.RIGHT_CLICK_BEHAVIOR.DIALOG) {
const content = game.i18n.format(
'EffectsPanel.DeleteOrDisableEffectContent',
{
effect: effect.name,
}
);
return Dialog.wait({
title: 'Delete or Disable Effect',
content: `<h4>Delete or disable ${effect.label}?</h4>`,
title: game.i18n.localize('EffectsPanel.DeleteOrDisableEffect'),
content: `<h4>${content}?</h4>`,
buttons: {
delete: {
icon: '<i class="fas fa-trash"></i>',
label: 'Delete',
label: game.i18n.localize('EffectsPanel.Delete'),
callback: async () => {
await effect.delete();
this._viewMvc.refresh();
Expand All @@ -144,7 +150,9 @@ export default class EffectsPanelController {
icon: effect.disabled
? '<i class="fas fa-check"></i>'
: '<i class="fas fa-close"></i>',
label: effect.disabled ? 'Enable' : 'Disable',
label: effect.disabled
? game.i18n.localize('EffectsPanel.Enable')
: game.i18n.localize('EffectsPanel.Disable'),
callback: async () => {
await effect.update({ disabled: !effect.disabled });
},
Expand Down
52 changes: 29 additions & 23 deletions scripts/handlebar-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,42 +42,48 @@ export default class HandlebarHelpers {
const remainingSeconds = effect.remainingSeconds;
if (remainingSeconds == Infinity && effect.turns) {
if (effect.turns == 1) {
return '1 turn';
return game.i18n.localize('EffectsPanel.OneTurn');
} else {
return `${effect.turns} turns`;
return game.i18n.format('EffectsPanel.ManyTurns', {
turns: effect.turns,
});
}
} else if (remainingSeconds == Infinity) {
return 'Unlimited';
return game.i18n.localize('EffectsPanel.Unlimited');
} else if (remainingSeconds >= Constants.SECONDS.IN_TWO_YEARS) {
return `${Math.floor(
remainingSeconds / Constants.SECONDS.IN_ONE_YEAR
)} years`;
return game.i18n.format('EffectsPanel.ManyYears', {
years: Math.floor(remainingSeconds / Constants.SECONDS.IN_ONE_YEAR),
});
} else if (remainingSeconds >= Constants.SECONDS.IN_ONE_YEAR) {
return '1 year';
return game.i18n.localize('EffectsPanel.OneYear');
} else if (remainingSeconds >= Constants.SECONDS.IN_TWO_WEEKS) {
return `${Math.floor(
remainingSeconds / Constants.SECONDS.IN_ONE_WEEK
)} weeks`;
return game.i18n.format('EffectsPanel.ManyWeeks', {
weeks: Math.floor(remainingSeconds / Constants.SECONDS.IN_ONE_WEEK),
});
} else if (remainingSeconds > Constants.SECONDS.IN_ONE_WEEK) {
return '1 week';
return game.i18n.localize('EffectsPanel.OneWeek');
} else if (remainingSeconds >= Constants.SECONDS.IN_TWO_DAYS) {
return `${Math.floor(
remainingSeconds / Constants.SECONDS.IN_ONE_DAY
)} days`;
return game.i18n.format('EffectsPanel.ManyDays', {
days: Math.floor(remainingSeconds / Constants.SECONDS.IN_ONE_DAY),
});
} else if (remainingSeconds > Constants.SECONDS.IN_TWO_HOURS) {
return `${Math.floor(
remainingSeconds / Constants.SECONDS.IN_ONE_HOUR
)} hours`;
return game.i18n.format('EffectsPanel.ManyHours', {
hours: Math.floor(remainingSeconds / Constants.SECONDS.IN_ONE_HOUR),
});
} else if (remainingSeconds > Constants.SECONDS.IN_TWO_MINUTES) {
return `${Math.floor(
remainingSeconds / Constants.SECONDS.IN_ONE_MINUTE
)} minutes`;
return game.i18n.format('EffectsPanel.ManyMinutes', {
minutes: Math.floor(
remainingSeconds / Constants.SECONDS.IN_ONE_MINUTE
),
});
} else if (remainingSeconds >= 2) {
return `${remainingSeconds} seconds`;
return game.i18n.format('EffectsPanel.ManySeconds', {
seconds: remainingSeconds,
});
} else if (remainingSeconds === 1) {
return '1 second';
return game.i18n.localize('EffectsPanel.OneSecond');
} else {
return 'Expired';
return game.i18n.localize('EffectsPanel.Expired');
}
});
}
Expand Down
55 changes: 33 additions & 22 deletions scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,34 @@ export default class Settings {
*/
registerSettings() {
const userRoles = {};
userRoles[CONST.USER_ROLES.PLAYER] = 'Player';
userRoles[CONST.USER_ROLES.TRUSTED] = 'Trusted Player';
userRoles[CONST.USER_ROLES.ASSISTANT] = 'Assistant GM';
userRoles[CONST.USER_ROLES.GAMEMASTER] = 'Game Master';
userRoles[5] = 'None';
userRoles[CONST.USER_ROLES.PLAYER] = game.i18n.localize(
'EffectsPanel.SettingPlayer'
);
userRoles[CONST.USER_ROLES.TRUSTED] = game.i18n.localize(
'EffectsPanel.SettingTrustedPlayer'
);
userRoles[CONST.USER_ROLES.ASSISTANT] = game.i18n.localize(
'EffectsPanel.SettingAssistantGM'
);
userRoles[CONST.USER_ROLES.GAMEMASTER] = game.i18n.localize(
'EffectsPanel.SettingGameMaster'
);
userRoles[5] = game.i18n.localize('EffectsPanel.SettingNone');

const rightClickBehaviors = {};
rightClickBehaviors[Constants.RIGHT_CLICK_BEHAVIOR.DIALOG] = 'Dialog';
rightClickBehaviors[Constants.RIGHT_CLICK_BEHAVIOR.DELETE] = 'Delete';
rightClickBehaviors[Constants.RIGHT_CLICK_BEHAVIOR.DISABLE] = 'Disable';
rightClickBehaviors[Constants.RIGHT_CLICK_BEHAVIOR.DIALOG] =
game.i18n.localize('EffectsPanel.SettingDialog');
rightClickBehaviors[Constants.RIGHT_CLICK_BEHAVIOR.DELETE] =
game.i18n.localize('EffectsPanel.SettingDelete');
rightClickBehaviors[Constants.RIGHT_CLICK_BEHAVIOR.DISABLE] =
game.i18n.localize('EffectsPanel.SettingDisable');

game.settings.register(
Constants.MODULE_ID,
Settings.SHOW_DISABLED_EFFECTS,
{
name: 'Show Disabled Effects',
hint: 'If enabled, disabled effects will be shown in the panel with a grey tint.',
name: 'EffectsPanel.SettingShowDisabledEffects',
hint: 'EffectsPanel.SettingShowDisabledEffectsHint',
scope: 'client',
config: true,
default: true,
Expand All @@ -46,8 +57,8 @@ export default class Settings {
);

game.settings.register(Constants.MODULE_ID, Settings.SHOW_PASSIVE_EFFECTS, {
name: 'Show Passive Effects',
hint: 'If enabled, passive effects will be shown in the panel.',
name: 'EffectsPanel.SettingShowPassiveEffects',
hint: 'EffectsPanel.SettingShowPassiveEffectsHint',
scope: 'client',
config: true,
default: false,
Expand All @@ -59,8 +70,8 @@ export default class Settings {
Constants.MODULE_ID,
Settings.SHOW_DURATION_OVERLAYS,
{
name: 'Show Duration Overlays',
hint: 'If enabled, an overlay icon will be shown over each effect to indicate its duration.',
name: 'EffectsPanel.SettingShowDurationOverlays',
hint: 'EffectsPanel.SettingShowDurationOverlaysHint',
scope: 'client',
config: true,
default: true,
Expand All @@ -73,8 +84,8 @@ export default class Settings {
Constants.MODULE_ID,
Settings.PASSIVE_EFFECTS_RIGHT_CLICK_BEHAVIOR,
{
name: 'Passive Effects Right-Click Behavior',
hint: 'This defines the behavior when right-clicking a passive effect.',
name: 'EffectsPanel.SettingPassiveEffectsRightClickBehavior',
hint: 'EffectsPanel.SettingPassiveEffectsRightClickBehaviorHint',
scope: 'client',
config: true,
default: Constants.RIGHT_CLICK_BEHAVIOR.DISABLE,
Expand All @@ -88,8 +99,8 @@ export default class Settings {
Constants.MODULE_ID,
Settings.TEMPORARY_EFFECTS_RIGHT_CLICK_BEHAVIOR,
{
name: 'Temporary Effects Right-Click Behavior',
hint: 'This defines the behavior when right-clicking a temporary effect.',
name: 'EffectsPanel.SettingTemporaryEffectsRightClickBehavior',
hint: 'EffectsPanel.SettingTemporaryEffectsRightClickBehaviorHint',
scope: 'client',
config: true,
default: Constants.RIGHT_CLICK_BEHAVIOR.DIALOG,
Expand All @@ -100,8 +111,8 @@ export default class Settings {
);

game.settings.register(Constants.MODULE_ID, Settings.VIEW_PERMISSION, {
name: 'View Permission',
hint: 'This defines the minimum permission level to see the effects panel. Setting this to None will never show the effects panel.',
name: 'EffectsPanel.SettingViewPermission',
hint: 'EffectsPanel.SettingViewPermissionHint',
scope: 'world',
config: true,
default: CONST.USER_ROLES.PLAYER,
Expand All @@ -114,8 +125,8 @@ export default class Settings {
Constants.MODULE_ID,
Settings.VIEW_DETAILS_PERMISSION,
{
name: 'View Details Permission',
hint: 'This defines the minimum permission level to see the details of the effects in the panel such as the duration and description. Setting this to None will never show any details.',
name: 'EffectsPanel.SettingViewDetailsPermission',
hint: 'EffectsPanel.SettingViewDetailsPermissionHint',
scope: 'world',
config: true,
default: CONST.USER_ROLES.PLAYER,
Expand Down

0 comments on commit e7e187e

Please sign in to comment.