Bug 1949519 - Part 2: Load locales from XPI when newtab is running from that XPI. r=willdurand,eemeli,home-newtab-reviewers,frontend-codestyle-reviewers,nbarrett
Differential Revision: https://phabricator.services.mozilla.com/D244596
This commit is contained in:
@@ -82,6 +82,8 @@ module.exports = [
|
|||||||
|
|
||||||
// Ignore newtab files
|
// Ignore newtab files
|
||||||
"browser/extensions/newtab/logs/",
|
"browser/extensions/newtab/logs/",
|
||||||
|
// JS file using the #include pre-processor macro, leading to syntax errors.
|
||||||
|
"browser/extensions/newtab/webext-glue/builtin-newtab.js",
|
||||||
|
|
||||||
// Ignore devtools debugger files which aren't intended for linting.
|
// Ignore devtools debugger files which aren't intended for linting.
|
||||||
"devtools/client/debugger/bin/",
|
"devtools/client/debugger/bin/",
|
||||||
|
|||||||
@@ -1481,7 +1481,9 @@ browser/extensions/newtab/data/content/activity-stream.bundle.js
|
|||||||
browser/extensions/newtab/logs/
|
browser/extensions/newtab/logs/
|
||||||
browser/extensions/newtab/node_modules/
|
browser/extensions/newtab/node_modules/
|
||||||
browser/extensions/newtab/prerendered/
|
browser/extensions/newtab/prerendered/
|
||||||
|
browser/extensions/newtab/webext-glue/builtin-newtab.js
|
||||||
browser/extensions/newtab/webext-glue/locales/locales-report.json
|
browser/extensions/newtab/webext-glue/locales/locales-report.json
|
||||||
|
browser/extensions/newtab/webext-glue/locales/supported-locales.json
|
||||||
browser/locales/l10n-changesets.json
|
browser/locales/l10n-changesets.json
|
||||||
browser/locales/l10n-onchange-changesets.json
|
browser/locales/l10n-onchange-changesets.json
|
||||||
devtools/client/aboutdebugging/test/jest/node_modules/
|
devtools/client/aboutdebugging/test/jest/node_modules/
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ browser.jar:
|
|||||||
builtin-addons/newtab/manifest.json (./manifest.json)
|
builtin-addons/newtab/manifest.json (./manifest.json)
|
||||||
builtin-addons/newtab/webext-glue/background.js (./webext-glue/background.js)
|
builtin-addons/newtab/webext-glue/background.js (./webext-glue/background.js)
|
||||||
builtin-addons/newtab/webext-glue/schema.json (./webext-glue/schema.json)
|
builtin-addons/newtab/webext-glue/schema.json (./webext-glue/schema.json)
|
||||||
builtin-addons/newtab/webext-glue/builtin-newtab.js (./webext-glue/builtin-newtab.js)
|
* builtin-addons/newtab/webext-glue/builtin-newtab.js (./webext-glue/builtin-newtab.js)
|
||||||
builtin-addons/newtab/lib/ (./lib/*)
|
builtin-addons/newtab/lib/ (./lib/*)
|
||||||
builtin-addons/newtab/common/ (./common/*)
|
builtin-addons/newtab/common/ (./common/*)
|
||||||
* builtin-addons/newtab/data/content/abouthomecache/page.html.template (./data/content/abouthomecache/page.html.template)
|
* builtin-addons/newtab/data/content/abouthomecache/page.html.template (./data/content/abouthomecache/page.html.template)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ COMPARE_TOOL_PATH = Path(
|
|||||||
REPORT_PATH = Path(WEBEXT_LOCALES_PATH, "locales-report.json")
|
REPORT_PATH = Path(WEBEXT_LOCALES_PATH, "locales-report.json")
|
||||||
REPORT_LEFT_JUSTIFY_CHARS = 15
|
REPORT_LEFT_JUSTIFY_CHARS = 15
|
||||||
FLUENT_FILE_ANCESTRY = Path("browser", "newtab")
|
FLUENT_FILE_ANCESTRY = Path("browser", "newtab")
|
||||||
|
SUPPORTED_LOCALES_PATH = Path(WEBEXT_LOCALES_PATH, "supported-locales.json")
|
||||||
|
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@@ -105,6 +106,9 @@ def update_locales(command_context):
|
|||||||
# There are 2 parent folders of each FLUENT_FILE (see FLUENT_FILE_ANCESTRY),
|
# There are 2 parent folders of each FLUENT_FILE (see FLUENT_FILE_ANCESTRY),
|
||||||
# and we want to get at the locale folder root for our comparison.
|
# and we want to get at the locale folder root for our comparison.
|
||||||
ANCESTRY_LENGTH = 2
|
ANCESTRY_LENGTH = 2
|
||||||
|
|
||||||
|
# Get the full list of supported locales that we just pulled down
|
||||||
|
supported_locales = [path.parents[ANCESTRY_LENGTH].name for path in paths]
|
||||||
path_strs = [path.parents[ANCESTRY_LENGTH].as_posix() for path in paths]
|
path_strs = [path.parents[ANCESTRY_LENGTH].as_posix() for path in paths]
|
||||||
|
|
||||||
# Verbosity on the compare.py tool appears to be a count value, which is
|
# Verbosity on the compare.py tool appears to be a count value, which is
|
||||||
@@ -142,6 +146,10 @@ def update_locales(command_context):
|
|||||||
line_handler=on_line,
|
line_handler=on_line,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print("Writing supported locales to %s" % SUPPORTED_LOCALES_PATH)
|
||||||
|
with open(SUPPORTED_LOCALES_PATH, "w") as file:
|
||||||
|
json.dump(supported_locales, file)
|
||||||
|
|
||||||
print("Done")
|
print("Done")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ XPCOMUtils.defineLazyServiceGetter(
|
|||||||
"nsISubstitutingProtocolHandler"
|
"nsISubstitutingProtocolHandler"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const SUPPORTED_LOCALES =
|
||||||
|
#include locales/supported-locales.json
|
||||||
|
|
||||||
const lazy = {};
|
const lazy = {};
|
||||||
ChromeUtils.defineESModuleGetters(lazy, {
|
ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
AboutHomeStartupCache: "resource:///modules/AboutHomeStartupCache.sys.mjs",
|
AboutHomeStartupCache: "resource:///modules/AboutHomeStartupCache.sys.mjs",
|
||||||
@@ -58,6 +61,21 @@ this.builtin_newtab = class extends ExtensionAPI {
|
|||||||
let redirector = Cc[
|
let redirector = Cc[
|
||||||
"@mozilla.org/network/protocol/about;1?what=newtab"
|
"@mozilla.org/network/protocol/about;1?what=newtab"
|
||||||
].getService(Ci.nsIAboutModule).wrappedJSObject;
|
].getService(Ci.nsIAboutModule).wrappedJSObject;
|
||||||
|
|
||||||
|
if (this.extension.rootURI.spec.endsWith("newtab@mozilla.org.xpi!/")) {
|
||||||
|
// We must be a train-hopped XPI running in this app. This means we
|
||||||
|
// may have Fluent files or Glean pings/metrics to register dynamically.
|
||||||
|
const newtabFileSource = new L10nFileSource(
|
||||||
|
"newtab",
|
||||||
|
"app",
|
||||||
|
SUPPORTED_LOCALES,
|
||||||
|
`resource://newtab/locales/{locale}/`
|
||||||
|
);
|
||||||
|
L10nRegistry.getInstance().registerSources([newtabFileSource]);
|
||||||
|
|
||||||
|
// TODO: Dynamically register any Glean pings/metrics here.
|
||||||
|
}
|
||||||
|
|
||||||
redirector.builtInAddonInitialized();
|
redirector.builtInAddonInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
|||||||
|
["sl", "szl", "sk", "ur", "fy-NL", "mai", "xcl", "sw", "kab", "uz", "sc", "pl", "ca-valencia", "vi", "sq", "he", "ms", "km", "nn-NO", "be", "es-ES", "da", "gn", "mr", "kk", "trs", "es-CL", "ixl", "ja-JP-mac", "ja", "el", "sco", "lv", "es-AR", "oc", "it", "ca", "is", "cs", "es-MX", "scn", "ia", "te", "fur", "ga-IE", "ach", "ru", "tl", "en-GB", "meh", "mix", "hye", "hy-AM", "gu-IN", "xh", "ro", "hsb", "cak", "zh-CN", "hi-IN", "ckb", "uk", "sr", "brx", "en-CA", "frp", "ltg", "pt-PT", "si", "ml", "mk", "sat", "an", "lij", "kn", "bn-IN", "bs", "zh-TW", "my", "ar", "nb-NO", "gl", "gv", "hr", "pt-BR", "hu", "nl", "bg", "ks", "bn", "ast", "af", "ka", "de", "as", "az", "gd", "br", "skr", "ko", "fi", "crh", "son", "eo", "id", "fr", "sv-SE", "lg", "et", "fa", "lt", "ff", "or", "cy", "en-US", "eu", "bn-BD", "lo", "ne-NP", "rm", "dsb", "ta", "ace", "th", "pai", "tr", "wo", "pa-IN", "tg"]
|
||||||
@@ -22,9 +22,11 @@ FINAL_TARGET_FILES += [
|
|||||||
]
|
]
|
||||||
FINAL_TARGET_FILES["webext-glue"] += [
|
FINAL_TARGET_FILES["webext-glue"] += [
|
||||||
"background.js",
|
"background.js",
|
||||||
"builtin-newtab.js",
|
|
||||||
"schema.json",
|
"schema.json",
|
||||||
]
|
]
|
||||||
|
FINAL_TARGET_PP_FILES["webext-glue"] += [
|
||||||
|
"builtin-newtab.js",
|
||||||
|
]
|
||||||
FINAL_TARGET_FILES.lib += [
|
FINAL_TARGET_FILES.lib += [
|
||||||
"../lib/**",
|
"../lib/**",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1899,6 +1899,8 @@ class SchemaAPIManager extends EventEmitter {
|
|||||||
Glean,
|
Glean,
|
||||||
GleanPings,
|
GleanPings,
|
||||||
IOUtils,
|
IOUtils,
|
||||||
|
L10nFileSource,
|
||||||
|
L10nRegistry,
|
||||||
MatchGlob,
|
MatchGlob,
|
||||||
MatchPattern,
|
MatchPattern,
|
||||||
MatchPatternSet,
|
MatchPatternSet,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ browser/extensions/newtab/logs/
|
|||||||
browser/extensions/newtab/node_modules/
|
browser/extensions/newtab/node_modules/
|
||||||
browser/extensions/newtab/prerendered/
|
browser/extensions/newtab/prerendered/
|
||||||
browser/extensions/newtab/webext-glue/locales/locales-report.json
|
browser/extensions/newtab/webext-glue/locales/locales-report.json
|
||||||
|
browser/extensions/newtab/webext-glue/locales/supported-locales.json
|
||||||
browser/locales/l10n-changesets.json
|
browser/locales/l10n-changesets.json
|
||||||
browser/locales/l10n-onchange-changesets.json
|
browser/locales/l10n-onchange-changesets.json
|
||||||
devtools/client/aboutdebugging/test/jest/node_modules/
|
devtools/client/aboutdebugging/test/jest/node_modules/
|
||||||
|
|||||||
Reference in New Issue
Block a user