Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lazy load translations and date-fns, server side support for "Browser…
… Default" language (#2380) * Lazy load i18n translations. * Lazy load date-fns * Fix inconsistent DOMContentLoaded event. Only when no translations and date-fns have to be dynamically loaded (e.g. for en-US) the NavBar `componentDidMount` is early enough to listen for "DOMContentLoaded". Removes one redundant `requestNotificationPermission()` call. * Rename interface language code "pt_BR" to "pt-BR". Browsers ask for "pt-BR", but the "interface_language" saved in the settings dialog asks for "pt_BR". This change will make the settings dialog ask for "pt-BR" instead of "pt_BR". For users that already (or still) have "pt_BR" configured, "pt-BR" will be used, but the settings dialog will present it as unspecified. * Use Accept-Language request header * Prefetch translation and date-fns --------- Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com>
- Loading branch information
1 parent
c80136e
commit e832cd2
Showing
13 changed files
with
493 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { verifyTranslationImports } from "./services/I18NextService"; | ||
import { verifyDateFnsImports } from "@utils/app/setup-date-fns"; | ||
|
||
export class ImportReport { | ||
error: Array<{ id: string; error: Error | string | undefined }> = []; | ||
success: string[] = []; | ||
} | ||
|
||
export type ImportReportCollection = { | ||
translation?: ImportReport; | ||
"date-fns"?: ImportReport; | ||
}; | ||
|
||
function collect( | ||
verbose: boolean, | ||
kind: keyof ImportReportCollection, | ||
collection: ImportReportCollection, | ||
report: ImportReport, | ||
) { | ||
collection[kind] = report; | ||
if (verbose) { | ||
for (const { id, error } of report.error) { | ||
console.warn(`${kind} "${id}" failed: ${error}`); | ||
} | ||
const good = report.success.length; | ||
const bad = report.error.length; | ||
if (bad) { | ||
console.error(`${bad} out of ${bad + good} ${kind} imports failed.`); | ||
} else { | ||
console.log(`${good} ${kind} imports verified.`); | ||
} | ||
} | ||
} | ||
|
||
// This verifies that the parameters used for parameterized imports are | ||
// correct, that the respective chunks are reachable or bundled, and that the | ||
// returned objects match expectations. | ||
export async function verifyDynamicImports( | ||
verbose: boolean, | ||
): Promise<ImportReportCollection> { | ||
const collection: ImportReportCollection = {}; | ||
await verifyTranslationImports().then(report => | ||
collect(verbose, "translation", collection, report), | ||
); | ||
await verifyDateFnsImports().then(report => | ||
collect(verbose, "date-fns", collection, report), | ||
); | ||
return collection; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.