From 7ebfad6d92f16df0649c1124138b8678e346a01e Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 23 Jul 2024 09:43:12 +0200 Subject: [PATCH] Replace the GENERIC-only "locale" with "localeProperties" in AppOptions Since "localeProperties" is needed in Firefox, let's remove a tiny bit of option duplication by using it in the GENERIC builds as well. For convenience, the old debug-only "locale" hash-parameter is kept intact. --- web/app.js | 2 +- web/app_options.js | 10 ++++------ web/genericcom.js | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/web/app.js b/web/app.js index 8078c8be8c57a..92b35ceb24d91 100644 --- a/web/app.js +++ b/web/app.js @@ -336,7 +336,7 @@ const PDFViewerApplication = { (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) && params.has("locale") ) { - AppOptions.set("locale", params.get("locale")); + AppOptions.set("localeProperties", { lang: params.get("locale") }); } // Set some specific preferences for tests. diff --git a/web/app_options.js b/web/app_options.js index 456f5ce26c8b9..cefd57035d5f1 100644 --- a/web/app_options.js +++ b/web/app_options.js @@ -90,7 +90,10 @@ const defaultOptions = { }, localeProperties: { /** @type {Object} */ - value: null, + value: + typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC") + ? { lang: navigator.language || "en-US" } + : null, kind: OptionKind.BROWSER, }, nimbusDataStr: { @@ -468,11 +471,6 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { value: typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING"), kind: OptionKind.VIEWER, }; - defaultOptions.locale = { - /** @type {string} */ - value: navigator.language || "en-US", - kind: OptionKind.VIEWER, - }; } else if (PDFJSDev.test("CHROME")) { defaultOptions.disableTelemetry = { /** @type {boolean} */ diff --git a/web/genericcom.js b/web/genericcom.js index 0e224dc247508..dc3d60a98c878 100644 --- a/web/genericcom.js +++ b/web/genericcom.js @@ -39,7 +39,7 @@ class Preferences extends BasePreferences { class ExternalServices extends BaseExternalServices { async createL10n() { - return new GenericL10n(AppOptions.get("locale")); + return new GenericL10n(AppOptions.get("localeProperties")?.lang); } createScripting() {