Merge pull request #2920 from ericrosenbaum/do-not-translate-only-numbers

Do not translate strings containing only digits
This commit is contained in:
Eric Rosenbaum 2021-03-02 12:42:41 -05:00 committed by GitHub
commit f71f2b7fe2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -247,6 +247,10 @@ class Scratch3TranslateBlocks {
* @return {Promise} - a promise that resolves after the response from the translate server.
*/
getTranslate (args) {
// If the text contains only digits 0-9 and nothing else, return it without
// making a request.
if (/^\d+$/.test(args.WORDS)) return Promise.resolve(args.WORDS);
// Don't remake the request if we already have the value.
if (this._lastTextTranslated === args.WORDS &&
this._lastLangTranslated === args.LANGUAGE) {