easy-scratch/doc/scratch-vm/Scratch3TranslateBlocks.html

1433 lines
80 KiB
HTML
Raw Normal View History

2025-02-12 12:27:32 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Scratch3TranslateBlocks - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="-_StackFrame.html">_StackFrame</a><ul class='methods'><li data-type='method'><a href="-_StackFrame.html#.create">create</a></li><li data-type='method'><a href="-_StackFrame.html#.release">release</a></li><li data-type='method'><a href="-_StackFrame.html#reset">reset</a></li><li data-type='method'><a href="-_StackFrame.html#reuse">reuse</a></li></ul></li><li><a href="BLE.html">BLE</a><ul class='methods'><li data-type='method'><a href="BLE.html#connectPeripheral">connectPeripheral</a></li><li data-type='method'><a href="BLE.html#didReceiveCall">didReceiveCall</a></li><li data-type='method'><a href="BLE.html#disconnect">disconnect</a></li><li data-type='method'><a href="BLE.html#handleDisconnectError">handleDisconnectError</a></li><li data-type='method'><a href="BLE.html#isConnected">isConnected</a></li><li data-type='method'><a href="BLE.html#read">read</a></li><li data-type='method'><a href="BLE.html#requestPeripheral">requestPeripheral</a></li><li data-type='method'><a href="BLE.html#startNotifications">startNotifications</a></li><li data-type='method'><a href="BLE.html#write">write</a></li></ul></li><li><a href="BlockCached.html">BlockCached</a></li><li><a href="Blocks.html">Blocks</a><ul class='methods'><li data-type='method'><a href="Blocks.html#_addScript">_addScript</a></li><li data-type='method'><a href="Blocks.html#_deleteScript">_deleteScript</a></li><li data-type='method'><a href="Blocks.html#_getBackdropField">_getBackdropField</a></li><li data-type='method'><a href="Blocks.html#_getBlockParams">_getBlockParams</a></li><li data-type='method'><a href="Blocks.html#_getCostumeField">_getCostumeField</a></li><li data-type='method'><a href="Blocks.html#_getCustomBlockInternal">_getCustomBlockInternal</a></li><li data-type='method'><a href="Blocks.html#_getSoundField">_getSoundField</a></li><li data-type='method'><a href="Blocks.html#_getSpriteField">_getSpriteField</a></li><li data-type='method'><a href="Blocks.html#blocklyListen">blocklyListen</a></li><li data-type='method'><a href="Blocks.html#blockToXML">blockToXML</a></li><li data-type='method'><a href="Blocks.html#changeBlock">changeBlock</a></li><li data-type='method'><a href="Blocks.html#createBlock">createBlock</a></li><li data-type='method'><a href="Blocks.html#deleteBlock">deleteBlock</a></li><li data-type='method'><a href="Blocks.html#emitProjectChanged">emitProjectChanged</a></li><li data-type='method'><a href="Blocks.html#getAllVariableAndListReferences">getAllVariableAndListReferences</a></li><li data-type='method'><a href="Blocks.html#getBlock">getBlock</a></li><li data-type='method'><a href="Blocks.html#getBranch">getBranch</a></li><li data-type='method'><a href="Blocks.html#getFields">getFields</a></li><li data-type='method'><a href="Blocks.html#getInputs">getInputs</a></li><li data-type='method'><a href="Blocks.html#getMutation">getMutation</a></li><li data-type='method'><a href="Blocks.html#getNextBlock">getNextBlock</a></li><li data-type='method'><a href="Blocks.html#getOpcode">getOpcode</a></li><li data-type='method'><a href="Blocks.html#getProcedureDefinition">getProcedureDefinition</a></li><li data-type='method'><a href="Blocks.html#getProcedureParamNamesAndIds">getProcedureParamNamesAndIds</a></li><li data-type='method'><a href="Blocks.html#getProcedureParamNamesIdsAndDefaults">getProcedureParamNamesIdsAndDefaults</a></li><li data-type='method'><a href="Blocks.html#getScripts">getScripts</a></li><li data-type='method'><a href="Blocks.html#getTopLevelScript">getTopLevelScript</a></li><li data-type='method'><a href="Blocks.html#moveBlock">moveBlock</a></li><li data-type='method'><a href="Blocks.html#mutationToXML">mutationToXML</a></li><li data-type='method'><a href="Blocks.html#resetCache">resetCache</a></li><li data-type='method'><a href="Blocks.html#runAllMonitored">runAllMonitored</a></li><li data-type='method'><a href="Blocks.html#toXML">toXML</a></li><li data-type='method'><a href="Blocks.html#updateAssetName">updateAssetName</a></li><li data-type='method'><a href
</nav>
<div id="main">
<h1 class="page-title">Scratch3TranslateBlocks</h1>
<section>
<header>
<h2>
Scratch3TranslateBlocks
</h2>
<div class="class-description"><p>Class for the translate block in Scratch 3.0.</p></div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="Scratch3TranslateBlocks"><span class="type-signature"></span>new Scratch3TranslateBlocks<span class="signature">()</span><span class="type-signature"></span></h4>
<dl class="details">
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id=".STATE_KEY"><span class="type-signature">(static) </span>STATE_KEY<span class="type-signature"></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>The key to load &amp; store a target's translate state.</p>
</div>
<h4 class="name" id="_lastLangTranslated"><span class="type-signature">(private) </span>_lastLangTranslated<span class="type-signature"> :string</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>The language of the text most recently translated.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">string</span>
</li>
</ul>
<h4 class="name" id="_lastTextTranslated"><span class="type-signature">(private) </span>_lastTextTranslated<span class="type-signature"> :string</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>The text most recently translated.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">string</span>
</li>
</ul>
<h4 class="name" id="_randomLanguageCode"><span class="type-signature">(private) </span>_randomLanguageCode<span class="type-signature"> :string</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>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.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">string</span>
</li>
</ul>
<h4 class="name" id="_supportedLanguages"><span class="type-signature">(private) </span>_supportedLanguages<span class="type-signature"> :Array.&lt;object.&lt;string, string>></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>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.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Array.&lt;object.&lt;string, string>></span>
</li>
</ul>
<h4 class="name" id="_translateResult"><span class="type-signature">(private) </span>_translateResult<span class="type-signature"> :string</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>The result from the most recent translation.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">string</span>
</li>
</ul>
<h4 class="name" id="_viewerLanguageCode"><span class="type-signature">(private) </span>_viewerLanguageCode<span class="type-signature"> :string</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Language code of the viewer, based on their locale.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">string</span>
</li>
</ul>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="_getSupportedLanguages"><span class="type-signature">(private) </span>_getSupportedLanguages<span class="signature">(code)</span><span class="type-signature"> &rarr; {Array.&lt;object.&lt;string, string>>}</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Computes a list of language code and name pairs for the given language.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>code</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>The language code to get the list of language pairs</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>An array of languge name and
language code pairs.</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;object.&lt;string, string>></span>
</dd>
</dl>
<h4 class="name" id="getInfo"><span class="type-signature"></span>getInfo<span class="signature">()</span><span class="type-signature"> &rarr; {object}</span></h4>
<dl class="details">
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>metadata for this extension and its blocks.</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">object</span>
</dd>
</dl>
<h4 class="name" id="getLanguageCodeFromArg"><span class="type-signature"></span>getLanguageCodeFromArg<span class="signature">(arg)</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Get a language code from a block argument. The arg can be a language code
or a language name, written in any language.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>arg</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"><p>A block argument.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>A language code.</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id="getTranslate"><span class="type-signature"></span>getTranslate<span class="signature">(args)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Translates the text in the translate block to the language specified in the menu.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>args</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"><p>the block arguments.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<ul>
<li>a promise that resolves after the response from the translate server.</li>
</ul>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="getViewerLanguage"><span class="type-signature"></span>getViewerLanguage<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Get the human readable language value for the reporter block.</p>
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>the language name of the project viewer.</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id="getViewerLanguageCode"><span class="type-signature"></span>getViewerLanguageCode<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Get the viewer's language code.</p>
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>the language code.</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
</body>
</html>