From 05acbce1591f2bf9a423f7d874878d661db972e1 Mon Sep 17 00:00:00 2001 From: Mike Harvey <43474485+mikeharv@users.noreply.github.com> Date: Fri, 15 May 2026 13:03:18 -0400 Subject: [PATCH] feat: Add custom ARIA labels to built-in block dropdown field options --- packages/blockly/blocks/logic.ts | 12 +- packages/blockly/blocks/math.ts | 82 ++++++++++---- packages/blockly/blocks/text.ts | 40 +++++-- packages/blockly/core/field_dropdown.ts | 4 +- packages/blockly/msg/json/en.json | 35 +++++- packages/blockly/msg/json/qqq.json | 35 +++++- packages/blockly/msg/messages.js | 107 +++++++++++++++++- .../tests/mocha/keyboard_movement_test.js | 6 +- 8 files changed, 273 insertions(+), 48 deletions(-) diff --git a/packages/blockly/blocks/logic.ts b/packages/blockly/blocks/logic.ts index d2a7405fffa..cf9a90a788b 100644 --- a/packages/blockly/blocks/logic.ts +++ b/packages/blockly/blocks/logic.ts @@ -118,12 +118,12 @@ export const blocks = createBlockDefinitionsFromJsonArray([ 'type': 'field_dropdown', 'name': 'OP', 'options': [ - ['=', 'EQ'], - ['\u2260', 'NEQ'], - ['\u200F<', 'LT'], - ['\u200F\u2264', 'LTE'], - ['\u200F>', 'GT'], - ['\u200F\u2265', 'GTE'], + ['=', 'EQ', '%{BKY_LOGIC_COMPARE_EQ_ARIA}'], + ['\u2260', 'NEQ', '%{BKY_LOGIC_COMPARE_NEQ_ARIA}'], + ['\u200F<', 'LT', '%{BKY_LOGIC_COMPARE_LT_ARIA}'], + ['\u200F\u2264', 'LTE', '%{BKY_LOGIC_COMPARE_LTE_ARIA}'], + ['\u200F>', 'GT', '%{BKY_LOGIC_COMPARE_GT_ARIA}'], + ['\u200F\u2265', 'GTE', '%{BKY_LOGIC_COMPARE_GTE_ARIA}'], ], }, { diff --git a/packages/blockly/blocks/math.ts b/packages/blockly/blocks/math.ts index e5aef5fbb6e..fa9a8546368 100644 --- a/packages/blockly/blocks/math.ts +++ b/packages/blockly/blocks/math.ts @@ -55,11 +55,31 @@ export const blocks = createBlockDefinitionsFromJsonArray([ 'type': 'field_dropdown', 'name': 'OP', 'options': [ - ['%{BKY_MATH_ADDITION_SYMBOL}', 'ADD'], - ['%{BKY_MATH_SUBTRACTION_SYMBOL}', 'MINUS'], - ['%{BKY_MATH_MULTIPLICATION_SYMBOL}', 'MULTIPLY'], - ['%{BKY_MATH_DIVISION_SYMBOL}', 'DIVIDE'], - ['%{BKY_MATH_POWER_SYMBOL}', 'POWER'], + [ + '%{BKY_MATH_ADDITION_SYMBOL}', + 'ADD', + '%{BKY_MATH_ADDITION_SYMBOL_ARIA}', + ], + [ + '%{BKY_MATH_SUBTRACTION_SYMBOL}', + 'MINUS', + '%{BKY_MATH_SUBTRACTION_SYMBOL_ARIA}', + ], + [ + '%{BKY_MATH_MULTIPLICATION_SYMBOL}', + 'MULTIPLY', + '%{BKY_MATH_MULTIPLICATION_SYMBOL_ARIA}', + ], + [ + '%{BKY_MATH_DIVISION_SYMBOL}', + 'DIVIDE', + '%{BKY_MATH_DIVISION_SYMBOL_ARIA}', + ], + [ + '%{BKY_MATH_POWER_SYMBOL}', + 'POWER', + '%{BKY_MATH_POWER_SYMBOL_ARIA}', + ], ], }, { @@ -85,12 +105,16 @@ export const blocks = createBlockDefinitionsFromJsonArray([ 'name': 'OP', 'options': [ ['%{BKY_MATH_SINGLE_OP_ROOT}', 'ROOT'], - ['%{BKY_MATH_SINGLE_OP_ABSOLUTE}', 'ABS'], - ['-', 'NEG'], - ['ln', 'LN'], - ['log10', 'LOG10'], - ['e^', 'EXP'], - ['10^', 'POW10'], + [ + '%{BKY_MATH_SINGLE_OP_ABSOLUTE}', + 'ABS', + '%{BKY_MATH_SINGLE_OP_ABSOLUTE_ARIA}', + ], + ['-', 'NEG', '%{BKY_MATH_SINGLE_OP_NEG_ARIA}'], + ['ln', 'LN', '%{BKY_MATH_SINGLE_OP_LN_ARIA}'], + ['log10', 'LOG10', '%{BKY_MATH_SINGLE_OP_LOG10_ARIA}'], + ['e^', 'EXP', '%{BKY_MATH_SINGLE_OP_EXP_ARIA}'], + ['10^', 'POW10', '%{BKY_MATH_SINGLE_OP_POW10_ARIA}'], ], }, { @@ -114,12 +138,12 @@ export const blocks = createBlockDefinitionsFromJsonArray([ 'type': 'field_dropdown', 'name': 'OP', 'options': [ - ['%{BKY_MATH_TRIG_SIN}', 'SIN'], - ['%{BKY_MATH_TRIG_COS}', 'COS'], - ['%{BKY_MATH_TRIG_TAN}', 'TAN'], - ['%{BKY_MATH_TRIG_ASIN}', 'ASIN'], - ['%{BKY_MATH_TRIG_ACOS}', 'ACOS'], - ['%{BKY_MATH_TRIG_ATAN}', 'ATAN'], + ['%{BKY_MATH_TRIG_SIN}', 'SIN', '%{BKY_MATH_TRIG_SIN_ARIA}'], + ['%{BKY_MATH_TRIG_COS}', 'COS', '%{BKY_MATH_TRIG_COS_ARIA}'], + ['%{BKY_MATH_TRIG_TAN}', 'TAN', '%{BKY_MATH_TRIG_TAN_ARIA}'], + ['%{BKY_MATH_TRIG_ASIN}', 'ASIN', '%{BKY_MATH_TRIG_ASIN_ARIA}'], + ['%{BKY_MATH_TRIG_ACOS}', 'ACOS', '%{BKY_MATH_TRIG_ACOS_ARIA}'], + ['%{BKY_MATH_TRIG_ATAN}', 'ATAN', '%{BKY_MATH_TRIG_ATAN_ARIA}'], ], }, { @@ -143,12 +167,12 @@ export const blocks = createBlockDefinitionsFromJsonArray([ 'type': 'field_dropdown', 'name': 'CONSTANT', 'options': [ - ['\u03c0', 'PI'], - ['e', 'E'], - ['\u03c6', 'GOLDEN_RATIO'], - ['sqrt(2)', 'SQRT2'], - ['sqrt(\u00bd)', 'SQRT1_2'], - ['\u221e', 'INFINITY'], + ['\u03c0', 'PI', '%{BKY_MATH_CONSTANT_PI_ARIA}'], + ['e', 'E', '%{BKY_MATH_CONSTANT_E_ARIA}'], + ['\u03c6', 'GOLDEN_RATIO', '%{BKY_MATH_CONSTANT_GOLDEN_RATIO_ARIA}'], + ['sqrt(2)', 'SQRT2', '%{BKY_MATH_CONSTANT_SQRT2_ARIA}'], + ['sqrt(\u00bd)', 'SQRT1_2', '%{BKY_MATH_CONSTANT_SQRT1_2_ARIA}'], + ['\u221e', 'INFINITY', '%{BKY_MATH_CONSTANT_INFINITY_ARIA}'], ], }, ], @@ -250,8 +274,16 @@ export const blocks = createBlockDefinitionsFromJsonArray([ 'name': 'OP', 'options': [ ['%{BKY_MATH_ONLIST_OPERATOR_SUM}', 'SUM'], - ['%{BKY_MATH_ONLIST_OPERATOR_MIN}', 'MIN'], - ['%{BKY_MATH_ONLIST_OPERATOR_MAX}', 'MAX'], + [ + '%{BKY_MATH_ONLIST_OPERATOR_MIN}', + 'MIN', + '%{BKY_MATH_ONLIST_OPERATOR_MIN_ARIA}', + ], + [ + '%{BKY_MATH_ONLIST_OPERATOR_MAX}', + 'MAX', + '%{BKY_MATH_ONLIST_OPERATOR_MAX_ARIA}', + ], ['%{BKY_MATH_ONLIST_OPERATOR_AVERAGE}', 'AVERAGE'], ['%{BKY_MATH_ONLIST_OPERATOR_MEDIAN}', 'MEDIAN'], ['%{BKY_MATH_ONLIST_OPERATOR_MODE}', 'MODE'], diff --git a/packages/blockly/blocks/text.ts b/packages/blockly/blocks/text.ts index 8ab961ee5bc..a7775797169 100644 --- a/packages/blockly/blocks/text.ts +++ b/packages/blockly/blocks/text.ts @@ -172,8 +172,16 @@ export const blocks = createBlockDefinitionsFromJsonArray([ 'type': 'field_dropdown', 'name': 'WHERE', 'options': [ - ['%{BKY_TEXT_CHARAT_FROM_START}', 'FROM_START'], - ['%{BKY_TEXT_CHARAT_FROM_END}', 'FROM_END'], + [ + '%{BKY_TEXT_CHARAT_FROM_START}', + 'FROM_START', + '%{BKY_TEXT_FROM_START_ARIA}', + ], + [ + '%{BKY_TEXT_CHARAT_FROM_END}', + 'FROM_END', + '%{BKY_TEXT_FROM_END_ARIA}', + ], ['%{BKY_TEXT_CHARAT_FIRST}', 'FIRST'], ['%{BKY_TEXT_CHARAT_LAST}', 'LAST'], ['%{BKY_TEXT_CHARAT_RANDOM}', 'RANDOM'], @@ -191,8 +199,8 @@ export const blocks = createBlockDefinitionsFromJsonArray([ /** Type of a 'text_get_substring' block. */ type GetSubstringBlock = Block & GetSubstringMixin; interface GetSubstringMixin extends GetSubstringType { - WHERE_OPTIONS_1: Array<[string, string]>; - WHERE_OPTIONS_2: Array<[string, string]>; + WHERE_OPTIONS_1: Array<[string, string, string?]>; + WHERE_OPTIONS_2: Array<[string, string, string?]>; } type GetSubstringType = typeof GET_SUBSTRING_BLOCK; @@ -202,13 +210,29 @@ const GET_SUBSTRING_BLOCK = { */ init: function (this: GetSubstringBlock) { this['WHERE_OPTIONS_1'] = [ - [Msg['TEXT_GET_SUBSTRING_START_FROM_START'], 'FROM_START'], - [Msg['TEXT_GET_SUBSTRING_START_FROM_END'], 'FROM_END'], + [ + Msg['TEXT_GET_SUBSTRING_START_FROM_START'], + 'FROM_START', + Msg['TEXT_FROM_START_ARIA'], + ], + [ + Msg['TEXT_GET_SUBSTRING_START_FROM_END'], + 'FROM_END', + Msg['TEXT_FROM_END_ARIA'], + ], [Msg['TEXT_GET_SUBSTRING_START_FIRST'], 'FIRST'], ]; this['WHERE_OPTIONS_2'] = [ - [Msg['TEXT_GET_SUBSTRING_END_FROM_START'], 'FROM_START'], - [Msg['TEXT_GET_SUBSTRING_END_FROM_END'], 'FROM_END'], + [ + Msg['TEXT_GET_SUBSTRING_END_FROM_START'], + 'FROM_START', + Msg['TEXT_FROM_START_ARIA'], + ], + [ + Msg['TEXT_GET_SUBSTRING_END_FROM_END'], + 'FROM_END', + Msg['TEXT_FROM_END_ARIA'], + ], [Msg['TEXT_GET_SUBSTRING_END_LAST'], 'LAST'], ]; this.setHelpUrl(Msg['TEXT_GET_SUBSTRING_HELPURL']); diff --git a/packages/blockly/core/field_dropdown.ts b/packages/blockly/core/field_dropdown.ts index 8eeea302683..11e3f6282a8 100644 --- a/packages/blockly/core/field_dropdown.ts +++ b/packages/blockly/core/field_dropdown.ts @@ -747,7 +747,7 @@ export class FieldDropdown extends Field { value, ]; if (ariaLabel) { - trimmedLabelOption.push(ariaLabel); + trimmedLabelOption.push(parsing.replaceMessageReferences(ariaLabel)); } return trimmedLabelOption; } @@ -760,7 +760,7 @@ export class FieldDropdown extends Field { : label; const imageOptions: MenuOption = [imageLabel, value]; if (ariaLabel) { - imageOptions.push(ariaLabel); + imageOptions.push(parsing.replaceMessageReferences(ariaLabel)); } return imageOptions; }); diff --git a/packages/blockly/msg/json/en.json b/packages/blockly/msg/json/en.json index 7c24c37a7db..6b075c69afb 100644 --- a/packages/blockly/msg/json/en.json +++ b/packages/blockly/msg/json/en.json @@ -1,7 +1,7 @@ { "@metadata": { "author": "Ellen Spertus ", - "lastupdated": "2026-05-14 08:47:43.920300", + "lastupdated": "2026-05-15 12:51:08.370549", "locale": "en", "messagedocumentation" : "qqq" }, @@ -93,11 +93,17 @@ "CONTROLS_IF_ELSEIF_TOOLTIP": "Add a condition to the if block.", "CONTROLS_IF_ELSE_TOOLTIP": "Add a final, catch-all condition to the if block.", "LOGIC_COMPARE_HELPURL": "https://en.wikipedia.org/wiki/Inequality_(mathematics)", + "LOGIC_COMPARE_EQ_ARIA": "equals", "LOGIC_COMPARE_TOOLTIP_EQ": "Return true if both inputs equal each other.", + "LOGIC_COMPARE_NEQ_ARIA": "not equals", "LOGIC_COMPARE_TOOLTIP_NEQ": "Return true if both inputs are not equal to each other.", + "LOGIC_COMPARE_LT_ARIA": "less than", "LOGIC_COMPARE_TOOLTIP_LT": "Return true if the first input is smaller than the second input.", + "LOGIC_COMPARE_LTE_ARIA": "less than or equal to", "LOGIC_COMPARE_TOOLTIP_LTE": "Return true if the first input is smaller than or equal to the second input.", + "LOGIC_COMPARE_GT_ARIA": "greater than", "LOGIC_COMPARE_TOOLTIP_GT": "Return true if the first input is greater than the second input.", + "LOGIC_COMPARE_GTE_ARIA": "greater than or equal to", "LOGIC_COMPARE_TOOLTIP_GTE": "Return true if the first input is greater than or equal to the second input.", "LOGIC_OPERATION_HELPURL": "https://github.com/RaspberryPiFoundation/blockly/wiki/Logic#logical-operations", "LOGIC_OPERATION_TOOLTIP_AND": "Return true if both inputs are true.", @@ -122,16 +128,33 @@ "MATH_NUMBER_HELPURL": "https://en.wikipedia.org/wiki/Number", "MATH_NUMBER_TOOLTIP": "A number.", "MATH_ADDITION_SYMBOL": "+", + "MATH_ADDITION_SYMBOL_ARIA": "plus", "MATH_SUBTRACTION_SYMBOL": "-", + "MATH_SUBTRACTION_SYMBOL_ARIA": "minus", "MATH_DIVISION_SYMBOL": "÷", + "MATH_DIVISION_SYMBOL_ARIA": "divided by", "MATH_MULTIPLICATION_SYMBOL": "×", + "MATH_MULTIPLICATION_SYMBOL_ARIA": "times", "MATH_POWER_SYMBOL": "^", + "MATH_POWER_SYMBOL_ARIA": "to the power of", "MATH_TRIG_SIN": "sin", + "MATH_TRIG_SIN_ARIA": "sine", "MATH_TRIG_COS": "cos", + "MATH_TRIG_COS_ARIA": "cosine", "MATH_TRIG_TAN": "tan", + "MATH_TRIG_TAN_ARIA": "tangent", "MATH_TRIG_ASIN": "asin", + "MATH_TRIG_ASIN_ARIA": "inverse sine", "MATH_TRIG_ACOS": "acos", + "MATH_TRIG_ACOS_ARIA": "inverse cosine", "MATH_TRIG_ATAN": "atan", + "MATH_TRIG_ATAN_ARIA": "inverse tangent", + "MATH_CONSTANT_PI_ARIA": "pi", + "MATH_CONSTANT_E_ARIA": "e", + "MATH_CONSTANT_GOLDEN_RATIO_ARIA": "golden ratio", + "MATH_CONSTANT_SQRT2_ARIA": "square root of 2", + "MATH_CONSTANT_SQRT1_2_ARIA": "square root of 1 over 2", + "MATH_CONSTANT_INFINITY_ARIA": "infinity", "MATH_ARITHMETIC_HELPURL": "https://en.wikipedia.org/wiki/Arithmetic", "MATH_ARITHMETIC_TOOLTIP_ADD": "Return the sum of the two numbers.", "MATH_ARITHMETIC_TOOLTIP_MINUS": "Return the difference of the two numbers.", @@ -142,7 +165,13 @@ "MATH_SINGLE_OP_ROOT": "square root", "MATH_SINGLE_TOOLTIP_ROOT": "Return the square root of a number.", "MATH_SINGLE_OP_ABSOLUTE": "absolute", + "MATH_SINGLE_OP_ABSOLUTE_ARIA": "absolute value", "MATH_SINGLE_TOOLTIP_ABS": "Return the absolute value of a number.", + "MATH_SINGLE_OP_NEG_ARIA": "negative", + "MATH_SINGLE_OP_LN_ARIA": "natural logarithm", + "MATH_SINGLE_OP_LOG10_ARIA": "base 10 logarithm", + "MATH_SINGLE_OP_EXP_ARIA": "e to the power of", + "MATH_SINGLE_OP_POW10_ARIA": "10 to the power of", "MATH_SINGLE_TOOLTIP_NEG": "Return the negation of a number.", "MATH_SINGLE_TOOLTIP_LN": "Return the natural logarithm of a number.", "MATH_SINGLE_TOOLTIP_LOG10": "Return the base 10 logarithm of a number.", @@ -177,8 +206,10 @@ "MATH_ONLIST_OPERATOR_SUM": "sum of list", "MATH_ONLIST_TOOLTIP_SUM": "Return the sum of all the numbers in the list.", "MATH_ONLIST_OPERATOR_MIN": "min of list", + "MATH_ONLIST_OPERATOR_MIN_ARIA": "minimum", "MATH_ONLIST_TOOLTIP_MIN": "Return the smallest number in the list.", "MATH_ONLIST_OPERATOR_MAX": "max of list", + "MATH_ONLIST_OPERATOR_MAX_ARIA": "maximum", "MATH_ONLIST_TOOLTIP_MAX": "Return the largest number in the list.", "MATH_ONLIST_OPERATOR_AVERAGE": "average of list", "MATH_ONLIST_TOOLTIP_AVERAGE": "Return the average (arithmetic mean) of the numeric values in the list.", @@ -227,6 +258,8 @@ "TEXT_INDEXOF_TITLE": "in text %1 %2 %3", "TEXT_INDEXOF_OPERATOR_FIRST": "find first occurrence of text", "TEXT_INDEXOF_OPERATOR_LAST": "find last occurrence of text", + "TEXT_FROM_START_ARIA": "letter number", + "TEXT_FROM_END_ARIA": "letter number from end", "TEXT_CHARAT_HELPURL": "https://github.com/RaspberryPiFoundation/blockly/wiki/Text#extracting-text", "TEXT_CHARAT_TITLE": "in text %1 %2", "TEXT_CHARAT_FROM_START": "get letter #", diff --git a/packages/blockly/msg/json/qqq.json b/packages/blockly/msg/json/qqq.json index 1d1dca07940..854e267744a 100644 --- a/packages/blockly/msg/json/qqq.json +++ b/packages/blockly/msg/json/qqq.json @@ -87,11 +87,17 @@ "CONTROLS_IF_ELSEIF_TOOLTIP": "tooltip - Describes the 'else if' subblock during [https://github.com/RaspberryPiFoundation/blockly/wiki/IfElse#block-modification if block modification].", "CONTROLS_IF_ELSE_TOOLTIP": "tooltip - Describes the 'else' subblock during [https://github.com/RaspberryPiFoundation/blockly/wiki/IfElse#block-modification if block modification].", "LOGIC_COMPARE_HELPURL": "{{Optional}} url - Information about comparisons.", + "LOGIC_COMPARE_EQ_ARIA": "logic - ARIA label for the equals (=) operator.", "LOGIC_COMPARE_TOOLTIP_EQ": "tooltip - Describes the equals (=) block.", + "LOGIC_COMPARE_NEQ_ARIA": "logic - ARIA label for the not equals (≠) operator.", "LOGIC_COMPARE_TOOLTIP_NEQ": "tooltip - Describes the not equals (≠) block.", + "LOGIC_COMPARE_LT_ARIA": "logic - ARIA label for the less than (<) operator.", "LOGIC_COMPARE_TOOLTIP_LT": "tooltip - Describes the less than (<) block.", + "LOGIC_COMPARE_LTE_ARIA": "logic - ARIA label for the less than or equals (≤) operator.", "LOGIC_COMPARE_TOOLTIP_LTE": "tooltip - Describes the less than or equals (≤) block.", + "LOGIC_COMPARE_GT_ARIA": "logic - ARIA label for the greater than (>) operator.", "LOGIC_COMPARE_TOOLTIP_GT": "tooltip - Describes the greater than (>) block.", + "LOGIC_COMPARE_GTE_ARIA": "logic - ARIA label for the greater than or equals (≥) operator.", "LOGIC_COMPARE_TOOLTIP_GTE": "tooltip - Describes the greater than or equals (≥) block.", "LOGIC_OPERATION_HELPURL": "{{Optional}} url - Information about the Boolean conjunction ('and') and disjunction ('or') operators. Consider using the translation of [https://en.wikipedia.org/wiki/Boolean_logic https://en.wikipedia.org/wiki/Boolean_logic], if it exists in your language.", "LOGIC_OPERATION_TOOLTIP_AND": "tooltip - See [https://en.wikipedia.org/wiki/Logical_conjunction https://en.wikipedia.org/wiki/Logical_conjunction].", @@ -116,16 +122,33 @@ "MATH_NUMBER_HELPURL": "{{Optional}} url - Information about (real) numbers.", "MATH_NUMBER_TOOLTIP": "tooltip - Any positive or negative number, not necessarily an integer.", "MATH_ADDITION_SYMBOL": "{{Optional}} math - The symbol for the binary operation addition.", + "MATH_ADDITION_SYMBOL_ARIA": "math - ARIA label for the binary operation addition.", "MATH_SUBTRACTION_SYMBOL": "{{Optional}} math - The symbol for the binary operation indicating that the right operand should be subtracted from the left operand.", + "MATH_SUBTRACTION_SYMBOL_ARIA": "math - ARIA label for the binary operation subtraction.", "MATH_DIVISION_SYMBOL": "{{Optional}} math - The binary operation indicating that the left operand should be divided by the right operand.", + "MATH_DIVISION_SYMBOL_ARIA": "math - ARIA label for the binary operation division.", "MATH_MULTIPLICATION_SYMBOL": "{{Optional}} math - The symbol for the binary operation multiplication.", + "MATH_MULTIPLICATION_SYMBOL_ARIA": "math - ARIA label for the binary operation multiplication.", "MATH_POWER_SYMBOL": "{{Optional}} math - The symbol for the binary operation exponentiation. Specifically, if the value of the left operand is L and the value of the right operand (the exponent) is R, multiply L by itself R times. (Fractional and negative exponents are also legal.)", + "MATH_POWER_SYMBOL_ARIA": "math - ARIA label for the binary operation exponentiation.", "MATH_TRIG_SIN": "math - The short name of the trigonometric function [https://en.wikipedia.org/wiki/Trigonometric_functions#Sine.2C_cosine_and_tangent sine].", + "MATH_TRIG_SIN_ARIA": "math - ARIA label for the trigonometric function", "MATH_TRIG_COS": "math - The short name of the trigonometric function [https://en.wikipedia.org/wiki/Trigonometric_functions#Sine.2C_cosine_and_tangent cosine].", + "MATH_TRIG_COS_ARIA": "math - ARIA label for the trigonometric function", "MATH_TRIG_TAN": "math - The short name of the trigonometric function [https://en.wikipedia.org/wiki/Trigonometric_functions#Sine.2C_cosine_and_tangent tangent].", + "MATH_TRIG_TAN_ARIA": "math - ARIA label for the trigonometric function", "MATH_TRIG_ASIN": "math - The short name of the ''inverse of'' the trigonometric function [https://en.wikipedia.org/wiki/Trigonometric_functions#Sine.2C_cosine_and_tangent sine].", + "MATH_TRIG_ASIN_ARIA": "math - ARIA label for the inverse trigonometric function", "MATH_TRIG_ACOS": "math - The short name of the ''inverse of'' the trigonometric function [https://en.wikipedia.org/wiki/Trigonometric_functions#Sine.2C_cosine_and_tangent cosine].", + "MATH_TRIG_ACOS_ARIA": "math - ARIA label for the inverse trigonometric function", "MATH_TRIG_ATAN": "math - The short name of the ''inverse of'' the trigonometric function [https://en.wikipedia.org/wiki/Trigonometric_functions#Sine.2C_cosine_and_tangent tangent].", + "MATH_TRIG_ATAN_ARIA": "math - ARIA label for the inverse trigonometric function", + "MATH_CONSTANT_PI_ARIA": "math - ARIA label for the constant pi", + "MATH_CONSTANT_E_ARIA": "math - ARIA label for the constant e", + "MATH_CONSTANT_GOLDEN_RATIO_ARIA": "math - ARIA label for the golden ratio constant", + "MATH_CONSTANT_SQRT2_ARIA": "math - ARIA label for the constant square root of 2", + "MATH_CONSTANT_SQRT1_2_ARIA": "math - ARIA label for the constant square root of 1/2", + "MATH_CONSTANT_INFINITY_ARIA": "math - ARIA label for the constant infinity", "MATH_ARITHMETIC_HELPURL": "{{Optional}} url - Information about addition, subtraction, multiplication, division, and exponentiation.", "MATH_ARITHMETIC_TOOLTIP_ADD": "tooltip - See [https://en.wikipedia.org/wiki/Addition https://en.wikipedia.org/wiki/Addition].", "MATH_ARITHMETIC_TOOLTIP_MINUS": "tooltip - See [https://en.wikipedia.org/wiki/Subtraction https://en.wikipedia.org/wiki/Subtraction].", @@ -135,8 +158,14 @@ "MATH_SINGLE_HELPURL": "{{Optional}} url - Information about the square root operation.", "MATH_SINGLE_OP_ROOT": "dropdown - This computes the positive [https://en.wikipedia.org/wiki/Square_root square root] of its input. For example, the square root of 16 is 4.", "MATH_SINGLE_TOOLTIP_ROOT": "tooltip - Please use the same term as in the previous message.", - "MATH_SINGLE_OP_ABSOLUTE": "dropdown - This leaves positive numeric inputs changed and inverts negative inputs. For example, the absolute value of 5 is 5; the absolute value of -5 is also 5. For more information, see [https://en.wikipedia.org/wiki/Absolute_value https://en.wikipedia.org/wiki/Absolute_value].", + "MATH_SINGLE_OP_ABSOLUTE": "dropdown - This leaves positive numeric inputs unchanged and inverts negative inputs. For example, the absolute value of 5 is 5; the absolute value of -5 is also 5. For more information, see [https://en.wikipedia.org/wiki/Absolute_value https://en.wikipedia.org/wiki/Absolute_value].", + "MATH_SINGLE_OP_ABSOLUTE_ARIA": "dropdown ARIA label - Please use the same term as in the previous message.", "MATH_SINGLE_TOOLTIP_ABS": "tooltip - Please use the same term as in the previous message.", + "MATH_SINGLE_OP_NEG_ARIA": "dropdown ARIA label - This computes the negative of its input. For example, negative 5 is -5, and negative -5 is 5.", + "MATH_SINGLE_OP_LN_ARIA": "dropdown ARIA label - This computes the natural logarithm of its input. For example, the natural logarithm of e is 1.", + "MATH_SINGLE_OP_LOG10_ARIA": "dropdown ARIA label - This computes the base 10 logarithm of its input. For example, the base 10 logarithm of 100 is 2.", + "MATH_SINGLE_OP_EXP_ARIA": "dropdown ARIA label - This multiplies e by itself n times, where n is the input. For example, e to the power of 1 is e, and e to the power of 0 is 1.", + "MATH_SINGLE_OP_POW10_ARIA": "dropdown ARIA label - This multiplies 10 by itself n times, where n is the input. For example, 10 to the power of 2 is 100, and 10 to the power of 0 is 1.", "MATH_SINGLE_TOOLTIP_NEG": "tooltip - Calculates '''0-n''', where '''n''' is the single numeric input.", "MATH_SINGLE_TOOLTIP_LN": "tooltip - Calculates the [https://en.wikipedia.org/wiki/Natural_logarithm|natural logarithm] of its single numeric input.", "MATH_SINGLE_TOOLTIP_LOG10": "tooltip - Calculates the [https://en.wikipedia.org/wiki/Common_logarithm common logarithm] of its single numeric input.", @@ -171,8 +200,10 @@ "MATH_ONLIST_OPERATOR_SUM": "dropdown - This computes the sum of the numeric elements in the list. For example, the sum of the list {1, 4} is 5.", "MATH_ONLIST_TOOLTIP_SUM": "tooltip - Please use the same term for 'sum' as in the previous message.", "MATH_ONLIST_OPERATOR_MIN": "dropdown - This finds the smallest (minimum) number in a list. For example, the smallest number in the list [-5, 0, 3] is -5.", + "MATH_ONLIST_OPERATOR_MIN_ARIA": "ARIA label for the minimum operator", "MATH_ONLIST_TOOLTIP_MIN": "tooltip - Please use the same term for 'min' or 'minimum' as in the previous message.", "MATH_ONLIST_OPERATOR_MAX": "dropdown - This finds the largest (maximum) number in a list. For example, the largest number in the list [-5, 0, 3] is 3.", + "MATH_ONLIST_OPERATOR_MAX_ARIA": "ARIA label for the maximum operator", "MATH_ONLIST_TOOLTIP_MAX": "tooltip", "MATH_ONLIST_OPERATOR_AVERAGE": "dropdown - This adds up all of the numbers in a list and divides the sum by the number of elements in the list. For example, the [https://en.wikipedia.org/wiki/Arithmetic_mean average] of the list [1, 2, 3, 4] is 2.5 (10/4).", "MATH_ONLIST_TOOLTIP_AVERAGE": "tooltip - See [https://en.wikipedia.org/wiki/Arithmetic_mean https://en.wikipedia.org/wiki/Arithmetic_mean] for more informatin.", @@ -221,6 +252,8 @@ "TEXT_INDEXOF_TITLE": "block text - Title of blocks allowing users to find text. See [https://github.com/RaspberryPiFoundation/blockly/wiki/Text#finding-text https://github.com/RaspberryPiFoundation/blockly/wiki/Text#finding-text]. [[File:Blockly-find-text.png]]. In English the expanded message is 'in text %1 find (first|last) occurance of text %3' where %1 and %3 are added by the user. See TEXT_INDEXOF_OPERATOR_FIRST and TEXT_INDEXOF_OPERATOR_LAST for the dropdown text that replaces %2.", "TEXT_INDEXOF_OPERATOR_FIRST": "dropdown - See [https://github.com/RaspberryPiFoundation/blockly/wiki/Text#finding-text https://github.com/RaspberryPiFoundation/blockly/wiki/Text#finding-text]. [[File:Blockly-find-text.png]].", "TEXT_INDEXOF_OPERATOR_LAST": "dropdown - See [https://github.com/RaspberryPiFoundation/blockly/wiki/Text#finding-text https://github.com/RaspberryPiFoundation/blockly/wiki/Text#finding-text]. This would replace 'find first occurrence of text' below. (For more information on how common text is factored out of dropdown menus, see [https://translatewiki.net/wiki/Translating:Blockly#Drop-Down_Menus https://translatewiki.net/wiki/Translating:Blockly#Drop-Down_Menus)].) [[File:Blockly-find-text.png]].", + "TEXT_FROM_START_ARIA": "ARIA label for the dropdown option indicating that the following number specifies the", + "TEXT_FROM_END_ARIA": "ARIA label for the dropdown option indicating that the following number specifies the", "TEXT_CHARAT_HELPURL": "{{Optional}} url - Information about extracting characters (letters, number, symbols, etc.) from text.", "TEXT_CHARAT_TITLE": "block text - Text for a block to extract a letter (or number, punctuation character, etc.) from a string, as shown below. %1 is added by the user and %2 is replaced by a dropdown of options, possibly followed by another user supplied string. TEXT_CHARAT_TAIL is then added to the end. See [https://github.com/RaspberryPiFoundation/blockly/wiki/Text#extracting-a-single-character https://github.com/RaspberryPiFoundation/blockly/wiki/Text#extracting-a-single-character]. [[File:Blockly-text-get.png]]", "TEXT_CHARAT_FROM_START": "dropdown - Indicates that the letter (or number, punctuation character, etc.) with the specified index should be obtained from the preceding piece of text. See [https://github.com/RaspberryPiFoundation/blockly/wiki/Text#extracting-a-single-character https://github.com/RaspberryPiFoundation/blockly/wiki/Text#extracting-a-single-character]. [[File:Blockly-text-get.png]]", diff --git a/packages/blockly/msg/messages.js b/packages/blockly/msg/messages.js index 103e533d91e..3fa9d953ca5 100644 --- a/packages/blockly/msg/messages.js +++ b/packages/blockly/msg/messages.js @@ -366,21 +366,39 @@ Blockly.Msg.CONTROLS_IF_ELSE_TOOLTIP = 'Add a final, catch-all condition to the /// {{Optional}} url - Information about comparisons. Blockly.Msg.LOGIC_COMPARE_HELPURL = 'https://en.wikipedia.org/wiki/Inequality_(mathematics)'; /** @type {string} */ +/// logic - ARIA label for the equals (=) operator. +Blockly.Msg.LOGIC_COMPARE_EQ_ARIA = 'equals'; +/** @type {string} */ /// tooltip - Describes the equals (=) block. Blockly.Msg.LOGIC_COMPARE_TOOLTIP_EQ = 'Return true if both inputs equal each other.'; /** @type {string} */ +/// logic - ARIA label for the not equals (≠) operator. +Blockly.Msg.LOGIC_COMPARE_NEQ_ARIA = 'not equals'; +/** @type {string} */ /// tooltip - Describes the not equals (≠) block. Blockly.Msg.LOGIC_COMPARE_TOOLTIP_NEQ = 'Return true if both inputs are not equal to each other.'; /** @type {string} */ +/// logic - ARIA label for the less than (<) operator. +Blockly.Msg.LOGIC_COMPARE_LT_ARIA = 'less than'; +/** @type {string} */ /// tooltip - Describes the less than (<) block. Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LT = 'Return true if the first input is smaller than the second input.'; /** @type {string} */ +/// logic - ARIA label for the less than or equals (≤) operator. +Blockly.Msg.LOGIC_COMPARE_LTE_ARIA = 'less than or equal to'; +/** @type {string} */ /// tooltip - Describes the less than or equals (≤) block. Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LTE = 'Return true if the first input is smaller than or equal to the second input.'; /** @type {string} */ +/// logic - ARIA label for the greater than (>) operator. +Blockly.Msg.LOGIC_COMPARE_GT_ARIA = 'greater than'; +/** @type {string} */ /// tooltip - Describes the greater than (>) block. Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GT = 'Return true if the first input is greater than the second input.'; /** @type {string} */ +/// logic - ARIA label for the greater than or equals (≥) operator. +Blockly.Msg.LOGIC_COMPARE_GTE_ARIA = 'greater than or equal to'; +/** @type {string} */ /// tooltip - Describes the greater than or equals (≥) block. Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GTE = 'Return true if the first input is greater than or equal to the second input.'; @@ -462,46 +480,98 @@ Blockly.Msg.MATH_NUMBER_TOOLTIP = 'A number.'; /// {{Optional}} math - The symbol for the binary operation addition. Blockly.Msg.MATH_ADDITION_SYMBOL = '+'; /** @type {string} */ +/// math - ARIA label for the binary operation addition. +Blockly.Msg.MATH_ADDITION_SYMBOL_ARIA = 'plus'; +/** @type {string} */ /// {{Optional}} math - The symbol for the binary operation indicating that the right operand should be /// subtracted from the left operand. Blockly.Msg.MATH_SUBTRACTION_SYMBOL = '-'; /** @type {string} */ +/// math - ARIA label for the binary operation subtraction. +Blockly.Msg.MATH_SUBTRACTION_SYMBOL_ARIA = 'minus'; +/** @type {string} */ /// {{Optional}} math - The binary operation indicating that the left operand should be divided by /// the right operand. Blockly.Msg.MATH_DIVISION_SYMBOL = '÷'; /** @type {string} */ +/// math - ARIA label for the binary operation division. +Blockly.Msg.MATH_DIVISION_SYMBOL_ARIA = 'divided by'; +/** @type {string} */ /// {{Optional}} math - The symbol for the binary operation multiplication. Blockly.Msg.MATH_MULTIPLICATION_SYMBOL = '×'; /** @type {string} */ +/// math - ARIA label for the binary operation multiplication. +Blockly.Msg.MATH_MULTIPLICATION_SYMBOL_ARIA = 'times'; +/** @type {string} */ /// {{Optional}} math - The symbol for the binary operation exponentiation. Specifically, if the /// value of the left operand is L and the value of the right operand (the exponent) is /// R, multiply L by itself R times. (Fractional and negative exponents are also legal.) Blockly.Msg.MATH_POWER_SYMBOL = '^'; +/** @type {string} */ +/// math - ARIA label for the binary operation exponentiation. +Blockly.Msg.MATH_POWER_SYMBOL_ARIA = 'to the power of'; /** @type {string} */ /// math - The short name of the trigonometric function /// [https://en.wikipedia.org/wiki/Trigonometric_functions#Sine.2C_cosine_and_tangent sine]. Blockly.Msg.MATH_TRIG_SIN = 'sin'; /** @type {string} */ +/// math - ARIA label for the trigonometric function +Blockly.Msg.MATH_TRIG_SIN_ARIA = 'sine'; +/** @type {string} */ /// math - The short name of the trigonometric function /// [https://en.wikipedia.org/wiki/Trigonometric_functions#Sine.2C_cosine_and_tangent cosine]. Blockly.Msg.MATH_TRIG_COS = 'cos'; /** @type {string} */ +/// math - ARIA label for the trigonometric function +Blockly.Msg.MATH_TRIG_COS_ARIA = 'cosine'; +/** @type {string} */ /// math - The short name of the trigonometric function /// [https://en.wikipedia.org/wiki/Trigonometric_functions#Sine.2C_cosine_and_tangent tangent]. Blockly.Msg.MATH_TRIG_TAN = 'tan'; /** @type {string} */ +/// math - ARIA label for the trigonometric function +Blockly.Msg.MATH_TRIG_TAN_ARIA = 'tangent'; +/** @type {string} */ /// math - The short name of the ''inverse of'' the trigonometric function /// [https://en.wikipedia.org/wiki/Trigonometric_functions#Sine.2C_cosine_and_tangent sine]. Blockly.Msg.MATH_TRIG_ASIN = 'asin'; /** @type {string} */ +/// math - ARIA label for the inverse trigonometric function +Blockly.Msg.MATH_TRIG_ASIN_ARIA = 'inverse sine'; +/** @type {string} */ /// math - The short name of the ''inverse of'' the trigonometric function /// [https://en.wikipedia.org/wiki/Trigonometric_functions#Sine.2C_cosine_and_tangent cosine]. Blockly.Msg.MATH_TRIG_ACOS = 'acos'; /** @type {string} */ +/// math - ARIA label for the inverse trigonometric function +Blockly.Msg.MATH_TRIG_ACOS_ARIA = 'inverse cosine'; +/** @type {string} */ /// math - The short name of the ''inverse of'' the trigonometric function /// [https://en.wikipedia.org/wiki/Trigonometric_functions#Sine.2C_cosine_and_tangent tangent]. Blockly.Msg.MATH_TRIG_ATAN = 'atan'; +/** @type {string} */ +/// math - ARIA label for the inverse trigonometric function +Blockly.Msg.MATH_TRIG_ATAN_ARIA = 'inverse tangent'; + +/** @type {string} */ +/// math - ARIA label for the constant pi +Blockly.Msg.MATH_CONSTANT_PI_ARIA = 'pi'; +/** @type {string} */ +/// math - ARIA label for the constant e +Blockly.Msg.MATH_CONSTANT_E_ARIA = 'e'; +/** @type {string} */ +/// math - ARIA label for the golden ratio constant +Blockly.Msg.MATH_CONSTANT_GOLDEN_RATIO_ARIA = 'golden ratio'; +/** @type {string} */ +/// math - ARIA label for the constant square root of 2 +Blockly.Msg.MATH_CONSTANT_SQRT2_ARIA = 'square root of 2'; +/** @type {string} */ +/// math - ARIA label for the constant square root of 1/2 +Blockly.Msg.MATH_CONSTANT_SQRT1_2_ARIA = 'square root of 1 over 2'; +/** @type {string} */ +/// math - ARIA label for the constant infinity +Blockly.Msg.MATH_CONSTANT_INFINITY_ARIA = 'infinity'; /** @type {string} */ /// {{Optional}} url - Information about addition, subtraction, multiplication, division, and exponentiation. @@ -532,12 +602,28 @@ Blockly.Msg.MATH_SINGLE_OP_ROOT = 'square root'; /// tooltip - Please use the same term as in the previous message. Blockly.Msg.MATH_SINGLE_TOOLTIP_ROOT = 'Return the square root of a number.'; /** @type {string} */ -/// dropdown - This leaves positive numeric inputs changed and inverts negative inputs. For example, the absolute value of 5 is 5; the absolute value of -5 is also 5. For more information, see [https://en.wikipedia.org/wiki/Absolute_value https://en.wikipedia.org/wiki/Absolute_value]. +/// dropdown - This leaves positive numeric inputs unchanged and inverts negative inputs. For example, the absolute value of 5 is 5; the absolute value of -5 is also 5. For more information, see [https://en.wikipedia.org/wiki/Absolute_value https://en.wikipedia.org/wiki/Absolute_value]. Blockly.Msg.MATH_SINGLE_OP_ABSOLUTE = 'absolute'; +/// dropdown ARIA label - Please use the same term as in the previous message. +Blockly.Msg.MATH_SINGLE_OP_ABSOLUTE_ARIA = 'absolute value'; /** @type {string} */ /// tooltip - Please use the same term as in the previous message. Blockly.Msg.MATH_SINGLE_TOOLTIP_ABS = 'Return the absolute value of a number.'; - +/** @type {string}*/ +/// dropdown ARIA label - This computes the negative of its input. For example, negative 5 is -5, and negative -5 is 5. +Blockly.Msg.MATH_SINGLE_OP_NEG_ARIA = 'negative'; +/** @type {string} */ +/// dropdown ARIA label - This computes the natural logarithm of its input. For example, the natural logarithm of e is 1. +Blockly.Msg.MATH_SINGLE_OP_LN_ARIA = 'natural logarithm'; +/** @type {string} */ +/// dropdown ARIA label - This computes the base 10 logarithm of its input. For example, the base 10 logarithm of 100 is 2. +Blockly.Msg.MATH_SINGLE_OP_LOG10_ARIA = 'base 10 logarithm'; +/** @type {string} */ +/// dropdown ARIA label - This multiplies e by itself n times, where n is the input. For example, e to the power of 1 is e, and e to the power of 0 is 1. +Blockly.Msg.MATH_SINGLE_OP_EXP_ARIA = 'e to the power of'; +/** @type {string} */ +/// dropdown ARIA label - This multiplies 10 by itself n times, where n is the input. For example, 10 to the power of 2 is 100, and 10 to the power of 0 is 1. +Blockly.Msg.MATH_SINGLE_OP_POW10_ARIA = '10 to the power of'; /** @type {string} */ /// tooltip - Calculates '''0-n''', where '''n''' is the single numeric input. Blockly.Msg.MATH_SINGLE_TOOLTIP_NEG = 'Return the negation of a number.'; @@ -652,12 +738,18 @@ Blockly.Msg.MATH_ONLIST_TOOLTIP_SUM = 'Return the sum of all the numbers in the /// dropdown - This finds the smallest (minimum) number in a list. For example, the smallest number in the list [-5, 0, 3] is -5. Blockly.Msg.MATH_ONLIST_OPERATOR_MIN = 'min of list'; /** @type {string} */ +/// ARIA label for the minimum operator +Blockly.Msg.MATH_ONLIST_OPERATOR_MIN_ARIA = 'minimum'; +/** @type {string} */ /// tooltip - Please use the same term for "min" or "minimum" as in the previous message. Blockly.Msg.MATH_ONLIST_TOOLTIP_MIN = 'Return the smallest number in the list.'; /** @type {string} */ /// dropdown - This finds the largest (maximum) number in a list. For example, the largest number in the list [-5, 0, 3] is 3. Blockly.Msg.MATH_ONLIST_OPERATOR_MAX = 'max of list'; /** @type {string} */ +/// ARIA label for the maximum operator +Blockly.Msg.MATH_ONLIST_OPERATOR_MAX_ARIA = 'maximum'; +/** @type {string} */ /// tooltip Blockly.Msg.MATH_ONLIST_TOOLTIP_MAX = 'Return the largest number in the list.'; /** @type {string} */ @@ -837,8 +929,19 @@ Blockly.Msg.TEXT_INDEXOF_OPERATOR_FIRST = 'find first occurrence of text'; /// https://translatewiki.net/wiki/Translating:Blockly#Drop-Down_Menus)].) /// [[File:Blockly-find-text.png]]. Blockly.Msg.TEXT_INDEXOF_OPERATOR_LAST = 'find last occurrence of text'; + /** @type {string} */ +/// ARIA label for the dropdown option indicating that the following number specifies the +// position (relative to the start position) of a letter (or number, punctuation character, +// etc.) from a given piece of text. +Blockly.Msg.TEXT_FROM_START_ARIA = 'letter number'; +/** @type {string} */ +/// ARIA label for the dropdown option indicating that the following number specifies the +// position (relative to the end position) of a letter (or number, punctuation character, +// etc.) from a given piece of text. +Blockly.Msg.TEXT_FROM_END_ARIA = 'letter number from end'; +/** @type {string} */ /// {{Optional}} url - Information about extracting characters (letters, number, symbols, etc.) from text. Blockly.Msg.TEXT_CHARAT_HELPURL = 'https://github.com/RaspberryPiFoundation/blockly/wiki/Text#extracting-text'; /** @type {string} */ diff --git a/packages/blockly/tests/mocha/keyboard_movement_test.js b/packages/blockly/tests/mocha/keyboard_movement_test.js index 2c919dbd676..5a95ad42fa3 100644 --- a/packages/blockly/tests/mocha/keyboard_movement_test.js +++ b/packages/blockly/tests/mocha/keyboard_movement_test.js @@ -1400,12 +1400,12 @@ suite('Keyboard-driven movement', function () { this.clock.tick(10); this.moveAndAssert( moveRight, - ['Moving', 'to', '=', 'input 1'], + ['Moving', 'to', 'equals', 'input 1'], [this.getBlockLabel(boolean)], ); this.moveAndAssert( moveRight, - ['Moving', 'to', '=', '='], + ['Moving', 'to', 'equals', 'equals'], [this.getBlockLabel(boolean)], ); @@ -1477,7 +1477,7 @@ suite('Keyboard-driven movement', function () { this.clock.tick(10); this.moveAndAssert( moveRight, - ['Moving', 'to', 'input 1', '='], + ['Moving', 'to', 'input 1', 'equals'], [this.getBlockLabel(boolean)], ); cancelMove(this.workspace);