Replace raw string by translated strings

This commit is contained in:
DrMint 2022-05-15 10:14:45 +02:00
parent 0b97d9f73d
commit b2b2b00735
13 changed files with 304 additions and 310 deletions

View File

@ -325,6 +325,12 @@ export function AppLayout(props: Immutable<Props>): JSX.Element {
]) ])
) )
} }
insertLabels={
new Map([
[0, langui.primary_language],
[1, langui.secondary_language],
])
}
onChange={(items) => { onChange={(items) => {
const preferredLanguages = [...items].map( const preferredLanguages = [...items].map(
([code]) => code ([code]) => code

View File

@ -5,6 +5,7 @@ import { useEffect, useState } from "react";
interface Props { interface Props {
className?: string; className?: string;
items: Map<string, string>; items: Map<string, string>;
insertLabels?: Map<number, string | null | undefined>;
onChange?: (items: Map<string, string>) => void; onChange?: (items: Map<string, string>) => void;
} }
@ -25,12 +26,8 @@ export function OrderableList(props: Immutable<Props>): JSX.Element {
<div className="grid gap-2"> <div className="grid gap-2">
{[...items].map(([key, value], index) => ( {[...items].map(([key, value], index) => (
<> <>
{index === 0 ? ( {props.insertLabels?.get(index) && (
<p>Primary language</p> <p>{props.insertLabels.get(index)}</p>
) : index === 1 ? (
<p>Secondary languages</p>
) : (
""
)} )}
<div <div
onDragStart={(event) => { onDragStart={(event) => {

View File

@ -31,7 +31,7 @@ export function ScanSetCover(props: Immutable<Props>): JSX.Element {
const [selectedScan, LanguageSwitcher] = useSmartLanguage({ const [selectedScan, LanguageSwitcher] = useSmartLanguage({
items: images, items: images,
languages: languages, languages: languages,
languageExtractor: (item) => item?.language?.data?.attributes?.code, languageExtractor: (item) => item.language?.data?.attributes?.code,
}); });
const coverImages: UploadImageFragment[] = []; const coverImages: UploadImageFragment[] = [];

View File

@ -132,6 +132,19 @@ query getWebsiteInterface($language_code: String) {
response_invalid_code response_invalid_code
response_invalid_email response_invalid_email
response_email_success response_email_success
always_show_info
item_not_available
primary_language
secondary_language
combine_related_contents
previous_content
followup_content
videos
view_on
channel
subscribers
description
available_at
} }
} }
} }

View File

@ -36,7 +36,7 @@ export default function Channel(props: Props): JSX.Element {
<SubPanel> <SubPanel>
<ReturnButton <ReturnButton
href="/archives/videos/" href="/archives/videos/"
title={"Videos"} title={langui.videos}
langui={langui} langui={langui}
displayOn={ReturnButtonType.desktop} displayOn={ReturnButtonType.desktop}
className="mb-10" className="mb-10"
@ -44,12 +44,12 @@ export default function Channel(props: Props): JSX.Element {
<PanelHeader <PanelHeader
icon="movie" icon="movie"
title="Videos" title={langui.videos}
description={langui.archives_description} description={langui.archives_description}
/> />
<div className="flex flex-row gap-2 place-items-center coarse:hidden"> <div className="flex flex-row gap-2 place-items-center coarse:hidden">
<p className="flex-shrink-0">{"Always show info"}:</p> <p className="flex-shrink-0">{langui.always_show_info}:</p>
<Switch setState={setKeepInfoVisible} state={keepInfoVisible} /> <Switch setState={setKeepInfoVisible} state={keepInfoVisible} />
</div> </div>
</SubPanel> </SubPanel>

View File

@ -67,7 +67,7 @@ export default function Videos(props: Props): JSX.Element {
/> />
<div className="flex flex-row gap-2 place-items-center coarse:hidden"> <div className="flex flex-row gap-2 place-items-center coarse:hidden">
<p className="flex-shrink-0">{"Always show info"}:</p> <p className="flex-shrink-0">{langui.always_show_info}:</p>
<Switch setState={setKeepInfoVisible} state={keepInfoVisible} /> <Switch setState={setKeepInfoVisible} state={keepInfoVisible} />
</div> </div>
</SubPanel> </SubPanel>

View File

@ -39,7 +39,7 @@ export default function Video(props: Props): JSX.Element {
<SubPanel> <SubPanel>
<ReturnButton <ReturnButton
href="/archives/videos/" href="/archives/videos/"
title={"Videos"} title={langui.videos}
langui={langui} langui={langui}
displayOn={ReturnButtonType.desktop} displayOn={ReturnButtonType.desktop}
className="mb-10" className="mb-10"
@ -55,14 +55,14 @@ export default function Video(props: Props): JSX.Element {
/> />
<NavOption <NavOption
title={"Channel"} title={langui.channel}
url="#channel" url="#channel"
border border
onClick={() => appLayout.setSubPanelOpen(false)} onClick={() => appLayout.setSubPanelOpen(false)}
/> />
<NavOption <NavOption
title={"Description"} title={langui.description}
url="#description" url="#description"
border border
onClick={() => appLayout.setSubPanelOpen(false)} onClick={() => appLayout.setSubPanelOpen(false)}
@ -135,7 +135,7 @@ export default function Video(props: Props): JSX.Element {
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
> >
<Button className="!py-0 !px-3">{`View on ${video.source}`}</Button> <Button className="!py-0 !px-3">{`${langui.view_on} ${video.source}`}</Button>
</a> </a>
</div> </div>
</div> </div>
@ -144,7 +144,7 @@ export default function Video(props: Props): JSX.Element {
{video.channel?.data?.attributes && ( {video.channel?.data?.attributes && (
<InsetBox id="channel" className="grid place-items-center"> <InsetBox id="channel" className="grid place-items-center">
<div className="w-[clamp(0px,100%,42rem)] grid place-items-center gap-4 text-center"> <div className="w-[clamp(0px,100%,42rem)] grid place-items-center gap-4 text-center">
<h2 className="text-2xl">{"Channel"}</h2> <h2 className="text-2xl">{langui.channel}</h2>
<div> <div>
<Button <Button
href={`/archives/videos/c/${video.channel.data.attributes.uid}`} href={`/archives/videos/c/${video.channel.data.attributes.uid}`}
@ -153,8 +153,7 @@ export default function Video(props: Props): JSX.Element {
</Button> </Button>
<p> <p>
{video.channel.data.attributes.subscribers.toLocaleString()}{" "} {`${video.channel.data.attributes.subscribers.toLocaleString()} ${langui.subscribers?.toLowerCase()}`}
subscribers
</p> </p>
</div> </div>
</div> </div>
@ -163,7 +162,7 @@ export default function Video(props: Props): JSX.Element {
<InsetBox id="description" className="grid place-items-center"> <InsetBox id="description" className="grid place-items-center">
<div className="w-[clamp(0px,100%,42rem)] grid place-items-center gap-8"> <div className="w-[clamp(0px,100%,42rem)] grid place-items-center gap-8">
<h2 className="text-2xl">{"Description"}</h2> <h2 className="text-2xl">{langui.description}</h2>
<p className="whitespace-pre-line">{video.description}</p> <p className="whitespace-pre-line">{video.description}</p>
</div> </div>
</InsetBox> </InsetBox>

View File

@ -208,7 +208,6 @@ export default function Content(props: Immutable<Props>): JSX.Element {
className="mb-10" className="mb-10"
/> />
{content && (
<div className="grid place-items-center"> <div className="grid place-items-center">
<ThumbnailHeader <ThumbnailHeader
thumbnail={content.thumbnail?.data?.attributes} thumbnail={content.thumbnail?.data?.attributes}
@ -224,7 +223,9 @@ export default function Content(props: Immutable<Props>): JSX.Element {
{previousContent?.attributes && ( {previousContent?.attributes && (
<div className="mt-12 mb-8 w-full"> <div className="mt-12 mb-8 w-full">
<h2 className="text-center text-2xl mb-4">Previous content</h2> <h2 className="text-center text-2xl mb-4">
{langui.previous_content}
</h2>
<PreviewLine <PreviewLine
href={`/contents/${previousContent.attributes.slug}`} href={`/contents/${previousContent.attributes.slug}`}
pre_title={ pre_title={
@ -234,12 +235,8 @@ export default function Content(props: Immutable<Props>): JSX.Element {
previousContent.attributes.translations?.[0]?.title ?? previousContent.attributes.translations?.[0]?.title ??
prettySlug(previousContent.attributes.slug) prettySlug(previousContent.attributes.slug)
} }
subtitle={ subtitle={previousContent.attributes.translations?.[0]?.subtitle}
previousContent.attributes.translations?.[0]?.subtitle thumbnail={previousContent.attributes.thumbnail?.data?.attributes}
}
thumbnail={
previousContent.attributes.thumbnail?.data?.attributes
}
thumbnailAspectRatio="3/2" thumbnailAspectRatio="3/2"
topChips={ topChips={
isMobile isMobile
@ -251,8 +248,7 @@ export default function Content(props: Immutable<Props>): JSX.Element {
? previousContent.attributes.type.data.attributes ? previousContent.attributes.type.data.attributes
.titles[0]?.title .titles[0]?.title
: prettySlug( : prettySlug(
previousContent.attributes.type.data.attributes previousContent.attributes.type.data.attributes.slug
.slug
), ),
] ]
: undefined : undefined
@ -275,7 +271,9 @@ export default function Content(props: Immutable<Props>): JSX.Element {
{nextContent?.attributes && ( {nextContent?.attributes && (
<> <>
<HorizontalLine /> <HorizontalLine />
<h2 className="text-center text-2xl mb-4">Follow-up content</h2> <h2 className="text-center text-2xl mb-4">
{langui.followup_content}
</h2>
<PreviewLine <PreviewLine
href={`/contents/${nextContent.attributes.slug}`} href={`/contents/${nextContent.attributes.slug}`}
pre_title={nextContent.attributes.translations?.[0]?.pre_title} pre_title={nextContent.attributes.translations?.[0]?.pre_title}
@ -292,8 +290,8 @@ export default function Content(props: Immutable<Props>): JSX.Element {
: nextContent.attributes.type?.data?.attributes : nextContent.attributes.type?.data?.attributes
? [ ? [
nextContent.attributes.type.data.attributes.titles?.[0] nextContent.attributes.type.data.attributes.titles?.[0]
? nextContent.attributes.type.data.attributes ? nextContent.attributes.type.data.attributes.titles[0]
.titles[0]?.title ?.title
: prettySlug( : prettySlug(
nextContent.attributes.type.data.attributes.slug nextContent.attributes.type.data.attributes.slug
), ),
@ -311,7 +309,6 @@ export default function Content(props: Immutable<Props>): JSX.Element {
</> </>
)} )}
</div> </div>
)}
</ContentPanel> </ContentPanel>
); );

View File

@ -67,7 +67,7 @@ export default function Contents(props: Immutable<Props>): JSX.Element {
</div> </div>
<div className="flex flex-row gap-2 place-items-center coarse:hidden"> <div className="flex flex-row gap-2 place-items-center coarse:hidden">
<p className="flex-shrink-0">{"Combine related contents"}:</p> <p className="flex-shrink-0">{langui.combine_related_contents}:</p>
<Switch <Switch
setState={setCombineRelatedContent} setState={setCombineRelatedContent}
state={combineRelatedContent} state={combineRelatedContent}
@ -75,7 +75,7 @@ export default function Contents(props: Immutable<Props>): JSX.Element {
</div> </div>
<div className="flex flex-row gap-2 place-items-center coarse:hidden"> <div className="flex flex-row gap-2 place-items-center coarse:hidden">
<p className="flex-shrink-0">{"Always show info"}:</p> <p className="flex-shrink-0">{langui.always_show_info}:</p>
<Switch setState={setKeepInfoVisible} state={keepInfoVisible} /> <Switch setState={setKeepInfoVisible} state={keepInfoVisible} />
</div> </div>
</SubPanel> </SubPanel>
@ -122,7 +122,7 @@ export default function Contents(props: Immutable<Props>): JSX.Element {
stackNumber={ stackNumber={
combineRelatedContent && combineRelatedContent &&
item.attributes.group?.data?.attributes?.combine item.attributes.group?.data?.attributes?.combine
? item.attributes.group?.data?.attributes.contents ? item.attributes.group.data.attributes.contents
?.data.length ?.data.length
: 0 : 0
} }
@ -268,7 +268,7 @@ function filterContents(
(content) => (content) =>
!content.attributes?.group?.data?.attributes || !content.attributes?.group?.data?.attributes ||
!content.attributes.group.data.attributes.combine || !content.attributes.group.data.attributes.combine ||
content.attributes.group.data.attributes.contents?.data?.[0].id === content.attributes.group.data.attributes.contents?.data[0].id ===
content.id content.id
); );
} }

View File

@ -163,23 +163,6 @@ function testingContent(contents: Immutable<Props["contents"]>): Report {
}); });
} }
if (
content.attributes.next_recommended?.data?.id === content.id ||
content.attributes.previous_recommended?.data?.id === content.id
) {
report.lines.push({
subitems: [content.attributes.slug],
name: "Self Recommendation",
type: "Error",
severity: "Very High",
description:
"The Content is referring to itself as a Next or Previous Recommended.",
recommandation: "",
backendUrl: backendUrl,
frontendUrl: frontendUrl,
});
}
if (!content.attributes.thumbnail?.data?.id) { if (!content.attributes.thumbnail?.data?.id) {
report.lines.push({ report.lines.push({
subitems: [content.attributes.slug], subitems: [content.attributes.slug],
@ -270,171 +253,170 @@ function testingContent(contents: Immutable<Props["contents"]>): Report {
frontendUrl: frontendUrl, frontendUrl: frontendUrl,
}); });
} else { } else {
const textSetLanguages: string[] = [];
/* /*
if (content.attributes && textSet) { *const textSetLanguages: string[] = [];
if (textSet.language?.data?.id) { *if (content.attributes && textSet) {
if (textSet.language.data.id in textSetLanguages) { * if (textSet.language?.data?.id) {
report.lines.push({ * if (textSet.language.data.id in textSetLanguages) {
subitems: [ * report.lines.push({
content.attributes.slug, * subitems: [
`TextSet ${textSetIndex.toString()}`, * content.attributes.slug,
], * `TextSet ${textSetIndex.toString()}`,
name: "Duplicate Language", * ],
type: "Error", * name: "Duplicate Language",
severity: "High", * type: "Error",
description: "", * severity: "High",
recommandation: "", * description: "",
backendUrl: backendUrl, * recommandation: "",
frontendUrl: frontendUrl, * backendUrl: backendUrl,
}); * frontendUrl: frontendUrl,
} else { * });
textSetLanguages.push(textSet.language.data.id); * } else {
} * textSetLanguages.push(textSet.language.data.id);
} else { * }
report.lines.push({ * } else {
subitems: [ * report.lines.push({
content.attributes.slug, * subitems: [
`TextSet ${textSetIndex.toString()}`, * content.attributes.slug,
], * `TextSet ${textSetIndex.toString()}`,
name: "No Language", * ],
type: "Error", * name: "No Language",
severity: "Very High", * type: "Error",
description: "", * severity: "Very High",
recommandation: "", * description: "",
backendUrl: backendUrl, * recommandation: "",
frontendUrl: frontendUrl, * backendUrl: backendUrl,
}); * frontendUrl: frontendUrl,
} * });
* }
if (!textSet.source_language?.data?.id) { *
report.lines.push({ * if (!textSet.source_language?.data?.id) {
subitems: [ * report.lines.push({
content.attributes.slug, * subitems: [
`TextSet ${textSetIndex.toString()}`, * content.attributes.slug,
], * `TextSet ${textSetIndex.toString()}`,
name: "No Source Language", * ],
type: "Error", * name: "No Source Language",
severity: "High", * type: "Error",
description: "", * severity: "High",
recommandation: "", * description: "",
backendUrl: backendUrl, * recommandation: "",
frontendUrl: frontendUrl, * backendUrl: backendUrl,
}); * frontendUrl: frontendUrl,
} * });
* }
if (textSet.status !== Enum_Componentsetstextset_Status.Done) { *
report.lines.push({ * if (textSet.status !== Enum_Componentsetstextset_Status.Done) {
subitems: [ * report.lines.push({
content.attributes.slug, * subitems: [
`TextSet ${textSetIndex.toString()}`, * content.attributes.slug,
], * `TextSet ${textSetIndex.toString()}`,
name: "Not Done Status", * ],
type: "Improvement", * name: "Not Done Status",
severity: "Low", * type: "Improvement",
description: "", * severity: "Low",
recommandation: "", * description: "",
backendUrl: backendUrl, * recommandation: "",
frontendUrl: frontendUrl, * backendUrl: backendUrl,
}); * frontendUrl: frontendUrl,
} * });
* }
if (!textSet.text || textSet.text.length < 10) { *
report.lines.push({ * if (!textSet.text || textSet.text.length < 10) {
subitems: [ * report.lines.push({
content.attributes.slug, * subitems: [
`TextSet ${textSetIndex.toString()}`, * content.attributes.slug,
], * `TextSet ${textSetIndex.toString()}`,
name: "No Text", * ],
type: "Missing", * name: "No Text",
severity: "Medium", * type: "Missing",
description: "", * severity: "Medium",
recommandation: "", * description: "",
backendUrl: backendUrl, * recommandation: "",
frontendUrl: frontendUrl, * backendUrl: backendUrl,
}); * frontendUrl: frontendUrl,
} * });
* }
if ( *
textSet.source_language?.data?.id === * if (
textSet.language?.data?.id * textSet.source_language?.data?.id ===
) { * textSet.language?.data?.id
if (textSet.transcribers?.data.length === 0) { * ) {
report.lines.push({ * if (textSet.transcribers?.data.length === 0) {
subitems: [ * report.lines.push({
content.attributes.slug, * subitems: [
`TextSet ${textSetIndex.toString()}`, * content.attributes.slug,
], * `TextSet ${textSetIndex.toString()}`,
name: "No Transcribers", * ],
type: "Missing", * name: "No Transcribers",
severity: "High", * type: "Missing",
description: * severity: "High",
"The Content is a Transcription but doesn't credit any Transcribers.", * description:
recommandation: "Add the appropriate Transcribers.", * "The Content is a Transcription but doesn't credit any Transcribers.",
backendUrl: backendUrl, * recommandation: "Add the appropriate Transcribers.",
frontendUrl: frontendUrl, * backendUrl: backendUrl,
}); * frontendUrl: frontendUrl,
} * });
if ( * }
textSet.translators?.data && * if (
textSet.translators.data.length > 0 * textSet.translators?.data &&
) { * textSet.translators.data.length > 0
report.lines.push({ * ) {
subitems: [ * report.lines.push({
content.attributes.slug, * subitems: [
`TextSet ${textSetIndex.toString()}`, * content.attributes.slug,
], * `TextSet ${textSetIndex.toString()}`,
name: "Credited Translators", * ],
type: "Error", * name: "Credited Translators",
severity: "High", * type: "Error",
description: * severity: "High",
"The Content is a Transcription but credits one or more Translators.", * description:
recommandation: * "The Content is a Transcription but credits one or more Translators.",
"If appropriate, create a Translation Text Set with the Translator credited there.", * recommandation:
backendUrl: backendUrl, * "If appropriate, create a Translation Text Set with the Translator credited there.",
frontendUrl: frontendUrl, * backendUrl: backendUrl,
}); * frontendUrl: frontendUrl,
} * });
} else { * }
if (textSet.translators?.data.length === 0) { * } else {
report.lines.push({ * if (textSet.translators?.data.length === 0) {
subitems: [ * report.lines.push({
content.attributes.slug, * subitems: [
`TextSet ${textSetIndex.toString()}`, * content.attributes.slug,
], * `TextSet ${textSetIndex.toString()}`,
name: "No Translators", * ],
type: "Missing", * name: "No Translators",
severity: "High", * type: "Missing",
description: * severity: "High",
"The Content is a Transcription but doesn't credit any Translators.", * description:
recommandation: "Add the appropriate Translators.", * "The Content is a Transcription but doesn't credit any Translators.",
backendUrl: backendUrl, * recommandation: "Add the appropriate Translators.",
frontendUrl: frontendUrl, * backendUrl: backendUrl,
}); * frontendUrl: frontendUrl,
} * });
if ( * }
textSet.transcribers?.data && * if (
textSet.transcribers.data.length > 0 * textSet.transcribers?.data &&
) { * textSet.transcribers.data.length > 0
report.lines.push({ * ) {
subitems: [ * report.lines.push({
content.attributes.slug, * subitems: [
`TextSet ${textSetIndex.toString()}`, * content.attributes.slug,
], * `TextSet ${textSetIndex.toString()}`,
name: "Credited Transcribers", * ],
type: "Error", * name: "Credited Transcribers",
severity: "High", * type: "Error",
description: * severity: "High",
"The Content is a Translation but credits one or more Transcribers.", * description:
recommandation: * "The Content is a Translation but credits one or more Transcribers.",
"If appropriate, create a Transcription Text Set with the Transcribers credited there.", * recommandation:
backendUrl: backendUrl, * "If appropriate, create a Transcription Text Set with the Transcribers credited there.",
frontendUrl: frontendUrl, * backendUrl: backendUrl,
}); * frontendUrl: frontendUrl,
} * });
} * }
} * }
*}
*/ */
} }

View File

@ -202,7 +202,7 @@ export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
<> <>
{item?.urls && item.urls.length ? ( {item?.urls && item.urls.length ? (
<div className="flex flex-row place-items-center gap-3"> <div className="flex flex-row place-items-center gap-3">
<p>Available at</p> <p>{langui.available_at}</p>
{item.urls.map((url) => ( {item.urls.map((url) => (
<> <>
{url?.url && ( {url?.url && (
@ -218,7 +218,7 @@ export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
))} ))}
</div> </div>
) : ( ) : (
<p>This item is not for sale or is no longer available</p> <p>{langui.item_not_available}</p>
)} )}
</> </>
)} )}
@ -415,7 +415,7 @@ export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
</h2> </h2>
<div className="-mt-6 mb-8 flex flex-row gap-2 place-items-center coarse:hidden"> <div className="-mt-6 mb-8 flex flex-row gap-2 place-items-center coarse:hidden">
<p className="flex-shrink-0">{"Always show info"}:</p> <p className="flex-shrink-0">{langui.always_show_info}:</p>
<Switch setState={setKeepInfoVisible} state={keepInfoVisible} /> <Switch setState={setKeepInfoVisible} state={keepInfoVisible} />
</div> </div>
<div <div

View File

@ -127,7 +127,7 @@ export default function Library(props: Immutable<Props>): JSX.Element {
</div> </div>
<div className="flex flex-row gap-2 place-items-center coarse:hidden"> <div className="flex flex-row gap-2 place-items-center coarse:hidden">
<p className="flex-shrink-0">{"Always show info"}:</p> <p className="flex-shrink-0">{langui.always_show_info}:</p>
<Switch setState={setKeepInfoVisible} state={keepInfoVisible} /> <Switch setState={setKeepInfoVisible} state={keepInfoVisible} />
</div> </div>
</SubPanel> </SubPanel>

View File

@ -34,7 +34,7 @@ export default function News(props: Immutable<Props>): JSX.Element {
/> />
<div className="flex flex-row gap-2 place-items-center coarse:hidden"> <div className="flex flex-row gap-2 place-items-center coarse:hidden">
<p className="flex-shrink-0">{"Always show info"}:</p> <p className="flex-shrink-0">{langui.always_show_info}:</p>
<Switch setState={setKeepInfoVisible} state={keepInfoVisible} /> <Switch setState={setKeepInfoVisible} state={keepInfoVisible} />
</div> </div>
</SubPanel> </SubPanel>