Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0f51037
add: new messages file with French translations
chosww Jul 26, 2024
47ede16
fix: sort the messages file in alphabetical order
chosww Jul 26, 2024
b784239
fix: errors in messages
chosww Jul 26, 2024
810f99e
merge develop-1.13
chosww Jul 29, 2024
d2f993d
fix: update messages
chosww Aug 22, 2024
48b8c97
fix: remove unused messages
chosww Aug 23, 2024
2eb4e2b
fix: replace redundant messages with common message
chosww Aug 23, 2024
59d15b3
fix: update privacy policy messages to be stored in localization file
chosww Sep 4, 2024
feb9f13
fix: simplify key for list items and fix lint issues
chosww Sep 4, 2024
b93ef72
fix: format the messages
chosww Sep 23, 2024
5045736
fix: combine messages for the command replacement and move to next/pr…
chosww Sep 23, 2024
6ef7e44
fix: lint issues
chosww Sep 23, 2024
c2e70da
fix: separate step numbers and step names from add node aria label
chosww Sep 23, 2024
31cdea6
fix: return aria labels for ActionPanel in a method
chosww Sep 23, 2024
27f63b2
fix: merge develop-1.13
chosww Sep 27, 2024
ead12c8
fix: update messages placeholders
chosww Sep 30, 2024
11b1a92
fix: update based on PR feedback
chosww Oct 23, 2024
8bb37d6
Add messages2tsv.js and tsv2messages.js
sbates-idrc Oct 24, 2024
db78632
Sort messages.json keys in ASCII order
sbates-idrc Oct 24, 2024
f7f9011
Add check_messages.js
sbates-idrc Oct 25, 2024
3f65859
Use Unix line endings
sbates-idrc Oct 25, 2024
dd5ab8e
Add "UI." prefix to messages that are visible in the UI
sbates-idrc Oct 28, 2024
d346ff0
Sort messages
sbates-idrc Oct 28, 2024
e517ddd
Merge branch 'develop-1.13' into message-french-translation
sbates-idrc Nov 12, 2024
16cf4a5
Update messages and French translations
sbates-idrc Mar 24, 2025
72b37a5
Sort messages
sbates-idrc Mar 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 44 additions & 44 deletions src/ActionPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import './ActionPanel.scss';

