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) => {
const preferredLanguages = [...items].map(
([code]) => code

View File

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

View File

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

View File

@ -132,6 +132,19 @@ query getWebsiteInterface($language_code: String) {
response_invalid_code
response_invalid_email
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>
<ReturnButton
href="/archives/videos/"
title={"Videos"}
title={langui.videos}
langui={langui}
displayOn={ReturnButtonType.desktop}
className="mb-10"
@ -44,12 +44,12 @@ export default function Channel(props: Props): JSX.Element {
<PanelHeader
icon="movie"
title="Videos"
title={langui.videos}
description={langui.archives_description}
/>
<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} />
</div>
</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">
<p className="flex-shrink-0">{"Always show info"}:</p>
<p className="flex-shrink-0">{langui.always_show_info}:</p>
<Switch setState={setKeepInfoVisible} state={keepInfoVisible} />
</div>
</SubPanel>

View File

@ -39,7 +39,7 @@ export default function Video(props: Props): JSX.Element {
<SubPanel>
<ReturnButton
href="/archives/videos/"
title={"Videos"}
title={langui.videos}
langui={langui}
displayOn={ReturnButtonType.desktop}
className="mb-10"
@ -55,14 +55,14 @@ export default function Video(props: Props): JSX.Element {
/>
<NavOption
title={"Channel"}
title={langui.channel}
url="#channel"
border
onClick={() => appLayout.setSubPanelOpen(false)}
/>
<NavOption
title={"Description"}
title={langui.description}
url="#description"
border
onClick={() => appLayout.setSubPanelOpen(false)}
@ -135,7 +135,7 @@ export default function Video(props: Props): JSX.Element {
target="_blank"
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>
</div>
</div>
@ -144,7 +144,7 @@ export default function Video(props: Props): JSX.Element {
{video.channel?.data?.attributes && (
<InsetBox id="channel" className="grid place-items-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>
<Button
href={`/archives/videos/c/${video.channel.data.attributes.uid}`}
@ -153,8 +153,7 @@ export default function Video(props: Props): JSX.Element {
</Button>
<p>
{video.channel.data.attributes.subscribers.toLocaleString()}{" "}
subscribers
{`${video.channel.data.attributes.subscribers.toLocaleString()} ${langui.subscribers?.toLowerCase()}`}
</p>
</div>
</div>
@ -163,7 +162,7 @@ export default function Video(props: Props): JSX.Element {
<InsetBox id="description" className="grid place-items-center">
<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>
</div>
</InsetBox>

View File

@ -208,7 +208,6 @@ export default function Content(props: Immutable<Props>): JSX.Element {
className="mb-10"
/>
{content && (
<div className="grid place-items-center">
<ThumbnailHeader
thumbnail={content.thumbnail?.data?.attributes}
@ -224,7 +223,9 @@ export default function Content(props: Immutable<Props>): JSX.Element {
{previousContent?.attributes && (
<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
href={`/contents/${previousContent.attributes.slug}`}
pre_title={
@ -234,12 +235,8 @@ export default function Content(props: Immutable<Props>): JSX.Element {
previousContent.attributes.translations?.[0]?.title ??
prettySlug(previousContent.attributes.slug)
}
subtitle={
previousContent.attributes.translations?.[0]?.subtitle
}
thumbnail={
previousContent.attributes.thumbnail?.data?.attributes
}
subtitle={previousContent.attributes.translations?.[0]?.subtitle}
thumbnail={previousContent.attributes.thumbnail?.data?.attributes}
thumbnailAspectRatio="3/2"
topChips={
isMobile
@ -251,8 +248,7 @@ export default function Content(props: Immutable<Props>): JSX.Element {
? previousContent.attributes.type.data.attributes
.titles[0]?.title
: prettySlug(
previousContent.attributes.type.data.attributes
.slug
previousContent.attributes.type.data.attributes.slug
),
]
: undefined
@ -275,7 +271,9 @@ export default function Content(props: Immutable<Props>): JSX.Element {
{nextContent?.attributes && (
<>
<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
href={`/contents/${nextContent.attributes.slug}`}
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.titles?.[0]
? nextContent.attributes.type.data.attributes
.titles[0]?.title
? nextContent.attributes.type.data.attributes.titles[0]
?.title
: prettySlug(
nextContent.attributes.type.data.attributes.slug
),
@ -311,7 +309,6 @@ export default function Content(props: Immutable<Props>): JSX.Element {
</>
)}
</div>
)}
</ContentPanel>
);

View File

@ -67,7 +67,7 @@ export default function Contents(props: Immutable<Props>): JSX.Element {
</div>
<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
setState={setCombineRelatedContent}
state={combineRelatedContent}
@ -75,7 +75,7 @@ export default function Contents(props: Immutable<Props>): JSX.Element {
</div>
<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} />
</div>
</SubPanel>
@ -122,7 +122,7 @@ export default function Contents(props: Immutable<Props>): JSX.Element {
stackNumber={
combineRelatedContent &&
item.attributes.group?.data?.attributes?.combine
? item.attributes.group?.data?.attributes.contents
? item.attributes.group.data.attributes.contents
?.data.length
: 0
}
@ -268,7 +268,7 @@ function filterContents(
(content) =>
!content.attributes?.group?.data?.attributes ||
!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
);
}

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

View File

@ -202,7 +202,7 @@ export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
<>
{item?.urls && item.urls.length ? (
<div className="flex flex-row place-items-center gap-3">
<p>Available at</p>
<p>{langui.available_at}</p>
{item.urls.map((url) => (
<>
{url?.url && (
@ -218,7 +218,7 @@ export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
))}
</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>
<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} />
</div>
<div

View File

@ -127,7 +127,7 @@ export default function Library(props: Immutable<Props>): JSX.Element {
</div>
<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} />
</div>
</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">
<p className="flex-shrink-0">{"Always show info"}:</p>
<p className="flex-shrink-0">{langui.always_show_info}:</p>
<Switch setState={setKeepInfoVisible} state={keepInfoVisible} />
</div>
</SubPanel>