Set the terms to empty string when building
This commit is contained in:
parent
aa9b7cccc7
commit
638e4e6410
@ -9,6 +9,8 @@ import * as babelParser from "@babel/parser";
|
||||
import babelGenerate from "@babel/generator";
|
||||
import * as babelTypes from "@babel/types";
|
||||
import { escapeStringForPropertiesFile } from "../../tools/escapeStringForPropertiesFile";
|
||||
import { getThisCodebaseRootDirPath } from "../../tools/getThisCodebaseRootDirPath";
|
||||
import * as fs from "fs";
|
||||
|
||||
export function generateMessageProperties(params: {
|
||||
themeSrcDirPath: string;
|
||||
@ -39,10 +41,6 @@ export function generateMessageProperties(params: {
|
||||
readFileSync(file).toString("utf8").includes("createUseI18n")
|
||||
);
|
||||
|
||||
if (files.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const extraMessages = files
|
||||
.map(file => {
|
||||
const root = recast.parse(readFileSync(file).toString("utf8"), {
|
||||
@ -99,15 +97,28 @@ export function generateMessageProperties(params: {
|
||||
return extraMessages;
|
||||
});
|
||||
|
||||
const languageTags = extraMessages
|
||||
.map(extraMessage => Object.keys(extraMessage))
|
||||
.flat()
|
||||
.reduce(...removeDuplicates<string>());
|
||||
const languageTags = [
|
||||
...extraMessages.map(extraMessage => Object.keys(extraMessage)).flat(),
|
||||
...fs
|
||||
.readdirSync(
|
||||
pathJoin(
|
||||
getThisCodebaseRootDirPath(),
|
||||
"src",
|
||||
themeType,
|
||||
"i18n",
|
||||
"baseMessages"
|
||||
)
|
||||
)
|
||||
.filter(baseName => baseName !== "index.ts")
|
||||
.map(baseName => baseName.replace(/\.ts$/, ""))
|
||||
].reduce(...removeDuplicates<string>());
|
||||
|
||||
const keyValueMapByLanguageTag: Record<string, Record<string, string>> = {};
|
||||
|
||||
for (const languageTag of languageTags) {
|
||||
const keyValueMap: Record<string, string> = {};
|
||||
const keyValueMap: Record<string, string> = {
|
||||
termsText: ""
|
||||
};
|
||||
|
||||
for (const extraMessage of extraMessages) {
|
||||
const keyValueMap_i = extraMessage[languageTag];
|
||||
@ -152,14 +163,9 @@ export function generateMessageProperties(params: {
|
||||
|
||||
out.push({
|
||||
languageTag,
|
||||
propertiesFileSource: [
|
||||
"# This file was generated by keycloakify",
|
||||
"",
|
||||
"parent=base",
|
||||
"",
|
||||
propertiesFileSource,
|
||||
""
|
||||
].join("\n")
|
||||
propertiesFileSource: ["", "parent=base", "", propertiesFileSource, ""].join(
|
||||
"\n"
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -205,15 +205,7 @@ function createI18nTranslationFunctionsFactory<MessageKey extends string, ExtraM
|
||||
const messageOrUndefined = (messages_currentLanguage as any)[key] ?? (messages_fallbackLanguage as any)[key];
|
||||
|
||||
if (key === "termsText") {
|
||||
if (params.messages_currentLanguage === undefined) {
|
||||
return " ";
|
||||
}
|
||||
|
||||
if (realmMessageBundleTermsText !== messageOrUndefined) {
|
||||
return realmMessageBundleTermsText;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return realmMessageBundleTermsText;
|
||||
}
|
||||
|
||||
return messageOrUndefined;
|
||||
|
Loading…
x
Reference in New Issue
Block a user