зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1529001 - Add locales to the build. r=johannh
Differential Revision: https://phabricator.services.mozilla.com/D20366 --HG-- rename : browser/extensions/fxmonitor/locale/en-US/strings.properties => browser/extensions/fxmonitor/locales/en-US/fxmonitor.properties extra : moz-landing-system : lando
This commit is contained in:
Родитель
a12ddd1865
Коммит
e0675a189f
|
@ -0,0 +1,8 @@
|
|||
#filter substitution
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
[features/fxmonitor@mozilla.org] @AB_CD@.jar:
|
||||
% locale fxmonitor @AB_CD@ %locale/@AB_CD@/
|
||||
locale/@AB_CD@/fxmonitor.properties (%fxmonitor.properties)
|
|
@ -0,0 +1,7 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
JAR_MANIFESTS += ['jar.mn']
|
|
@ -7,6 +7,8 @@
|
|||
DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION']
|
||||
DEFINES['MOZ_APP_MAXVERSION'] = CONFIG['MOZ_APP_MAXVERSION']
|
||||
|
||||
DIRS += ['locales']
|
||||
|
||||
FINAL_TARGET_FILES.features['fxmonitor@mozilla.org'] += [
|
||||
'background.js',
|
||||
'manifest.json'
|
||||
|
@ -30,9 +32,5 @@ FINAL_TARGET_FILES.features['fxmonitor@mozilla.org']['privileged']['subscripts']
|
|||
'privileged/subscripts/PanelUI.jsm'
|
||||
]
|
||||
|
||||
FINAL_TARGET_FILES.features['fxmonitor@mozilla.org']['locale']['en-US'] += [
|
||||
'locale/en-US/strings.properties'
|
||||
]
|
||||
|
||||
with Files('**'):
|
||||
BUG_COMPONENT = ('Firefox', 'Firefox Monitor')
|
||||
|
|
|
@ -22,7 +22,8 @@ this.FirefoxMonitor = {
|
|||
// Whether we've started observing for the user visiting a breached site.
|
||||
observerAdded: false,
|
||||
|
||||
// loadStrings loads a stringbundle into this property.
|
||||
// This is here for documentation, will be redefined to a lazy getter
|
||||
// that creates and returns a string bundle in loadStrings().
|
||||
strings: null,
|
||||
|
||||
// This is here for documentation, will be redefined to a pref getter
|
||||
|
@ -83,7 +84,6 @@ this.FirefoxMonitor = {
|
|||
}
|
||||
},
|
||||
|
||||
|
||||
// Used to enforce idempotency of delayedInit. delayedInit is
|
||||
// called in startObserving() to ensure we load our strings, etc.
|
||||
_delayedInited: false,
|
||||
|
@ -145,27 +145,27 @@ this.FirefoxMonitor = {
|
|||
this._delayedInited = true;
|
||||
},
|
||||
|
||||
async loadStrings() {
|
||||
// Services.strings.createBundle has a whitelist of URL schemes that it
|
||||
// accepts. moz-extension: is not one of them, so we work around that
|
||||
// by reading the file manually and creating a data: URL (allowed).
|
||||
let response;
|
||||
let locale = Services.locale.defaultLocale;
|
||||
try {
|
||||
response = await fetch(this.getURL(`locale/${locale}/strings.properties`));
|
||||
} catch (e) {
|
||||
Cu.reportError(`Firefox Monitor: no strings available for ${locale}. Falling back to en-US.`);
|
||||
response = await fetch(this.getURL(`locale/en-US/strings.properties`));
|
||||
loadStrings() {
|
||||
let l10nManifest;
|
||||
if (this.extension.rootURI instanceof Ci.nsIJARURI) {
|
||||
l10nManifest = this.extension.rootURI.JARFile
|
||||
.QueryInterface(Ci.nsIFileURL).file;
|
||||
} else if (this.extension.rootURI instanceof Ci.nsIFileURL) {
|
||||
l10nManifest = this.extension.rootURI.file;
|
||||
}
|
||||
let buffer = await response.arrayBuffer();
|
||||
let binary = "";
|
||||
let bytes = new Uint8Array(buffer);
|
||||
let len = bytes.byteLength;
|
||||
for (let i = 0; i < len; i++) {
|
||||
binary += String.fromCharCode(bytes[i]);
|
||||
|
||||
if (l10nManifest) {
|
||||
Components.manager.addBootstrappedManifestLocation(l10nManifest);
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "strings", () => {
|
||||
return Services.strings.createBundle(
|
||||
"chrome://fxmonitor/locale/fxmonitor.properties");
|
||||
});
|
||||
} else {
|
||||
// Something is very strange if we reach this line, so we throw
|
||||
// in order to prevent init from completing and burst the stack.
|
||||
throw "Cannot find fxmonitor chrome.manifest for registering translated strings";
|
||||
}
|
||||
let b64 = btoa(binary);
|
||||
this.strings = Services.strings.createBundle(`data:text/plain;base64,${b64}`);
|
||||
},
|
||||
|
||||
kRemoteSettingsKey: "fxmonitor-breaches",
|
||||
|
|
|
@ -13,6 +13,7 @@ dirs = browser
|
|||
devtools/client
|
||||
devtools/startup
|
||||
browser/extensions/formautofill
|
||||
browser/extensions/fxmonitor
|
||||
browser/extensions/webcompat-reporter
|
||||
|
||||
[includes]
|
||||
|
|
|
@ -128,6 +128,10 @@ locales = [
|
|||
reference = "browser/extensions/formautofill/locales/en-US/**"
|
||||
l10n = "{l}browser/extensions/formautofill/**"
|
||||
|
||||
[[paths]]
|
||||
reference = "browser/extensions/fxmonitor/locales/en-US/**"
|
||||
l10n = "{l}browser/extensions/fxmonitor/**"
|
||||
|
||||
[[paths]]
|
||||
reference = "browser/extensions/webcompat-reporter/locales/en-US/**"
|
||||
l10n = "{l}browser/extensions/webcompat-reporter/**"
|
||||
|
|
Загрузка…
Ссылка в новой задаче