Skip to content

Commit

Permalink
chore(lang): updated translations from crowdin (#1612)
Browse files Browse the repository at this point in the history
Co-authored-by: Crowdin Homarr <190541745+homarr-crowdin[bot]@users.noreply.github.com>
Co-authored-by: Meier Lukas <[email protected]>
  • Loading branch information
homarr-crowdin[bot] and Meierschlumpf authored Dec 5, 2024
1 parent a5b366a commit 86cd101
Show file tree
Hide file tree
Showing 29 changed files with 53,962 additions and 1,969 deletions.
1,963 changes: 1,893 additions & 70 deletions packages/translation/src/lang/cs.json

Large diffs are not rendered by default.

1,993 changes: 1,908 additions & 85 deletions packages/translation/src/lang/da.json

Large diffs are not rendered by default.

2,009 changes: 1,916 additions & 93 deletions packages/translation/src/lang/de.json

Large diffs are not rendered by default.

1,959 changes: 1,891 additions & 68 deletions packages/translation/src/lang/el.json

Large diffs are not rendered by default.

1,981 changes: 1,902 additions & 79 deletions packages/translation/src/lang/es.json

Large diffs are not rendered by default.

1,971 changes: 1,902 additions & 69 deletions packages/translation/src/lang/et.json

Large diffs are not rendered by default.

1,981 changes: 1,902 additions & 79 deletions packages/translation/src/lang/fr.json

Large diffs are not rendered by default.

1,951 changes: 1,887 additions & 64 deletions packages/translation/src/lang/he.json

Large diffs are not rendered by default.

1,965 changes: 1,894 additions & 71 deletions packages/translation/src/lang/hr.json

Large diffs are not rendered by default.

1,957 changes: 1,890 additions & 67 deletions packages/translation/src/lang/hu.json

Large diffs are not rendered by default.

1,993 changes: 1,908 additions & 85 deletions packages/translation/src/lang/it.json

Large diffs are not rendered by default.

1,963 changes: 1,893 additions & 70 deletions packages/translation/src/lang/ja.json

Large diffs are not rendered by default.

1,971 changes: 1,897 additions & 74 deletions packages/translation/src/lang/ko.json

Large diffs are not rendered by default.

1,961 changes: 1,894 additions & 67 deletions packages/translation/src/lang/lt.json

Large diffs are not rendered by default.

1,963 changes: 1,893 additions & 70 deletions packages/translation/src/lang/lv.json

Large diffs are not rendered by default.

1,981 changes: 1,902 additions & 79 deletions packages/translation/src/lang/nl.json

Large diffs are not rendered by default.

1,971 changes: 1,897 additions & 74 deletions packages/translation/src/lang/no.json

Large diffs are not rendered by default.

1,961 changes: 1,892 additions & 69 deletions packages/translation/src/lang/pl.json

Large diffs are not rendered by default.

1,981 changes: 1,902 additions & 79 deletions packages/translation/src/lang/pt.json

Large diffs are not rendered by default.

1,979 changes: 1,901 additions & 78 deletions packages/translation/src/lang/ro.json

Large diffs are not rendered by default.

1,959 changes: 1,891 additions & 68 deletions packages/translation/src/lang/ru.json

Large diffs are not rendered by default.

1,961 changes: 1,892 additions & 69 deletions packages/translation/src/lang/sk.json

Large diffs are not rendered by default.

1,959 changes: 1,891 additions & 68 deletions packages/translation/src/lang/sl.json

Large diffs are not rendered by default.

1,973 changes: 1,898 additions & 75 deletions packages/translation/src/lang/sv.json

Large diffs are not rendered by default.

1,957 changes: 1,890 additions & 67 deletions packages/translation/src/lang/tr.json

Large diffs are not rendered by default.

1,951 changes: 1,887 additions & 64 deletions packages/translation/src/lang/uk.json

Large diffs are not rendered by default.

1,957 changes: 1,890 additions & 67 deletions packages/translation/src/lang/vi.json

Large diffs are not rendered by default.

2,734 changes: 2,734 additions & 0 deletions packages/translation/src/lang/zh.json

Large diffs are not rendered by default.

26 changes: 25 additions & 1 deletion packages/translation/src/request.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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) {
Expand All @@ -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>,
);
};

0 comments on commit 86cd101

Please sign in to comment.