mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Merge pull request #19430 from Snuffleupagus/Fluent-PLATFORM
[GENERIC viewer] Add Fluent `PLATFORM` function (PR 19414 follow-up)
This commit is contained in:
commit
41a918b0fe
2 changed files with 32 additions and 7 deletions
|
@ -15,14 +15,33 @@
|
|||
|
||||
/** @typedef {import("./interfaces").IL10n} IL10n */
|
||||
|
||||
import { FeatureTest, fetchData } from "pdfjs-lib";
|
||||
import { FluentBundle, FluentResource } from "fluent-bundle";
|
||||
import { DOMLocalization } from "fluent-dom";
|
||||
import { fetchData } from "pdfjs-lib";
|
||||
import { L10n } from "./l10n.js";
|
||||
|
||||
function PLATFORM() {
|
||||
const { isAndroid, isLinux, isMac, isWindows } = FeatureTest.platform;
|
||||
if (isLinux) {
|
||||
return "linux";
|
||||
}
|
||||
if (isWindows) {
|
||||
return "windows";
|
||||
}
|
||||
if (isMac) {
|
||||
return "macos";
|
||||
}
|
||||
if (isAndroid) {
|
||||
return "android";
|
||||
}
|
||||
return "other";
|
||||
}
|
||||
|
||||
function createBundle(lang, text) {
|
||||
const resource = new FluentResource(text);
|
||||
const bundle = new FluentBundle(lang);
|
||||
const bundle = new FluentBundle(lang, {
|
||||
functions: { PLATFORM },
|
||||
});
|
||||
const errors = bundle.addResource(resource);
|
||||
if (errors.length) {
|
||||
console.error("L10n errors", errors);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue