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
4e08a869
Commit
4e08a869
authored
Jul 11, 2019
by
Susan Rati Lane
Committed by
Jeffrey Schiller
Aug 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add internationalization to component block tooltips in Blocks Editor
Change-Id: I4a399d8a3defb239f7cd74384a3ba4b465710234
parent
c92c6ac4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
17 deletions
+44
-17
appinventor/blocklyeditor/src/blocks/components.js
appinventor/blocklyeditor/src/blocks/components.js
+8
-17
appinventor/blocklyeditor/src/component_database.js
appinventor/blocklyeditor/src/component_database.js
+36
-0
No files found.
appinventor/blocklyeditor/src/blocks/components.js
View file @
4e08a869
...
@@ -280,10 +280,10 @@ Blockly.Blocks.component_event = {
...
@@ -280,10 +280,10 @@ Blockly.Blocks.component_event = {
this
.
setParameterOrientation
(
horizParams
);
this
.
setParameterOrientation
(
horizParams
);
var
tooltipDescription
;
var
tooltipDescription
;
if
(
eventType
)
{
if
(
eventType
)
{
tooltipDescription
=
eventType
.
description
;
tooltipDescription
=
componentDb
.
getInternationalizedEventDescription
(
eventType
.
name
)
;
}
}
else
{
else
{
tooltipDescription
=
Blockly
.
Msg
.
UNDEFINED_BLOCK_TOOLTIP
;
tooltipDescription
=
componentDb
.
getInternationalizedEventDescription
(
this
.
eventName
)
;
}
}
this
.
setTooltip
(
tooltipDescription
);
this
.
setTooltip
(
tooltipDescription
);
this
.
setPreviousStatement
(
false
,
null
);
this
.
setPreviousStatement
(
false
,
null
);
...
@@ -563,9 +563,6 @@ Blockly.Blocks.component_event = {
...
@@ -563,9 +563,6 @@ Blockly.Blocks.component_event = {
if
(
isDefined
)
{
if
(
isDefined
)
{
this
.
notBadBlock
();
this
.
notBadBlock
();
if
(
this
.
getEventTypeObject
())
{
this
.
setTooltip
(
this
.
getEventTypeObject
().
description
);
// update the tooltipDescription, if block is defined
}
}
else
{
}
else
{
this
.
badBlock
();
this
.
badBlock
();
}
}
...
@@ -711,9 +708,9 @@ Blockly.Blocks.component_method = {
...
@@ -711,9 +708,9 @@ Blockly.Blocks.component_method = {
var
tooltipDescription
;
var
tooltipDescription
;
if
(
methodTypeObject
)
{
if
(
methodTypeObject
)
{
tooltipDescription
=
methodTypeObject
.
description
;
tooltipDescription
=
componentDb
.
getInternationalizedMethodDescription
(
methodTypeObject
.
name
)
;
}
else
{
}
else
{
tooltipDescription
=
Blockly
.
Msg
.
UNDEFINED_BLOCK_TOOLTIP
;
tooltipDescription
=
componentDb
.
getInternationalizedMethodDescription
(
this
.
typeName
)
;
}
}
this
.
setTooltip
(
tooltipDescription
);
this
.
setTooltip
(
tooltipDescription
);
...
@@ -912,9 +909,6 @@ Blockly.Blocks.component_method = {
...
@@ -912,9 +909,6 @@ Blockly.Blocks.component_method = {
var
isDefined
=
validate
.
call
(
this
);
var
isDefined
=
validate
.
call
(
this
);
if
(
isDefined
)
{
if
(
isDefined
)
{
this
.
notBadBlock
();
this
.
notBadBlock
();
if
(
this
.
getMethodTypeObject
())
{
this
.
setTooltip
(
this
.
getMethodTypeObject
().
description
);
// update the tooltipDescription, if block is defined
}
}
else
{
}
else
{
this
.
badBlock
();
this
.
badBlock
();
}
}
...
@@ -1000,8 +994,8 @@ Blockly.Blocks.component_set_get = {
...
@@ -1000,8 +994,8 @@ Blockly.Blocks.component_set_get = {
this
.
setColour
(
Blockly
.
ComponentBlock
.
COLOUR_GET
);
this
.
setColour
(
Blockly
.
ComponentBlock
.
COLOUR_GET
);
}
}
var
tooltipDescription
;
var
tooltipDescription
;
if
(
this
.
property
Object
)
{
if
(
this
.
property
Name
)
{
tooltipDescription
=
this
.
propertyObject
.
description
;
tooltipDescription
=
componentDb
.
getInternationalizedPropertyDescription
(
this
.
propertyName
)
;
}
else
{
}
else
{
tooltipDescription
=
Blockly
.
Msg
.
UNDEFINED_BLOCK_TOOLTIP
;
tooltipDescription
=
Blockly
.
Msg
.
UNDEFINED_BLOCK_TOOLTIP
;
}
}
...
@@ -1016,8 +1010,8 @@ Blockly.Blocks.component_set_get = {
...
@@ -1016,8 +1010,8 @@ Blockly.Blocks.component_set_get = {
thisBlock
.
propertyName
=
selection
;
thisBlock
.
propertyName
=
selection
;
thisBlock
.
propertyObject
=
thisBlock
.
getPropertyObject
(
selection
);
thisBlock
.
propertyObject
=
thisBlock
.
getPropertyObject
(
selection
);
thisBlock
.
setTypeCheck
();
thisBlock
.
setTypeCheck
();
if
(
thisBlock
.
property
Object
)
{
if
(
thisBlock
.
property
Name
)
{
thisBlock
.
setTooltip
(
thisBlock
.
propertyObject
.
description
);
thisBlock
.
setTooltip
(
componentDb
.
getInternationalizedPropertyDescription
(
thisBlock
.
propertyName
)
);
}
else
{
}
else
{
thisBlock
.
setTooltip
(
Blockly
.
Msg
.
UNDEFINED_BLOCK_TOOLTIP
);
thisBlock
.
setTooltip
(
Blockly
.
Msg
.
UNDEFINED_BLOCK_TOOLTIP
);
}
}
...
@@ -1251,9 +1245,6 @@ Blockly.Blocks.component_set_get = {
...
@@ -1251,9 +1245,6 @@ Blockly.Blocks.component_set_get = {
var
isDefined
=
validate
.
call
(
this
);
var
isDefined
=
validate
.
call
(
this
);
if
(
isDefined
)
{
if
(
isDefined
)
{
this
.
notBadBlock
();
this
.
notBadBlock
();
if
(
this
.
propertyObject
)
{
this
.
setTooltip
(
this
.
propertyObject
.
description
);
// update the tooltipDescription, if block is defined
}
}
else
{
}
else
{
this
.
badBlock
(
true
);
this
.
badBlock
(
true
);
}
}
...
...
appinventor/blocklyeditor/src/component_database.js
View file @
4e08a869
...
@@ -104,9 +104,12 @@ Blockly.ComponentDatabase = function() {
...
@@ -104,9 +104,12 @@ Blockly.ComponentDatabase = function() {
// Internationalization support
// Internationalization support
this
.
i18nComponentTypes_
=
{};
this
.
i18nComponentTypes_
=
{};
this
.
i18nEventNames_
=
{};
this
.
i18nEventNames_
=
{};
this
.
i18nEventDescriptions_
=
{};
this
.
i18nMethodNames_
=
{};
this
.
i18nMethodNames_
=
{};
this
.
i18nMethodDescriptions_
=
{};
this
.
i18nParamNames_
=
{};
this
.
i18nParamNames_
=
{};
this
.
i18nPropertyNames_
=
{};
this
.
i18nPropertyNames_
=
{};
this
.
i18nPropertyDescriptions_
=
{};
};
};
/**
/**
...
@@ -375,6 +378,12 @@ Blockly.ComponentDatabase.prototype.populateTranslations = function(translations
...
@@ -375,6 +378,12 @@ Blockly.ComponentDatabase.prototype.populateTranslations = function(translations
this
.
i18nMethodNames_
[
parts
[
1
]]
=
translations
[
key
];
this
.
i18nMethodNames_
[
parts
[
1
]]
=
translations
[
key
];
}
else
if
(
parts
[
0
]
==
'
PARAM
'
)
{
}
else
if
(
parts
[
0
]
==
'
PARAM
'
)
{
this
.
i18nParamNames_
[
parts
[
1
]]
=
translations
[
key
];
this
.
i18nParamNames_
[
parts
[
1
]]
=
translations
[
key
];
}
else
if
(
parts
[
0
]
==
'
EVENTDESC
'
)
{
this
.
i18nEventDescriptions_
[
parts
[
1
]]
=
translations
[
key
];
}
else
if
(
parts
[
0
]
==
'
METHDESC
'
)
{
this
.
i18nMethodDescriptions_
[
parts
[
1
]]
=
translations
[
key
];
}
else
if
(
parts
[
0
]
==
'
PROPDESC
'
)
{
this
.
i18nPropertyDescriptions_
[
parts
[
1
]]
=
translations
[
key
];
}
}
}
}
}
}
...
@@ -504,6 +513,15 @@ Blockly.ComponentDatabase.prototype.getInternationalizedEventName = function(nam
...
@@ -504,6 +513,15 @@ Blockly.ComponentDatabase.prototype.getInternationalizedEventName = function(nam
return
this
.
i18nEventNames_
[
name
]
||
name
;
return
this
.
i18nEventNames_
[
name
]
||
name
;
};
};
/**
* Get the internationalized string for the given event description tooltip.
* @param {!string} name String naming a component event
* @returns {string} The localized string if available, otherwise the unlocalized name.
*/
Blockly
.
ComponentDatabase
.
prototype
.
getInternationalizedEventDescription
=
function
(
name
)
{
return
this
.
i18nEventDescriptions_
[
name
]
||
name
;
};
/**
/**
* Get the internationalized string for the given method name.
* Get the internationalized string for the given method name.
* @param {!string} name String naming a component method
* @param {!string} name String naming a component method
...
@@ -513,6 +531,15 @@ Blockly.ComponentDatabase.prototype.getInternationalizedMethodName = function(na
...
@@ -513,6 +531,15 @@ Blockly.ComponentDatabase.prototype.getInternationalizedMethodName = function(na
return
this
.
i18nMethodNames_
[
name
]
||
name
;
return
this
.
i18nMethodNames_
[
name
]
||
name
;
};
};
/**
* Get the internationalized string for the given method name.
* @param {!string} name String naming a component method
* @returns {string} The localized string if available, otherwise the unlocalized name.
*/
Blockly
.
ComponentDatabase
.
prototype
.
getInternationalizedMethodDescription
=
function
(
name
)
{
return
this
.
i18nMethodDescriptions_
[
name
]
||
name
;
};
/**
/**
* Get the internationalized string for the given parameter name.
* Get the internationalized string for the given parameter name.
* @param {!string} name String naming a component event or method parameter
* @param {!string} name String naming a component event or method parameter
...
@@ -530,3 +557,12 @@ Blockly.ComponentDatabase.prototype.getInternationalizedParameterName = function
...
@@ -530,3 +557,12 @@ Blockly.ComponentDatabase.prototype.getInternationalizedParameterName = function
Blockly
.
ComponentDatabase
.
prototype
.
getInternationalizedPropertyName
=
function
(
name
)
{
Blockly
.
ComponentDatabase
.
prototype
.
getInternationalizedPropertyName
=
function
(
name
)
{
return
this
.
i18nPropertyNames_
[
name
]
||
name
;
return
this
.
i18nPropertyNames_
[
name
]
||
name
;
};
};
/**
* Get the internationalized string for the given property description tooltip.
* @param {!string} name String naming a component property
* @returns {string} The localized string if available, otherwise the unlocalized name.
*/
Blockly
.
ComponentDatabase
.
prototype
.
getInternationalizedPropertyDescription
=
function
(
name
)
{
return
this
.
i18nPropertyDescriptions_
[
name
]
||
name
;
};
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