Skip to content

Commit

Permalink
show genre transliteration on english locale
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedriad1 committed Sep 25, 2024
1 parent 9dae222 commit 783bb92
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function generateImageMetadata({
const genre = await findGenreBySlug(genreSlug);
if (!genre) return [];

const primaryText = getPrimaryLocalizedText(genre.nameTranslations, "en");
const primaryText = getPrimaryLocalizedText(genre.nameTranslations, "ar");

return [
{
Expand All @@ -54,7 +54,7 @@ export default async function Image({
notFound();
}

const primaryText = getPrimaryLocalizedText(genre.nameTranslations, "en");
const primaryText = genre.transliteration;

// Font
const [calSans, family] = await Promise.all([
Expand Down
12 changes: 9 additions & 3 deletions src/app/[locale]/(entityPages)/genre/[genreSlug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ export const generateMetadata = async ({
if (!genre) return;

const locale = await getPathLocale();
const primaryText = getPrimaryLocalizedText(genre.nameTranslations, locale);
const primaryText =
locale === "en"
? genre.transliteration
: getPrimaryLocalizedText(genre.nameTranslations, locale);

return getMetadata({
hasImage: true,
pagePath: navigation.genres.bySlug(genreSlug),
title: primaryText,
title: primaryText ?? "",
});
};

Expand Down Expand Up @@ -69,7 +72,10 @@ async function GenrePage({
},
});

const primaryName = getPrimaryLocalizedText(genre.nameTranslations, locale);
const primaryName =
locale === "en"
? genre.transliteration
: getPrimaryLocalizedText(genre.nameTranslations, locale);
const secondaryName = null;

return (
Expand Down
10 changes: 6 additions & 4 deletions src/app/[locale]/t/[bookId]/_components/content-tab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,12 @@ export default function ContentTab({ bookResponse }: TabProps) {
variant="secondary"
className="font-normal"
>
{getPrimaryLocalizedText(
genre.nameTranslations,
pathLocale,
)}
{pathLocale === "en"
? genre.transliteration
: getPrimaryLocalizedText(
genre.nameTranslations,
pathLocale,
)}
</Badge>
</Link>
))}
Expand Down
5 changes: 4 additions & 1 deletion src/components/genre-search-result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export default async function GenreSearchResult({
const pathLocale = await getPathLocale();

const genre = result.document;
const name = getPrimaryLocalizedText(genre.nameTranslations, pathLocale);
const name =
pathLocale === "en"
? genre.transliteration
: getPrimaryLocalizedText(genre.nameTranslations, pathLocale);

return (
<Link
Expand Down
8 changes: 4 additions & 4 deletions src/components/genres-filter/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ export default function _GenresFilter({
// const count = genreIdToBooksCount[genre.genreId.toLowerCase()] ?? 0;
const booksCount = formatter.number(genre._count.books);

const primaryText = getPrimaryLocalizedText(
genre.nameTranslations,
locale,
);
const primaryText =
locale === "en"
? genre.transliteration
: getPrimaryLocalizedText(genre.nameTranslations, locale);
const title = `${primaryText} (${booksCount})`;

return (
Expand Down

0 comments on commit 783bb92

Please sign in to comment.