Skip to content

Commit 64875a6

Browse files
committed
Fix issue processing malformated strings in messages.js
1 parent 4cacde4 commit 64875a6

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

blockly/i18n/common.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ def _create_lang_file(author, lang, output_dir, ardublockly=False):
125125
Raises:
126126
IOError: An error occurred while opening or writing the file.
127127
"""
128+
qqq_name = 'qqq' + ('_ardublockly' if ardublockly else '')
128129
lang_file_name = lang + ('_ardublockly.json' if ardublockly else '.json')
129130
lang_file_name = os.path.join(os.curdir, output_dir, lang_file_name)
130131
lang_file = codecs.open(lang_file_name, 'w', 'utf-8')
@@ -135,8 +136,8 @@ def _create_lang_file(author, lang, output_dir, ardublockly=False):
135136
\t\t"author": "{0}",
136137
\t\t"lastupdated": "{1}",
137138
\t\t"locale": "{2}",
138-
\t\t"messagedocumentation" : "qqq"
139-
""".format(author, str(datetime.now()), lang))
139+
\t\t"messagedocumentation" : "{3}"
140+
""".format(author, str(datetime.now()), lang, qqq_name))
140141
lang_file.write('\t},\n')
141142
return lang_file
142143

blockly/i18n/js_to_json.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
import re
4848
from common import write_files, write_files_ardublockly
4949

50-
50+
# Original RegEx kept as a reminder that it'll conflict when upstreamed pulled
5151
#_INPUT_DEF_PATTERN = re.compile("""Blockly.Msg.(\w*)\s*=\s*'([^']*)';?$""")
52-
_INPUT_DEF_PATTERN = re.compile("""Blockly.Msg.(\w*)\s*=\s*'([^']*)';[\r\n]+$""")
52+
_INPUT_DEF_PATTERN = re.compile("""Blockly.Msg.(\w*)\s*=\s*'(.*)';?\r?$""")
5353

5454
_INPUT_SYN_PATTERN = re.compile(
5555
"""Blockly.Msg.(\w*)\s*=\s*Blockly.Msg.(\w*);""")
@@ -114,7 +114,9 @@ def main():
114114
write_files(args.author, args.lang, args.output_dir, results, False)
115115

116116
# Create synonyms.json.
117-
synonym_file_name = os.path.join(os.curdir, args.output_dir, 'synonyms.json')
117+
synonym_name = 'synonyms' + \
118+
('_ardublockly.json' if args.ardublockly else '.json')
119+
synonym_file_name = os.path.join(os.curdir, args.output_dir, synonym_name)
118120
with open(synonym_file_name, 'w') as outfile:
119121
json.dump(synonyms, outfile)
120122
if not args.quiet:

blockly/msg/messages_ardublockly.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ goog.require('Blockly.Msg');
2929
* message descriptor. The build process extracts these descriptors, adds
3030
* them to msg/json/qqq_ardublockly.json, and they show up in the translation
3131
* console.
32+
* Note the strings have to be surrounded by single quotation marks: ''
3233
*/
3334

3435
/// Ardublockly Types
@@ -79,7 +80,7 @@ Blockly.Msg.ARD_SERIAL_SETUP_TIP = 'Selects the speed for a specific Serial peri
7980
Blockly.Msg.ARD_SERIAL_PRINT = 'print';
8081
Blockly.Msg.ARD_SERIAL_PRINT_NEWLINE = 'add new line';
8182
Blockly.Msg.ARD_SERIAL_PRINT_TIP = 'Prints data to the console/serial port as human-readable ASCII text.';
82-
Blockly.Msg.ARD_SERIAL_PRINT_WARN = 'A setup block for %1 must be added to the workspace to use this block!'
83+
Blockly.Msg.ARD_SERIAL_PRINT_WARN = 'A setup block for %1 must be added to the workspace to use this block!';
8384
Blockly.Msg.ARD_SERVO_WRITE = 'set SERVO from Pin';
8485
Blockly.Msg.ARD_SERVO_WRITE_TO = 'to';
8586
Blockly.Msg.ARD_SERVO_WRITE_DEG_180 = 'Degrees (0~180)';
@@ -108,13 +109,13 @@ Blockly.Msg.ARD_SPI_TRANSRETURN_TIP = 'Send a SPI message to an specified slave
108109
Blockly.Msg.ARD_STEPPER_SETUP = 'Setup stepper motor';
109110
Blockly.Msg.ARD_STEPPER_MOTOR = 'stepper motor:';
110111
Blockly.Msg.ARD_STEPPER_DEFAULT_NAME = 'MyStepper';
111-
Blockly.Msg.ARD_STEPPER_NUMBER_OF_PINS = "Number of pins";
112-
Blockly.Msg.ARD_STEPPER_TWO_PINS = "2";
113-
Blockly.Msg.ARD_STEPPER_FOUR_PINS = "4";
112+
Blockly.Msg.ARD_STEPPER_NUMBER_OF_PINS = 'Number of pins';
113+
Blockly.Msg.ARD_STEPPER_TWO_PINS = '2';
114+
Blockly.Msg.ARD_STEPPER_FOUR_PINS = '4';
114115
Blockly.Msg.ARD_STEPPER_PIN1 = 'pin1#';
115116
Blockly.Msg.ARD_STEPPER_PIN2 = 'pin2#';
116-
Blockly.Msg.ARD_STEPPER_PIN3 = "pin3#";
117-
Blockly.Msg.ARD_STEPPER_PIN4 = "pin4#";
117+
Blockly.Msg.ARD_STEPPER_PIN3 = 'pin3#';
118+
Blockly.Msg.ARD_STEPPER_PIN4 = 'pin4#';
118119
Blockly.Msg.ARD_STEPPER_REVOLVS = 'how many steps per revolution';
119120
Blockly.Msg.ARD_STEPPER_SPEED = 'set speed (rpm) to';
120121
Blockly.Msg.ARD_STEPPER_SETUP_TIP = 'Configures a stepper motor pinout and other settings.';
@@ -133,7 +134,7 @@ Blockly.Msg.ARD_TIME_MILLIS_TIP = 'Returns the number of milliseconds since the
133134
Blockly.Msg.ARD_TIME_MICROS = 'current elapsed Time (microseconds)';
134135
Blockly.Msg.ARD_TIME_MICROS_TIP = 'Returns the number of microseconds since the Arduino board began running the current program. Has to be stored in a positive long integer';
135136
Blockly.Msg.ARD_TIME_INF = 'wait forever (end program)';
136-
Blockly.Msg.ARD_TIME_INF_TIP = 'Wait indefinitely, stopping the program.'
137+
Blockly.Msg.ARD_TIME_INF_TIP = 'Wait indefinitely, stopping the program.';
137138
Blockly.Msg.ARD_VAR_AS = 'as';
138139
Blockly.Msg.ARD_VAR_AS_TIP = 'Sets a value to a specific type';
139140
Blockly.Msg.ARD_PULSEREAD = 'Read';

0 commit comments

Comments
 (0)