tor-browser

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

l10n.js (1562B)


      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 const L10N = new LocalizationHelper(
      9  "devtools/client/locales/animationinspector.properties"
     10 );
     11 const INSPECTOR_L10N = new LocalizationHelper(
     12  "devtools/client/locales/inspector.properties"
     13 );
     14 
     15 /**
     16 * Get a formatted title for this animation. This will be either:
     17 * "%S", "%S : CSS Transition", "%S : CSS Animation",
     18 * "%S : Script Animation", or "Script Animation", depending
     19 * if the server provides the type, what type it is and if the animation
     20 * has a name.
     21 *
     22 * @param {object} state
     23 */
     24 function getFormattedTitle(state) {
     25  // Older servers don't send a type, and only know about
     26  // CSSAnimations and CSSTransitions, so it's safe to use
     27  // just the name.
     28  if (!state.type) {
     29    return state.name;
     30  }
     31 
     32  // Script-generated animations may not have a name.
     33  if (state.type === "scriptanimation" && !state.name) {
     34    return L10N.getStr("timeline.scriptanimation.unnamedLabel");
     35  }
     36 
     37  return L10N.getFormatStr(`timeline.${state.type}.nameLabel`, state.name);
     38 }
     39 
     40 module.exports = {
     41  getFormatStr: (...args) => L10N.getFormatStr(...args),
     42  getFormattedTitle,
     43  getInspectorStr: (...args) => INSPECTOR_L10N.getStr(...args),
     44  getStr: (...args) => L10N.getStr(...args),
     45  numberWithDecimals: (...args) => L10N.numberWithDecimals(...args),
     46 };