Merge pull request #687 from movie-web/fix-666

Specify defaultValue in random extra title
This commit is contained in:
Jip Frijlink 2023-12-31 16:38:38 +01:00 committed by GitHub
commit 2c4c0edb77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,7 +14,10 @@ export function useRandomTranslation() {
const defaultTitle = t(`${key}.default`) ?? "";
if (!shouldJoke) return defaultTitle;
const keys = t(`${key}.extra`, { returnObjects: true });
const keys = t(`${key}.extra`, {
returnObjects: true,
defaultValue: defaultTitle,
});
if (Array.isArray(keys)) {
if (keys.length === 0) return defaultTitle;
return keys[Math.floor(seed * keys.length)];