mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 23:12:24 -05:00
- Update the reporter to return the human readable language.
- Remove the non-final icons and replace with a TODO. - Add messages for the text in the blocks.
This commit is contained in:
parent
f615e9191a
commit
e2f6dfd29f
1 changed files with 27 additions and 11 deletions
|
@ -6,9 +6,6 @@ const nets = require('nets');
|
||||||
const languageNames = require('scratch-translate-extension-languages');
|
const languageNames = require('scratch-translate-extension-languages');
|
||||||
const formatMessage = require('format-message');
|
const formatMessage = require('format-message');
|
||||||
|
|
||||||
// TODO: Change these to the correct icons.
|
|
||||||
const blockIconURI = 'https://www.gstatic.com/images/icons/material/system/1x/translate_white_24dp.png';
|
|
||||||
const menuIconURI = 'https://www.gstatic.com/images/icons/material/system/1x/translate_grey600_24dp.png';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The url of the translate server.
|
* The url of the translate server.
|
||||||
|
@ -82,17 +79,25 @@ class Scratch3TranslateBlocks {
|
||||||
return {
|
return {
|
||||||
id: 'translate',
|
id: 'translate',
|
||||||
name: 'Translate',
|
name: 'Translate',
|
||||||
menuIconURI: menuIconURI,
|
menuIconURI: '', // TODO: Add the final icons.
|
||||||
blockIconURI: blockIconURI,
|
blockIconURI: '',
|
||||||
blocks: [
|
blocks: [
|
||||||
{
|
{
|
||||||
opcode: 'getTranslate',
|
opcode: 'getTranslate',
|
||||||
text: 'translate [WORDS] to [LANGUAGE]',
|
text: formatMessage({
|
||||||
|
id: 'translate.translateBlock',
|
||||||
|
default: 'translate [WORDS] to [LANGUAGE]',
|
||||||
|
description: 'translate some text to a different language'
|
||||||
|
}),
|
||||||
blockType: BlockType.REPORTER,
|
blockType: BlockType.REPORTER,
|
||||||
arguments: {
|
arguments: {
|
||||||
WORDS: {
|
WORDS: {
|
||||||
type: ArgumentType.STRING,
|
type: ArgumentType.STRING,
|
||||||
defaultValue: 'hello'
|
defaultValue: formatMessage({
|
||||||
|
id: 'translate.defaultTextToTranslate',
|
||||||
|
default: 'hello',
|
||||||
|
description: 'hello: the default text to translate'
|
||||||
|
})
|
||||||
},
|
},
|
||||||
LANGUAGE: {
|
LANGUAGE: {
|
||||||
type: ArgumentType.STRING,
|
type: ArgumentType.STRING,
|
||||||
|
@ -103,7 +108,11 @@ class Scratch3TranslateBlocks {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
opcode: 'getViewerLanguage',
|
opcode: 'getViewerLanguage',
|
||||||
text: 'viewer language',
|
text: formatMessage({
|
||||||
|
id: 'translate.viewerLanguage',
|
||||||
|
default: 'viewer language',
|
||||||
|
description: 'the languge of the project viewer'
|
||||||
|
}),
|
||||||
blockType: BlockType.REPORTER,
|
blockType: BlockType.REPORTER,
|
||||||
arguments: {}
|
arguments: {}
|
||||||
}
|
}
|
||||||
|
@ -115,11 +124,18 @@ class Scratch3TranslateBlocks {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the viewer language for the reporter block.
|
* Get the human readable language value for the reporter block.
|
||||||
* @return {string} the language code of the project viewer.
|
* @return {string} the language name of the project viewer.
|
||||||
*/
|
*/
|
||||||
getViewerLanguage () {
|
getViewerLanguage () {
|
||||||
return this._viewerLanguageCode;
|
this._viewerLanguageCode = this.getViewerLanguageCode();
|
||||||
|
const names = languageNames.menuMap[this._viewerLanguageCode];
|
||||||
|
const langNameObj = names.find(obj => obj.code === this._viewerLanguageCode);
|
||||||
|
let langName = this._viewerLanguageCode;
|
||||||
|
if (langNameObj) {
|
||||||
|
langName = langNameObj.name;
|
||||||
|
}
|
||||||
|
return langName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue