How to use the webextension-polyfill.i18n function in webextension-polyfill

To help you get started, we’ve selected a few webextension-polyfill examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dessant / clear-browsing-data / src / utils / common.js View on Github external
import browser from 'webextension-polyfill';

const getText = browser.i18n.getMessage;

async function createTab(
  url,
  {index = null, active = true, openerTabId = null} = {}
) {
  const props = {url, active};
  if (index !== null) {
    props.index = index;
  }
  if (
    openerTabId !== null &&
    openerTabId !== browser.tabs.TAB_ID_NONE &&
    !(await isAndroid())
  ) {
    props.openerTabId = openerTabId;
  }
github ipfs-shipyard / ipfs-companion / add-on / src / options / forms / global-toggle-form.js View on Github external
function globalToggleForm ({ active, onOptionChange }) {
  const toggle = onOptionChange('active')
  return html`
    <form class="dib mb3">
      <label class="dib pa3 flex items-center pointer ${!active ? 'charcoal bg-gray-muted br2' : ''}" for="active">
        ${switchToggle({ id: 'active', checked: active, onchange: toggle, style: 'mr3' })}
        ${browser.i18n.getMessage('panel_headerActiveToggleTitle')}
      </label>
    </form>
  `
}
github sienori / Tab-Session-Manager / src / popup / components / Session.js View on Github external
getOpenButtonTitle = () => {
    const defaultBehavior = getSettings("openButtonBehavior");
    switch (defaultBehavior) {
      case "openInNewWindow":
        return browser.i18n.getMessage("openInNewWindowLabel");
      case "openInCurrentWindow":
        return browser.i18n.getMessage("openInCurrentWindowLabel");
      case "addToCurrentWindow":
        return browser.i18n.getMessage("addToCurrentWindowLabel");
      default:
        return "";
    }
  };
github dessant / buster / src / utils / common.js View on Github external
import browser from 'webextension-polyfill';
import Bowser from 'bowser';

import {targetEnv} from 'utils/config';

const getText = browser.i18n.getMessage;

function createTab(
  url,
  {index = null, active = true, openerTabId = null} = {}
) {
  const props = {url, active};
  if (index !== null) {
    props.index = index;
  }
  if (openerTabId !== null && ['chrome', 'opera'].includes(targetEnv)) {
    props.openerTabId = openerTabId;
  }
  return browser.tabs.create(props);
}

async function isAndroid() {
github sienori / Tab-Session-Manager / src / background / backup.js View on Github external
function returnFileName(sessions) {
  log.log(logDir, "returnFileName()", sessions);
  const sessionLabel = browser.i18n.getMessage("sessionLabel").toLowerCase();
  const sessionsLabel = browser.i18n.getMessage("sessionsLabel").toLowerCase();

  let fileName = `${moment().format(getSettings("dateFormat"))} (${sessions.length} ${
    sessions.length == 1 ? sessionLabel : sessionsLabel
  })`;

  const pattern = /\\|\/|\:|\?|\.|"|&lt;|&gt;|\|/g;
  fileName = fileName.replace(pattern, "-");
  return fileName;
}
github sienori / Tab-Session-Manager / src / background / updateOldSessions.js View on Github external
const updateAutoName = () => {
    for (let i in sessions) {
      if (sessions[i].tag.includes("winClose")) {
        if (sessions[i].name === "Auto Saved - Window was closed")
          sessions[i].name = browser.i18n.getMessage("winCloseSessionName");
      } else if (sessions[i].tag.includes("regular")) {
        if (sessions[i].name === "Auto Saved - Regularly")
          sessions[i].name = browser.i18n.getMessage("regularSaveSessionName");
      }
    }
  };
  updateTags();
github foray1010 / Popup-my-Bookmarks / src / popup / components / Editor / index.tsx View on Github external
closeEditor()
    },
    [closeEditor, createBookmarkAfterId, editBookmark, isCreating, targetId],
  )

  return (
    &lt;&gt;
github sienori / Tab-Session-Manager / src / options / components / CategoryContainer.js View on Github external
export default props =&gt; {
  const { category, elements } = props;
  return (
    <li>
      <fieldset>
        <legend>
          <p>
            {category !== "" ? browser.i18n.getMessage(category) : ""}
          </p>
        </legend>
        <ul>
          {elements.map((option, index) =&gt; (
            <div>
              
                {option.hasOwnProperty("childElements") ? (
                  <ul>
                    {option.childElements.map((option, index) =&gt; (
                      
                    ))}
                  </ul>
                ) : (
                  ""
                )}
              </div></ul></fieldset></li>
github FirefoxBar / HeaderEditor / src / core / utils.js View on Github external
t(key, params) {
		const s = browser.i18n.getMessage(key, params)
		return s || key;
	},
	getDomain(url) {
github foray1010 / Popup-my-Bookmarks / src / options / components / OptionForm / OptionForm.tsx View on Github external
optionValue={optionValue}
                  updatePartialOptions={props.updatePartialOptions}
                /&gt;,
              ]
            }

            return acc
          },
          [],
        )}
      
      
        
          
            
          
          
            
          
        
      
    
  
)