mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-25 05:41:13 +00:00
Update translation submodule (#2023)
* Update translation submodule * Fix translation generation error
This commit is contained in:
parent
d2fa599fe4
commit
47c8c80111
1 changed files with 4 additions and 4 deletions
|
@ -8,12 +8,12 @@ fs.readdir(translationDir, (_err, files) => {
|
||||||
const lang = filename.split(".")[0];
|
const lang = filename.split(".")[0];
|
||||||
try {
|
try {
|
||||||
const json = JSON.parse(
|
const json = JSON.parse(
|
||||||
fs.readFileSync(translationDir + filename, "utf8")
|
fs.readFileSync(translationDir + filename, "utf8"),
|
||||||
);
|
);
|
||||||
let data = `export const ${lang} = {\n translation: {`;
|
let data = `export const ${lang} = {\n translation: {`;
|
||||||
for (const key in json) {
|
for (const key in json) {
|
||||||
if (key in json) {
|
if (key in json) {
|
||||||
const value = json[key].replace(/"/g, '\\"');
|
const value = json[key].replace(/"/g, '\\"').replace("\n", "\\n");
|
||||||
data += `\n ${key}: "${value}",`;
|
data += `\n ${key}: "${value}",`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,14 +67,14 @@ ${optionKeys.map(key => `${indent}| "${key}"`).join("\n")};
|
||||||
export type I18nKeys = NoOptionI18nKeys | OptionI18nKeys;
|
export type I18nKeys = NoOptionI18nKeys | OptionI18nKeys;
|
||||||
|
|
||||||
export type TTypedOptions<TKey extends OptionI18nKeys> =${Array.from(
|
export type TTypedOptions<TKey extends OptionI18nKeys> =${Array.from(
|
||||||
optionMap.entries()
|
optionMap.entries(),
|
||||||
).reduce(
|
).reduce(
|
||||||
(acc, [key, options]) =>
|
(acc, [key, options]) =>
|
||||||
`${acc} TKey extends \"${key}\" ? ${
|
`${acc} TKey extends \"${key}\" ? ${
|
||||||
options.reduce((acc, cur) => acc + `${cur}: string | number; `, "{ ") +
|
options.reduce((acc, cur) => acc + `${cur}: string | number; `, "{ ") +
|
||||||
"}"
|
"}"
|
||||||
} :\n${indent}`,
|
} :\n${indent}`,
|
||||||
""
|
"",
|
||||||
)} (Record<string, unknown> | string);
|
)} (Record<string, unknown> | string);
|
||||||
|
|
||||||
export interface TFunctionTyped {
|
export interface TFunctionTyped {
|
||||||
|
|
Loading…
Reference in a new issue