Constructor
new Scratch3TranslateBlocks()
Members
(static) STATE_KEY
The key to load & store a target's translate state.
(private) _lastLangTranslated :string
The language of the text most recently translated.
Type:
- string
(private) _lastTextTranslated :string
The text most recently translated.
Type:
- string
(private) _randomLanguageCode :string
A randomly selected language code, for use as the default value in the language menu. Properly filled in getInfo so it is updated when the interface languages changes.
Type:
- string
(private) _supportedLanguages :Array.<object.<string, string>>
List of supported language name and language code pairs, for use in the block menu. Filled in by getInfo so it is updated when the interface language changes.
Type:
- Array.<object.<string, string>>
(private) _translateResult :string
The result from the most recent translation.
Type:
- string
(private) _viewerLanguageCode :string
Language code of the viewer, based on their locale.
Type:
- string
Methods
(private) _getSupportedLanguages(code) → {Array.<object.<string, string>>}
Computes a list of language code and name pairs for the given language.
Parameters:
Name | Type | Description |
---|---|---|
code |
string | The language code to get the list of language pairs |
Returns:
An array of languge name and language code pairs.
- Type
- Array.<object.<string, string>>
getInfo() → {object}
Returns:
metadata for this extension and its blocks.
- Type
- object
getLanguageCodeFromArg(arg) → {string}
Get a language code from a block argument. The arg can be a language code or a language name, written in any language.
Parameters:
Name | Type | Description |
---|---|---|
arg |
object | A block argument. |
Returns:
A language code.
- Type
- string
getTranslate(args) → {Promise}
Translates the text in the translate block to the language specified in the menu.
Parameters:
Name | Type | Description |
---|---|---|
args |
object | the block arguments. |
Returns:
- a promise that resolves after the response from the translate server.
- Type
- Promise
getViewerLanguage() → {string}
Get the human readable language value for the reporter block.
Returns:
the language name of the project viewer.
- Type
- string
getViewerLanguageCode() → {string}
Get the viewer's language code.
Returns:
the language code.
- Type
- string