addon-sdk/source/lib/sdk/l10n/json/core.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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  "use strict";
     6 module.metadata = {
     7   "stability": "unstable"
     8 };
    10 let usingJSON = false;
    11 let hash = {}, bestMatchingLocale = null;
    12 try {
    13   let data = require("@l10n/data");
    14   hash = data.hash;
    15   bestMatchingLocale = data.bestMatchingLocale;
    16   usingJSON = true;
    17 }
    18 catch(e) {}
    20 exports.usingJSON = usingJSON;
    22 // Returns the translation for a given key, if available.
    23 exports.get = function get(k) {
    24   return k in hash ? hash[k] : null;
    25 }
    27 // Returns the full length locale code: ja-JP-mac, en-US or fr
    28 exports.locale = function locale() {
    29   return bestMatchingLocale;
    30 }
    31 // Returns the short locale code: ja, en, fr
    32 exports.language = function language() {
    33   return bestMatchingLocale ? bestMatchingLocale.split("-")[0].toLowerCase()
    34                             : null;
    35 }

mercurial