Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
7eec1088
Commit
7eec1088
authored
May 09, 2019
by
Evan W. Patton
Committed by
Jeffrey Schiller
May 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make 'global' keyword internationalizable
Change-Id: I326f2f64f03fcc43a85c6f498e22b36da407815c
parent
3e292608
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
20 deletions
+21
-20
appinventor/blocklyeditor/src/blocklyeditor.js
appinventor/blocklyeditor/src/blocklyeditor.js
+3
-4
appinventor/blocklyeditor/src/blocks/lexical-variables.js
appinventor/blocklyeditor/src/blocks/lexical-variables.js
+4
-4
appinventor/blocklyeditor/src/demos/yail/yail_testing_index.html
...ntor/blocklyeditor/src/demos/yail/yail_testing_index.html
+5
-4
appinventor/blocklyeditor/src/field_global_flydown.js
appinventor/blocklyeditor/src/field_global_flydown.js
+1
-1
appinventor/blocklyeditor/src/field_lexical_variable.js
appinventor/blocklyeditor/src/field_lexical_variable.js
+5
-5
appinventor/blocklyeditor/src/generators/yail/variables.js
appinventor/blocklyeditor/src/generators/yail/variables.js
+2
-2
appinventor/blocklyeditor/src/msg/en/_messages.js
appinventor/blocklyeditor/src/msg/en/_messages.js
+1
-0
No files found.
appinventor/blocklyeditor/src/blocklyeditor.js
View file @
7eec1088
...
@@ -156,7 +156,6 @@ Blockly.usePrefixInYail = false;
...
@@ -156,7 +156,6 @@ Blockly.usePrefixInYail = false;
+ maybe index variables have prefix "index", or maybe instead they are treated as "param"
+ maybe index variables have prefix "index", or maybe instead they are treated as "param"
*/
*/
Blockly
.
globalNamePrefix
=
"
global
"
;
// For names introduced by global variable declarations
Blockly
.
procedureParameterPrefix
=
"
input
"
;
// For names introduced by procedure/function declarations
Blockly
.
procedureParameterPrefix
=
"
input
"
;
// For names introduced by procedure/function declarations
Blockly
.
handlerParameterPrefix
=
"
input
"
;
// For names introduced by event handlers
Blockly
.
handlerParameterPrefix
=
"
input
"
;
// For names introduced by event handlers
Blockly
.
localNamePrefix
=
"
local
"
;
// For names introduced by local variable declarations
Blockly
.
localNamePrefix
=
"
local
"
;
// For names introduced by local variable declarations
...
@@ -183,14 +182,14 @@ function (prefix) {
...
@@ -183,14 +182,14 @@ function (prefix) {
};
};
Blockly
.
prefixGlobalMenuName
=
function
(
name
)
{
Blockly
.
prefixGlobalMenuName
=
function
(
name
)
{
return
Blockly
.
globalNamePrefix
+
Blockly
.
menuSeparator
+
name
;
return
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
+
Blockly
.
menuSeparator
+
name
;
};
};
// Return a list of (1) prefix (if it exists, "" if not) and (2) unprefixed name
// Return a list of (1) prefix (if it exists, "" if not) and (2) unprefixed name
Blockly
.
unprefixName
=
function
(
name
)
{
Blockly
.
unprefixName
=
function
(
name
)
{
if
(
name
.
indexOf
(
Blockly
.
globalNamePrefix
+
Blockly
.
menuSeparator
)
==
0
)
{
if
(
name
.
indexOf
(
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
+
Blockly
.
menuSeparator
)
==
0
)
{
// Globals always have prefix, regardless of flags. Handle these specially
// Globals always have prefix, regardless of flags. Handle these specially
return
[
Blockly
.
globalNamePrefix
,
name
.
substring
(
Blockly
.
globalNamePrefix
.
length
+
Blockly
.
menuSeparator
.
length
)];
return
[
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
,
name
.
substring
(
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
.
length
+
Blockly
.
menuSeparator
.
length
)];
}
else
if
(
!
Blockly
.
showPrefixToUser
)
{
}
else
if
(
!
Blockly
.
showPrefixToUser
)
{
return
[
""
,
name
];
return
[
""
,
name
];
}
else
{
}
else
{
...
...
appinventor/blocklyeditor/src/blocks/lexical-variables.js
View file @
7eec1088
...
@@ -145,7 +145,7 @@ Blockly.Blocks['lexical_variable_get'] = {
...
@@ -145,7 +145,7 @@ Blockly.Blocks['lexical_variable_get'] = {
var
prefixPair
=
Blockly
.
unprefixName
(
this
.
getFieldValue
(
'
VAR
'
));
var
prefixPair
=
Blockly
.
unprefixName
(
this
.
getFieldValue
(
'
VAR
'
));
var
prefix
=
prefixPair
[
0
];
var
prefix
=
prefixPair
[
0
];
// Only rename lexical (nonglobal) names
// Only rename lexical (nonglobal) names
if
(
prefix
!==
Blockly
.
globalNamePrefix
)
{
if
(
prefix
!==
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
)
{
var
oldName
=
prefixPair
[
1
];
var
oldName
=
prefixPair
[
1
];
var
newName
=
freeSubstitution
.
apply
(
oldName
);
var
newName
=
freeSubstitution
.
apply
(
oldName
);
if
(
newName
!==
oldName
)
{
if
(
newName
!==
oldName
)
{
...
@@ -157,7 +157,7 @@ Blockly.Blocks['lexical_variable_get'] = {
...
@@ -157,7 +157,7 @@ Blockly.Blocks['lexical_variable_get'] = {
var
prefixPair
=
Blockly
.
unprefixName
(
this
.
getFieldValue
(
'
VAR
'
));
var
prefixPair
=
Blockly
.
unprefixName
(
this
.
getFieldValue
(
'
VAR
'
));
var
prefix
=
prefixPair
[
0
];
var
prefix
=
prefixPair
[
0
];
// Only return lexical (nonglobal) names
// Only return lexical (nonglobal) names
if
(
prefix
!==
Blockly
.
globalNamePrefix
)
{
if
(
prefix
!==
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
)
{
var
oldName
=
prefixPair
[
1
];
var
oldName
=
prefixPair
[
1
];
return
new
Blockly
.
NameSet
([
oldName
])
return
new
Blockly
.
NameSet
([
oldName
])
}
else
{
}
else
{
...
@@ -202,7 +202,7 @@ Blockly.Blocks['lexical_variable_set'] = {
...
@@ -202,7 +202,7 @@ Blockly.Blocks['lexical_variable_set'] = {
var
prefixPair
=
Blockly
.
unprefixName
(
this
.
getFieldValue
(
'
VAR
'
));
var
prefixPair
=
Blockly
.
unprefixName
(
this
.
getFieldValue
(
'
VAR
'
));
var
prefix
=
prefixPair
[
0
];
var
prefix
=
prefixPair
[
0
];
// Only rename lexical (nonglobal) names
// Only rename lexical (nonglobal) names
if
(
prefix
!==
Blockly
.
globalNamePrefix
)
{
if
(
prefix
!==
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
)
{
var
oldName
=
prefixPair
[
1
];
var
oldName
=
prefixPair
[
1
];
var
newName
=
freeSubstitution
.
apply
(
oldName
);
var
newName
=
freeSubstitution
.
apply
(
oldName
);
if
(
newName
!==
oldName
)
{
if
(
newName
!==
oldName
)
{
...
@@ -219,7 +219,7 @@ Blockly.Blocks['lexical_variable_set'] = {
...
@@ -219,7 +219,7 @@ Blockly.Blocks['lexical_variable_set'] = {
var
prefixPair
=
Blockly
.
unprefixName
(
this
.
getFieldValue
(
'
VAR
'
));
var
prefixPair
=
Blockly
.
unprefixName
(
this
.
getFieldValue
(
'
VAR
'
));
var
prefix
=
prefixPair
[
0
];
var
prefix
=
prefixPair
[
0
];
// Only return lexical (nonglobal) names
// Only return lexical (nonglobal) names
if
(
prefix
!==
Blockly
.
globalNamePrefix
)
{
if
(
prefix
!==
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
)
{
var
oldName
=
prefixPair
[
1
];
var
oldName
=
prefixPair
[
1
];
result
.
insert
(
oldName
);
result
.
insert
(
oldName
);
}
}
...
...
appinventor/blocklyeditor/src/demos/yail/yail_testing_index.html
View file @
7eec1088
...
@@ -53,7 +53,6 @@ function start() {
...
@@ -53,7 +53,6 @@ function start() {
Blockly
.
showPrefixToUser
=
true
;
Blockly
.
showPrefixToUser
=
true
;
Blockly
.
usePrefixInYail
=
false
;
Blockly
.
usePrefixInYail
=
false
;
Blockly
.
globalNamePrefix
=
"
global
"
;
// For names introduced by global variable declarations
Blockly
.
procedureParameterPrefix
=
"
input
"
;
// For names introduced by procedure/function declarations
Blockly
.
procedureParameterPrefix
=
"
input
"
;
// For names introduced by procedure/function declarations
Blockly
.
handlerParameterPrefix
=
"
input
"
;
// For names introduced by event handlers
Blockly
.
handlerParameterPrefix
=
"
input
"
;
// For names introduced by event handlers
Blockly
.
localNamePrefix
=
"
local
"
;
// For names introduced by local variable declarations
Blockly
.
localNamePrefix
=
"
local
"
;
// For names introduced by local variable declarations
...
@@ -79,14 +78,16 @@ function start() {
...
@@ -79,14 +78,16 @@ function start() {
};
};
Blockly
.
prefixGlobalMenuName
=
function
(
name
)
{
Blockly
.
prefixGlobalMenuName
=
function
(
name
)
{
return
Blockly
.
globalNamePrefix
+
Blockly
.
menuSeparator
+
name
;
return
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
+
Blockly
.
menuSeparator
+
name
;
};
};
// Return a list of (1) prefix (if it exists, "" if not) and (2) unprefixed name
// Return a list of (1) prefix (if it exists, "" if not) and (2) unprefixed name
Blockly
.
unprefixName
=
function
(
name
)
{
Blockly
.
unprefixName
=
function
(
name
)
{
if
(
name
.
indexOf
(
Blockly
.
globalNamePrefix
+
Blockly
.
menuSeparator
)
==
0
)
{
if
(
name
.
indexOf
(
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
+
Blockly
.
menuSeparator
)
==
0
)
{
// Globals always have prefix, regardless of flags. Handle these specially
// Globals always have prefix, regardless of flags. Handle these specially
return
[
Blockly
.
globalNamePrefix
,
name
.
substring
(
Blockly
.
globalNamePrefix
.
length
+
Blockly
.
menuSeparator
.
length
)];
return
[
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
,
name
.
substring
(
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
.
length
+
Blockly
.
menuSeparator
.
length
)];
}
else
if
(
!
Blockly
.
showPrefixToUser
)
{
}
else
if
(
!
Blockly
.
showPrefixToUser
)
{
return
[
""
,
name
];
return
[
""
,
name
];
}
else
{
}
else
{
...
...
appinventor/blocklyeditor/src/field_global_flydown.js
View file @
7eec1088
...
@@ -37,7 +37,7 @@ Blockly.FieldGlobalFlydown.prototype.flyoutCSSClassName = 'blocklyFieldParameter
...
@@ -37,7 +37,7 @@ Blockly.FieldGlobalFlydown.prototype.flyoutCSSClassName = 'blocklyFieldParameter
* @return {!Array.<string>} List of two XML elements.
* @return {!Array.<string>} List of two XML elements.
**/
**/
Blockly
.
FieldGlobalFlydown
.
prototype
.
flydownBlocksXML_
=
function
()
{
Blockly
.
FieldGlobalFlydown
.
prototype
.
flydownBlocksXML_
=
function
()
{
var
name
=
Blockly
.
globalNamePrefix
+
"
"
+
this
.
getText
();
// global name for this parameter field.
var
name
=
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
+
"
"
+
this
.
getText
();
// global name for this parameter field.
var
getterSetterXML
=
var
getterSetterXML
=
'
<xml>
'
+
'
<xml>
'
+
'
<block type="lexical_variable_get">
'
+
'
<block type="lexical_variable_get">
'
+
...
...
appinventor/blocklyeditor/src/field_lexical_variable.js
View file @
7eec1088
...
@@ -90,7 +90,7 @@ Blockly.FieldLexicalVariable.prototype.updateMutation = function() {
...
@@ -90,7 +90,7 @@ Blockly.FieldLexicalVariable.prototype.updateMutation = function() {
var
text
=
this
.
getText
();
var
text
=
this
.
getText
();
if
(
this
.
sourceBlock_
&&
this
.
sourceBlock_
.
getParent
())
{
if
(
this
.
sourceBlock_
&&
this
.
sourceBlock_
.
getParent
())
{
this
.
sourceBlock_
.
eventparam
=
undefined
;
this
.
sourceBlock_
.
eventparam
=
undefined
;
if
(
text
.
indexOf
(
Blockly
.
globalNamePrefix
+
'
'
)
===
0
)
{
if
(
text
.
indexOf
(
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
+
'
'
)
===
0
)
{
this
.
sourceBlock_
.
eventparam
=
null
;
this
.
sourceBlock_
.
eventparam
=
null
;
return
;
return
;
}
}
...
@@ -459,8 +459,8 @@ Blockly.LexicalVariable.renameGlobal = function (newName) {
...
@@ -459,8 +459,8 @@ Blockly.LexicalVariable.renameGlobal = function (newName) {
var
renamingFunction
=
block
.
renameLexicalVar
;
var
renamingFunction
=
block
.
renameLexicalVar
;
if
(
renamingFunction
)
{
if
(
renamingFunction
)
{
renamingFunction
.
call
(
block
,
renamingFunction
.
call
(
block
,
Blockly
.
globalNamePrefix
+
Blockly
.
menuSeparator
+
oldName
,
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
+
Blockly
.
menuSeparator
+
oldName
,
Blockly
.
globalNamePrefix
+
Blockly
.
menuSeparator
+
newName
);
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
+
Blockly
.
menuSeparator
+
newName
);
}
}
}
}
}
}
...
@@ -906,7 +906,7 @@ Blockly.LexicalVariable.referenceResult = function (block, name, prefix, env) {
...
@@ -906,7 +906,7 @@ Blockly.LexicalVariable.referenceResult = function (block, name, prefix, env) {
var
referenceName
=
unprefixedPair
[
1
];
var
referenceName
=
unprefixedPair
[
1
];
var
referenceNotInEnv
=
((
Blockly
.
usePrefixInYail
&&
(
env
.
indexOf
(
possiblyPrefixedReferenceName
)
==
-
1
))
var
referenceNotInEnv
=
((
Blockly
.
usePrefixInYail
&&
(
env
.
indexOf
(
possiblyPrefixedReferenceName
)
==
-
1
))
||
((
!
Blockly
.
usePrefixInYail
)
&&
(
env
.
indexOf
(
referenceName
)
==
-
1
)))
||
((
!
Blockly
.
usePrefixInYail
)
&&
(
env
.
indexOf
(
referenceName
)
==
-
1
)))
if
(
!
(
referencePrefix
===
Blockly
.
globalNamePrefix
))
{
if
(
!
(
referencePrefix
===
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
))
{
if
((
referenceName
===
name
)
&&
referenceNotInEnv
)
{
if
((
referenceName
===
name
)
&&
referenceNotInEnv
)
{
// if referenceName refers to name and not some intervening declaration, it's a reference to be renamed:
// if referenceName refers to name and not some intervening declaration, it's a reference to be renamed:
blocksToRename
.
push
(
block
);
blocksToRename
.
push
(
block
);
...
@@ -1032,7 +1032,7 @@ Blockly.LexicalVariable.getEventParam = function (block) {
...
@@ -1032,7 +1032,7 @@ Blockly.LexicalVariable.getEventParam = function (block) {
// evaluated it.
// evaluated it.
var
prefixPair
=
Blockly
.
unprefixName
(
block
.
getFieldValue
(
"
VAR
"
));
var
prefixPair
=
Blockly
.
unprefixName
(
block
.
getFieldValue
(
"
VAR
"
));
var
prefix
=
prefixPair
[
0
];
var
prefix
=
prefixPair
[
0
];
if
(
prefix
!==
Blockly
.
globalNamePrefix
)
{
if
(
prefix
!==
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
)
{
var
name
=
prefixPair
[
1
];
var
name
=
prefixPair
[
1
];
var
child
=
block
;
var
child
=
block
;
var
parent
=
block
.
getParent
();
var
parent
=
block
.
getParent
();
...
...
appinventor/blocklyeditor/src/generators/yail/variables.js
View file @
7eec1088
...
@@ -90,7 +90,7 @@ Blockly.Yail['getVariableCommandAndName'] = function(name){
...
@@ -90,7 +90,7 @@ Blockly.Yail['getVariableCommandAndName'] = function(name){
var
pair
=
Blockly
.
unprefixName
(
name
);
var
pair
=
Blockly
.
unprefixName
(
name
);
var
prefix
=
pair
[
0
];
var
prefix
=
pair
[
0
];
var
unprefixedName
=
pair
[
1
];
var
unprefixedName
=
pair
[
1
];
if
(
prefix
===
Blockly
.
globalNamePrefix
)
{
if
(
prefix
===
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
)
{
name
=
Blockly
.
Yail
.
YAIL_GLOBAL_VAR_TAG
+
unprefixedName
;
name
=
Blockly
.
Yail
.
YAIL_GLOBAL_VAR_TAG
+
unprefixedName
;
command
=
Blockly
.
Yail
.
YAIL_GET_VARIABLE
;
command
=
Blockly
.
Yail
.
YAIL_GET_VARIABLE
;
}
else
{
}
else
{
...
@@ -106,7 +106,7 @@ Blockly.Yail['setVariableCommandAndName'] = function(name){
...
@@ -106,7 +106,7 @@ Blockly.Yail['setVariableCommandAndName'] = function(name){
var
pair
=
Blockly
.
unprefixName
(
name
);
var
pair
=
Blockly
.
unprefixName
(
name
);
var
prefix
=
pair
[
0
];
var
prefix
=
pair
[
0
];
var
unprefixedName
=
pair
[
1
];
var
unprefixedName
=
pair
[
1
];
if
(
prefix
===
Blockly
.
globalNamePrefix
)
{
if
(
prefix
===
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
)
{
name
=
Blockly
.
Yail
.
YAIL_GLOBAL_VAR_TAG
+
unprefixedName
;
name
=
Blockly
.
Yail
.
YAIL_GLOBAL_VAR_TAG
+
unprefixedName
;
command
=
Blockly
.
Yail
.
YAIL_SET_VARIABLE
;
command
=
Blockly
.
Yail
.
YAIL_SET_VARIABLE
;
}
else
{
}
else
{
...
...
appinventor/blocklyeditor/src/msg/en/_messages.js
View file @
7eec1088
...
@@ -941,6 +941,7 @@ Blockly.Msg.en.switch_language_to_english = {
...
@@ -941,6 +941,7 @@ Blockly.Msg.en.switch_language_to_english = {
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_DECLARATION_TO
=
'
to
'
;
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_DECLARATION_TO
=
'
to
'
;
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_DECLARATION_COLLAPSED_TEXT
=
'
global
'
;
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_DECLARATION_COLLAPSED_TEXT
=
'
global
'
;
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_DECLARATION_TOOLTIP
=
'
Creates a global variable and gives it the value of the attached blocks.
'
;
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_DECLARATION_TOOLTIP
=
'
Creates a global variable and gives it the value of the attached blocks.
'
;
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
=
'
global
'
;
Blockly
.
Msg
.
LANG_VARIABLES_GET_HELPURL
=
'
/reference/blocks/variables.html#get
'
;
Blockly
.
Msg
.
LANG_VARIABLES_GET_HELPURL
=
'
/reference/blocks/variables.html#get
'
;
Blockly
.
Msg
.
LANG_VARIABLES_GET_TITLE_GET
=
'
get
'
;
Blockly
.
Msg
.
LANG_VARIABLES_GET_TITLE_GET
=
'
get
'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment