Skip to content

Commit

Permalink
windows: support translations (#193)
Browse files Browse the repository at this point in the history
Co-authored-by: Shane Osbourne <[email protected]>
  • Loading branch information
shakyShane and Shane Osbourne authored Oct 17, 2024
1 parent acb35e4 commit ee8c6cb
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 12 deletions.
26 changes: 15 additions & 11 deletions build/app/public/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -4807,7 +4807,8 @@
permissions: z3.array(z3.unknown()).optional(),
certificates: z3.array(z3.unknown()).optional(),
cookiePromptManagementStatus: cookiePromptManagementStatusSchema.optional(),
isInvalidCert: z3.boolean().optional()
isInvalidCert: z3.boolean().optional(),
localeSettings: localeSettingsSchema.optional()
});
toggleReportScreenSchema = z3.object({
data: z3.array(toggleReportScreenDataItemSchema)
Expand Down Expand Up @@ -10252,7 +10253,7 @@
};

// node_modules/@formatjs/icu-messageformat-parser/lib/date-time-pattern-generator.js
function getBestPattern(skeleton, locale3) {
function getBestPattern(skeleton, locale4) {
var skeletonCopy = "";
for (var patternPos = 0; patternPos < skeleton.length; patternPos++) {
var patternChar = skeleton.charAt(patternPos);
Expand All @@ -10265,7 +10266,7 @@
var hourLen = 1 + (extraLength & 1);
var dayPeriodLen = extraLength < 2 ? 1 : 3 + (extraLength >> 1);
var dayPeriodChar = "a";
var hourChar = getDefaultHourSymbolFromLocale(locale3);
var hourChar = getDefaultHourSymbolFromLocale(locale4);
if (hourChar == "H" || hourChar == "k") {
dayPeriodLen = 0;
}
Expand All @@ -10283,12 +10284,12 @@
}
return skeletonCopy;
}
function getDefaultHourSymbolFromLocale(locale3) {
var hourCycle = locale3.hourCycle;
function getDefaultHourSymbolFromLocale(locale4) {
var hourCycle = locale4.hourCycle;
if (hourCycle === void 0 && // @ts-ignore hourCycle(s) is not identified yet
locale3.hourCycles && // @ts-ignore
locale3.hourCycles.length) {
hourCycle = locale3.hourCycles[0];
locale4.hourCycles && // @ts-ignore
locale4.hourCycles.length) {
hourCycle = locale4.hourCycles[0];
}
if (hourCycle) {
switch (hourCycle) {
Expand All @@ -10304,10 +10305,10 @@
throw new Error("Invalid hourCycle");
}
}
var languageTag = locale3.language;
var languageTag = locale4.language;
var regionTag;
if (languageTag !== "root") {
regionTag = locale3.maximize().region;
regionTag = locale4.maximize().region;
}
var hourCycles = timeData[regionTag || ""] || timeData[languageTag || ""] || timeData["".concat(languageTag, "-001")] || timeData["001"];
return hourCycles[0];
Expand Down Expand Up @@ -14577,13 +14578,15 @@
var protections3;
var isPendingUpdates3;
var parentEntity3;
var locale3;
var combineSources3 = () => ({
tab: Object.assign(
{},
trackerBlockingData3 || {},
{
isPendingUpdates: isPendingUpdates3,
parentEntity: parentEntity3
parentEntity: parentEntity3,
locale: locale3
},
permissionsData3 ? { permissions: permissionsData3 } : {},
certificateData3 ? { certificate: certificateData3 } : {}
Expand All @@ -14605,6 +14608,7 @@
permissionsData3 = viewModel.permissions || [];
certificateData3 = viewModel.certificates || [];
protections3 = viewModel.protections;
locale3 = viewModel.localeSettings?.locale;
trackerBlockingData3 = createTabData(viewModel.tabUrl, upgradedHttps3, viewModel.protections, viewModel.rawRequestData);
trackerBlockingData3.cookiePromptManagementStatus = viewModel.cookiePromptManagementStatus;
trackerBlockingData3.isInvalidCert = viewModel.isInvalidCert;
Expand Down
3 changes: 2 additions & 1 deletion schema/__generated__/schema.parsers.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema/__generated__/schema.types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions schema/windows-view-model.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"cookiePromptManagementStatus": { "$ref": "./cookie-prompt-management-status.json" },
"isInvalidCert": {
"type": "boolean"
},
"localeSettings": {
"$ref": "locale.json"
}
}
}
5 changes: 5 additions & 0 deletions shared/js/browser/windows-communication.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,17 @@ let protections
let isPendingUpdates
let parentEntity

/** @type {string | undefined} */
let locale

const combineSources = () => ({
tab: Object.assign(
{},
trackerBlockingData || {},
{
isPendingUpdates,
parentEntity,
locale,
},
permissionsData ? { permissions: permissionsData } : {},
certificateData ? { certificate: certificateData } : {}
Expand Down Expand Up @@ -103,6 +107,7 @@ function handleViewModelUpdate(viewModel) {
permissionsData = viewModel.permissions || []
certificateData = viewModel.certificates || []
protections = viewModel.protections
locale = viewModel.localeSettings?.locale

trackerBlockingData = createTabData(viewModel.tabUrl, upgradedHttps, viewModel.protections, viewModel.rawRequestData)
trackerBlockingData.cookiePromptManagementStatus = viewModel.cookiePromptManagementStatus
Expand Down
1 change: 1 addition & 0 deletions shared/js/ui/views/tests/generate-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ export class MockData {
certificates: this.certificate,
cookiePromptManagementStatus: this.cookiePromptManagementStatus,
isInvalidCert: this.isInvalidCert,
localeSettings: this.localeSettings,
},
}
}
Expand Down

0 comments on commit ee8c6cb

Please sign in to comment.