type ActionPanelProps = {
focusedOptionName: ?string,
selectedCommandName: ?string,
selectedActionName: ?string,
programSequence: ProgramSequence,
pressedStepIndex: number,
intl: IntlShape,
Expand All @@ -42,53 +42,53 @@ class ActionPanel extends React.Component<ActionPanelProps, {}> {
stepNumber = cachedCurrentStepLoopData.getContainingLoopPosition();
}

let stepName = '';
let stepActionName = '';
if (currentStep.block === 'startLoop' || currentStep.block === 'endLoop') {
stepName = this.props.intl.formatMessage(
stepActionName = this.props.intl.formatMessage(
{ id: 'Command.loop.label' },
{ loopLabel: currentStep.label }
);
} else {
stepName = this.props.intl.formatMessage(
stepActionName = this.props.intl.formatMessage(
{ id: `Command.${currentStep.block}` }
);
}

const replaceStepAriaLabel = this.props.selectedCommandName != null ?
const replaceStepAriaLabel = this.props.selectedActionName != null ?
this.props.intl.formatMessage(
{id:'ActionPanel.action.replace.withAction'},
{ stepNumber, stepName, selectedCommandName: this.props.intl.formatMessage({id: `Command.${this.props.selectedCommandName}`}) }
{id:'ActionPanel.action.replace.withSelectedAction'},
{ stepNumber, stepActionName, selectedActionName: this.props.intl.formatMessage({id: `Command.${this.props.selectedActionName}`}) }
) :
this.props.intl.formatMessage({id:'ActionPanel.action.replace.noAction'}, { stepNumber, stepName });
this.props.intl.formatMessage({id:'ActionPanel.action.replace.noSelectedAction'}, { stepNumber, stepActionName });

return {
replaceStepAriaLabel,
'deleteStepAriaLabel': this.props.intl.formatMessage({id:'ActionPanel.action.delete'}, { stepNumber, stepName }),
'previousStepAriaLabel': this.makePreviousStepAriaLabel(stepNumber, stepName),
'nextStepAriaLabel': this.makeNextStepAriaLabel(stepNumber, stepName)
'deleteStepAriaLabel': this.props.intl.formatMessage({id:'ActionPanel.action.delete'}, { stepNumber, stepActionName }),
'previousStepAriaLabel': this.makePreviousStepAriaLabel(stepNumber, stepActionName),
'nextStepAriaLabel': this.makeNextStepAriaLabel(stepNumber, stepActionName)
}
}

makePreviousStepAriaLabel(stepNumber: ?number | string, stepName: string): string {
makePreviousStepAriaLabel(stepNumber: ?number | string, stepActionName: string): string {
const currentStep = this.props.programSequence.getProgramStepAt(this.props.pressedStepIndex);
if (this.props.pressedStepIndex > 0) {
const prevStep = this.props.programSequence.getProgramStepAt(this.props.pressedStepIndex - 1);
const cachedPreviousStepLoopData = prevStep.cache;
// When previous step is startLoop, aria-label communicates that movePrevious will move out of the current loop
if (prevStep.block === 'startLoop' && currentStep.block !== 'endLoop') {
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.startLoop'},
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.outOfLoop'},
{
stepNumber,
stepName,
stepActionName,
loopLabel: prevStep.label
}
);
// When previous step is endLoop, aria-label communicates that movePrevious will move into a loop
} else if (prevStep.block === 'endLoop') {
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.endLoop'},
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.intoLoop'},
{
stepNumber,
stepName,
stepActionName,
loopLabel: prevStep.label
}
);
Expand All @@ -99,67 +99,67 @@ class ActionPanel extends React.Component<ActionPanelProps, {}> {
const startLoopIndex = this.props.programSequence.getMatchingLoopBlockIndex(this.props.pressedStepIndex);
const program = this.props.programSequence.getProgram();
if (startLoopIndex != null && program[startLoopIndex - 1] != null) {
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.command'},
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep'},
{
stepNumber,
stepName,
stepActionName,
previousStepNumber: startLoopIndex,
command: this.props.intl.formatMessage({id: `Command.${program[startLoopIndex - 1].block}`}),
previousStepActionName: this.props.intl.formatMessage({id: `Command.${program[startLoopIndex - 1].block}`}),
}
)
}
// When previous step is wrapped in a loop, aria-label communicates position within a loop
} else if (cachedPreviousStepLoopData != null) {
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.inLoop'},
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.withInLoop'},
{
stepNumber,
stepName,
stepActionName,
previousStepNumber: cachedPreviousStepLoopData.getContainingLoopPosition(),
command: this.props.intl.formatMessage({id: `Command.${prevStep.block}`}),
previousStepActionName: this.props.intl.formatMessage({id: `Command.${prevStep.block}`}),
loopLabel: cachedPreviousStepLoopData.getContainingLoopLabel(),
}
)
// When previous step is a movements step and not in a loop, aria-label communicates position within the program
} else {
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.command'},
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep'},
{
stepNumber,
stepName,
stepActionName,
previousStepNumber: this.props.pressedStepIndex,
command: this.props.intl.formatMessage({id: `Command.${prevStep.block}`})
previousStepActionName: this.props.intl.formatMessage({id: `Command.${prevStep.block}`})
}
);
}
}
}
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep'},
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.disabled'},
{
stepNumber,
stepName
stepActionName
}
);
}

