mirror of
https://github.com/goauthentik/authentik
synced 2026-05-10 17:12:08 +02:00
* web: bump typescript from 5.8.3 to 5.9.3 in /web Bumps [typescript](https://github.com/microsoft/TypeScript) from 5.8.3 to 5.9.3. - [Release notes](https://github.com/microsoft/TypeScript/releases) - [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release-publish.yml) - [Commits](https://github.com/microsoft/TypeScript/compare/v5.8.3...v5.9.3) --- updated-dependencies: - dependency-name: typescript dependency-version: 5.9.3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * fix up ish Signed-off-by: Jens Langhammer <jens@goauthentik.io> * web: Fix typing. * web: assign array type. --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: Teffen Ellis <teffen@goauthentik.io>
69 lines
2.1 KiB
JavaScript
69 lines
2.1 KiB
JavaScript
/// <reference types="node" />
|
|
|
|
/**
|
|
* @file Pseudo-localization script.
|
|
*
|
|
* @import { ConfigFile } from "@lit/localize-tools/lib/types/config.js"
|
|
* @import { Config } from '@lit/localize-tools/lib/types/config.js';
|
|
* @import { ProgramMessage } from "@lit/localize-tools/src/messages.js"
|
|
* @import { Locale } from "@lit/localize-tools/src/types/locale.js"
|
|
*/
|
|
|
|
import { readFileSync } from "node:fs";
|
|
import path from "node:path";
|
|
|
|
import { PackageRoot } from "#paths/node";
|
|
|
|
import pseudolocale from "pseudolocale";
|
|
|
|
import { makeFormatter } from "@lit/localize-tools/lib/formatters/index.js";
|
|
import { sortProgramMessages } from "@lit/localize-tools/lib/messages.js";
|
|
import { TransformLitLocalizer } from "@lit/localize-tools/lib/modes/transform.js";
|
|
|
|
const pseudoLocale = /** @type {Locale} */ ("pseudo-LOCALE");
|
|
const targetLocales = [pseudoLocale];
|
|
|
|
/**
|
|
* @type {ConfigFile}
|
|
*/
|
|
const baseConfig = JSON.parse(readFileSync(path.join(PackageRoot, "lit-localize.json"), "utf-8"));
|
|
|
|
// Need to make some internal specifications to satisfy the transformer. It doesn't actually matter
|
|
// which Localizer we use (transformer or runtime), because all of the functionality we care about
|
|
// is in their common parent class, but I had to pick one. Everything else here is just pure
|
|
// exploitation of the lit/localize-tools internals.
|
|
|
|
/**
|
|
* @satisfies {Config}
|
|
*/
|
|
const config = {
|
|
...baseConfig,
|
|
baseDir: path.join(__dirname, ".."),
|
|
targetLocales,
|
|
output: {
|
|
...baseConfig.output,
|
|
mode: "transform",
|
|
},
|
|
resolve: (path) => path,
|
|
};
|
|
|
|
/**
|
|
*
|
|
* @param {ProgramMessage} message
|
|
* @returns
|
|
*/
|
|
const pseudoMessagify = (message) => ({
|
|
name: message.name,
|
|
contents: message.contents.map((content) =>
|
|
typeof content === "string" ? pseudolocale(content, { prepend: "", append: "" }) : content,
|
|
),
|
|
});
|
|
|
|
const localizer = new TransformLitLocalizer(config);
|
|
const { messages } = localizer.extractSourceMessages();
|
|
const translations = messages.map(pseudoMessagify);
|
|
const sorted = sortProgramMessages([...messages]);
|
|
const formatter = makeFormatter(config);
|
|
|
|
formatter.writeOutput(sorted, new Map([[pseudoLocale, translations]]));
|