| import MainWorldContentScriptBridgeServer from '../mainWorldContentScriptBridge/Server.js'; |
| import {kCSTarget, kMWTarget} from './consts.js'; |
| // Main World i18n server (used in content scripts to be able to serve the |
| // chrome.i18n API to Main World (MW) scripts). |
| export default class MWI18nServer extends MainWorldContentScriptBridgeServer { |
| super(kCSTarget, kMWTarget); |
| this.setUpHandler(this.handleMessage); |
| handleMessage(uuid, action, request) { |
| var response = chrome.i18n.getMessage( |
| request.messageName, request.substitutions, request.options); |
| this._respond(uuid, response); |
| this._respond(uuid, chrome.i18n.getUILanguage()); |
| console.error(`[MWI18nServer] Invalid action received (${action})`); |