makeNextStepAriaLabel(stepNumber: ?number | string, stepName: string): string {
makeNextStepAriaLabel(stepNumber: ?number | string, stepActionName: string): string {
const currentStep = this.props.programSequence.getProgramStepAt(this.props.pressedStepIndex);
if (this.props.pressedStepIndex < (this.props.programSequence.getProgramLength() - 1)) {
const nextStep = this.props.programSequence.getProgramStepAt(this.props.pressedStepIndex + 1);
const cachedNextStepLoopData = nextStep.cache;
// When next step is startLoop, aria-label communicates that moveNext will move into a loop
if (nextStep.block === 'startLoop') {
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.startLoop'},
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.intoLoop'},
{
stepNumber,
stepName,
stepActionName,
loopLabel: nextStep.label
}
);
// When next step is endLoop, aria-label communicates that moveNext will move out of the current loop
} else if (nextStep.block === 'endLoop' && currentStep.block !== 'startLoop') {
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.endLoop'},
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.outOfLoop'},
{
stepNumber,
stepName,
stepActionName,
loopLabel: nextStep.label
}
);
Expand All @@ -170,43 +170,43 @@ class ActionPanel extends React.Component<ActionPanelProps, {}> {
const endLoopIndex = this.props.programSequence.getMatchingLoopBlockIndex(this.props.pressedStepIndex);
const program = this.props.programSequence.getProgram();
if (endLoopIndex != null && program[endLoopIndex + 1] != null) {
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.command'},
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep'},
{
stepNumber,
stepName,
stepActionName,
nextStepNumber: endLoopIndex + 2,
command: this.props.intl.formatMessage({id: `Command.${program[endLoopIndex + 1].block}`}),
nextStepActionName: this.props.intl.formatMessage({id: `Command.${program[endLoopIndex + 1].block}`}),
}
);
}
// When next step is wrapped in a loop, aria-label communicates position within a loop
} else if (cachedNextStepLoopData != null) {
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.inLoop'},
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.withInLoop'},
{
stepNumber,
stepName,
stepActionName,
nextStepNumber: cachedNextStepLoopData.getContainingLoopPosition(),
command: this.props.intl.formatMessage({id: `Command.${nextStep.block}`}),
nextStepActionName: this.props.intl.formatMessage({id: `Command.${nextStep.block}`}),
loopLabel: cachedNextStepLoopData.getContainingLoopLabel()
}
);
// When next step is a movements step and not in a loop, aria-label communicates position within the program
} else {
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.command'},
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep'},
{
stepNumber,
stepName,
stepActionName,
nextStepNumber: this.props.pressedStepIndex + 2,
command: this.props.intl.formatMessage({id: `Command.${nextStep.block}`})
nextStepActionName: this.props.intl.formatMessage({id: `Command.${nextStep.block}`})
}
);
}
}
}
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep'},
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.disabled'},
{
stepNumber,
stepName
stepActionName
}
);
}
Expand Down Expand Up @@ -238,7 +238,7 @@ class ActionPanel extends React.Component<ActionPanelProps, {}> {
const moveToNextStepIsDisabled = this.props.programSequence.moveToNextStepDisabled(this.props.pressedStepIndex);
const moveToPreviousStepIsDisabled = this.props.programSequence.moveToPreviousStepDisabled(this.props.pressedStepIndex);
const replaceIsVisible = this.getReplaceIsVisible();
const replaceIsDisabled = this.props.selectedCommandName == null;
const replaceIsDisabled = this.props.selectedActionName == null;

return (
<React.Fragment>
Expand Down
4 changes: 2 additions & 2 deletions src/ActionPanel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function createMountActionPanel(props) {
{},
{
focusedOptionName: null,
selectedCommandName: 'right45',
selectedActionName: 'right45',
programSequence: new ProgramSequence(
[
{block: 'forward1'},
Expand Down Expand Up @@ -101,7 +101,7 @@ describe('ActionPanel options', () => {
test('Given that there is no selected action, then the Replace button should be disabled', () => {
const { wrapper } = createMountActionPanel({
pressedStepIndex: 1,
selectedCommandName: null
selectedActionName: null
});
const replaceButton = getActionPanelOptionButtons(wrapper, 'replaceCurrentStep');
const expectedAriaLabel = 'Replace Step 2 turn left 45 degrees';
Expand Down
32 changes: 16 additions & 16 deletions src/AnnouncementBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,43 @@ export default class AnnouncementBuilder {
}

buildSelectActionAnnouncement(action: string): AnnouncementData {
let commandType = null;
let actionType = null;
if (action === 'loop') {
commandType = this.intl.formatMessage({
actionType = this.intl.formatMessage({
id: 'Announcement.control'
});
} else {
commandType = this.intl.formatMessage({
actionType = this.intl.formatMessage({
id: 'Announcement.movement'
});
}
return {
messageIdSuffix: 'actionSelected',
values: {
commandType: commandType,
command: this.intl.formatMessage({
actionType,
actionName: this.intl.formatMessage({
id: `Announcement.${action}`
}),
}
};
}

buildAddStepAnnouncement(action: string): AnnouncementData {
let commandType = null;
let actionType = null;
if (action === 'loop') {
commandType = this.intl.formatMessage({
actionType = this.intl.formatMessage({
id: 'Announcement.control'
});
} else {
commandType = this.intl.formatMessage({
actionType = this.intl.formatMessage({
id: 'Announcement.movement'
});
}
return {
messageIdSuffix: 'add',
values: {
commandType: commandType,
command: this.intl.formatMessage({
actionType,
actionName: this.intl.formatMessage({
id: `Announcement.${action}`
}),
}
Expand All @@ -64,10 +64,10 @@ export default class AnnouncementBuilder {
return {
messageIdSuffix: 'delete',
values: {
commandType: this.intl.formatMessage({
actionType: this.intl.formatMessage({
id: "Announcement.control"
}),
command: this.intl.formatMessage(
actionName: this.intl.formatMessage(
{
id: `Announcement.${programBlock.block}`
},
Expand All @@ -81,10 +81,10 @@ export default class AnnouncementBuilder {
return {
messageIdSuffix: 'delete',
values: {
commandType: this.intl.formatMessage({
actionType: this.intl.formatMessage({
id: "Announcement.movement"
}),
command: this.intl.formatMessage(
actionName: this.intl.formatMessage(
{
id: `Announcement.${programBlock.block}`
}
Expand All @@ -100,10 +100,10 @@ export default class AnnouncementBuilder {
return {
messageIdSuffix: 'replace',
values: {
oldCommand: this.intl.formatMessage({
oldActionName: this.intl.formatMessage({
id: `Announcement.${programBlock.block}`
}),
newCommand: this.intl.formatMessage({
newActionName: this.intl.formatMessage({
id: `Announcement.${selectedAction}`
})
}
Expand Down
Loading