tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

l10n.js (1276B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 const { LocalizationHelper } = require("resource://devtools/shared/l10n.js");
      8 loader.lazyRequireGetter(
      9  this,
     10  "BLOCKED_REASON_MESSAGES",
     11  "resource://devtools/client/netmonitor/src/constants.js",
     12  true
     13 );
     14 
     15 const NET_STRINGS_URI = "devtools/client/locales/netmonitor.properties";
     16 
     17 exports.L10N = new LocalizationHelper(NET_STRINGS_URI);
     18 
     19 function getBlockedReasonString(blockedReason, extension) {
     20  if (!blockedReason) {
     21    return null;
     22  }
     23 
     24  if (extension?.blocking) {
     25    return exports.L10N.getFormatStr(
     26      "networkMenu.blockedby",
     27      extension.blocking
     28    );
     29  }
     30 
     31  if (extension?.blocked) {
     32    return exports.L10N.getFormatStr(
     33      "networkMenu.addonBlocked",
     34      extension.blocked
     35    );
     36  }
     37 
     38  // If we receive a platform error code, print it as-is
     39  if (typeof blockedReason == "string" && blockedReason.startsWith("NS_")) {
     40    return blockedReason;
     41  }
     42 
     43  return (
     44    BLOCKED_REASON_MESSAGES[blockedReason] ||
     45    exports.L10N.getStr("networkMenu.blocked2")
     46  );
     47 }
     48 
     49 exports.getBlockedReasonString = getBlockedReasonString;