diff --git a/core/blockly.ts b/core/blockly.ts index f7b3e9b5542..b1d2cc20d4d 100644 --- a/core/blockly.ts +++ b/core/blockly.ts @@ -118,7 +118,7 @@ import {MarkerManager} from './marker_manager.js'; import {Menu} from './menu.js'; import {MenuItem} from './menuitem.js'; import {MetricsManager} from './metrics_manager.js'; -import {Msg} from './msg.js'; +import {Msg, setLocale} from './msg.js'; import {Mutator} from './mutator.js'; import {Names} from './names.js'; import {Options} from './options.js'; @@ -560,17 +560,6 @@ export const VARIABLE_DYNAMIC_CATEGORY_NAME: string = */ export const PROCEDURE_CATEGORY_NAME: string = Procedures.CATEGORY_NAME; -/** - * Sets the locale (i.e. the localized messages/block-text/etc) to the given - * locale. - * - * @param locale An object defining the messages for the given language. - */ -export const setLocale = function(locale: {[key: string]: string}) { - Object.keys(locale).forEach(function(k) { - Blockly.Msg[k] = locale[k]; - }); -}; // Context for why we need to monkey-patch in these functions (internal): // https://docs.google.com/document/d/1MbO0LEA-pAyx1ErGLJnyUqTLrcYTo-5zga9qplnxeXo/edit?usp=sharing&resourcekey=0-5h_32-i-dHwHjf_9KYEVKg @@ -732,7 +721,7 @@ export {Menu}; export {MenuItem}; export {MetricsManager}; export {Mutator}; -export {Msg}; +export {Msg, setLocale}; export {Names}; export {Options}; export {RenderedConnection}; diff --git a/core/msg.ts b/core/msg.ts index 4d4c440d56b..33bc93e6416 100644 --- a/core/msg.ts +++ b/core/msg.ts @@ -15,3 +15,15 @@ goog.declareModuleId('Blockly.Msg'); /** A dictionary of localised messages. */ export const Msg: {[key: string]: string} = Object.create(null); + +/** + * Sets the locale (i.e. the localized messages/block-text/etc) to the given + * locale. + * + * @param locale An object defining the messages for a given language. + */ +export const setLocale = function(locale: {[key: string]: string}) { + Object.keys(locale).forEach(function(k) { + Msg[k] = locale[k]; + }); +}; diff --git a/scripts/package/browser/core.js b/scripts/package/browser/core.js index a0b0d92593a..7471feda61d 100644 --- a/scripts/package/browser/core.js +++ b/scripts/package/browser/core.js @@ -12,9 +12,3 @@ /* eslint-disable */ 'use strict'; -// Add a helper method to set the Blockly locale. -Blockly.setLocale = function (locale) { - Object.keys(locale).forEach(function (k) { - Blockly.Msg[k] = locale[k]; - }); -}; diff --git a/scripts/package/node/core.js b/scripts/package/node/core.js index 2135b966dfb..11e77b5b6a9 100644 --- a/scripts/package/node/core.js +++ b/scripts/package/node/core.js @@ -12,12 +12,6 @@ /* eslint-disable */ 'use strict'; -// Add a helper method to set the Blockly locale. -Blockly.setLocale = function (locale) { - Object.keys(locale).forEach(function (k) { - Blockly.Msg[k] = locale[k]; - }); -}; // Override textToDomDocument and provide Node.js alternatives to DOMParser and // XMLSerializer.