chore(lang): updated translations from crowdin (#1612)

Co-authored-by: Crowdin Homarr <190541745+homarr-crowdin[bot]@users.noreply.github.com>
Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
This commit is contained in:
homarr-crowdin[bot]
2024-12-05 07:00:41 +01:00
committed by GitHub
parent a5b366a92e
commit 86cd1017b9
29 changed files with 53981 additions and 1988 deletions

View File

@@ -1,6 +1,7 @@
import deepmerge from "deepmerge";
import { getRequestConfig } from "next-intl/server";
import type { TranslationObject } from ".";
import { fallbackLocale, isLocaleSupported } from ".";
import type { SupportedLanguage } from "./config";
import { createLanguageMapping } from "./mapping";
@@ -15,7 +16,7 @@ export default getRequestConfig(async ({ requestLocale }) => {
const typedLocale = currentLocale as SupportedLanguage;
const languageMap = createLanguageMapping();
const currentMessages = (await languageMap[typedLocale]()).default;
const currentMessages = removeEmptyTranslations((await languageMap[typedLocale]()).default) as TranslationObject;
// Fallback to default locale if the current locales messages if not all messages are present
if (currentLocale !== fallbackLocale) {
@@ -31,3 +32,26 @@ export default getRequestConfig(async ({ requestLocale }) => {
messages: currentMessages,
};
});
const removeEmptyTranslations = (translations: Record<string, unknown>): Record<string, unknown> => {
return Object.entries(translations).reduce(
(acc, [key, value]) => {
if (typeof value !== "string") {
return {
...acc,
[key]: removeEmptyTranslations(value as Record<string, unknown>),
};
}
if (value.trim() === "") {
return acc;
}
return {
...acc,
[key]: value,
};
},
{} as Record<string, unknown>,
);
};