Skip to content

Commit e9d8c1e

Browse files
authored
fix(agora): clean up translation controls (#1136)
Shorten translated-content labels across locales and localize source language names in project content controls. Use the global display language as the single frontend source of truth for project language selection, removing duplicated selected-language watch state on project routes. Prevent stale conversation display-content query data from making the translation toggle appear stuck when switching between original and translated content. Normalize nullish source-language values to undefined internally by broadening toUnionUndefined, while preserving backend DTO boundaries. Tighten project conversation mobile layout to match the battle-tested normal conversation width when the sidebar is hidden. Deploy: agora
1 parent bae9656 commit e9d8c1e

18 files changed

Lines changed: 254 additions & 252 deletions

services/agora/src/components/project/ProjectActivityCard.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,16 @@ import { storeToRefs } from "pinia";
9696
import ContentTranslationControl from "src/components/translation/ContentTranslationControl.vue";
9797
import SpaLink from "src/components/ui-library/SpaLink.vue";
9898
import ZKPlainTextContent from "src/components/ui-library/ZKPlainTextContent.vue";
99-
import type { LanguageTextDirection } from "src/shared/languages";
99+
import type {
100+
LanguageTextDirection,
101+
SupportedDisplayLanguageCodes,
102+
} from "src/shared/languages";
103+
import { toUnionUndefined } from "src/shared/shared";
100104
import type { LocalizedContentTranslationStatus } from "src/shared/types/zod";
101105
import { useLanguageStore } from "src/stores/language";
102106
import {
103107
type ContentTranslationDisplayMode,
108+
getContentTranslationSourceLanguageLabel,
104109
resolveContentTranslationState,
105110
} from "src/utils/translation/contentTranslation";
106111
import { computed, ref, watch } from "vue";
@@ -118,7 +123,7 @@ import type {
118123
const props = defineProps<{
119124
activity: ProjectActivity;
120125
projectSlug: string;
121-
languageCode: string;
126+
languageCode: SupportedDisplayLanguageCodes;
122127
textDirection: LanguageTextDirection;
123128
}>();
124129
@@ -177,7 +182,7 @@ const activityTranslationInitialMode = computed<ContentTranslationDisplayMode>(
177182
178183
return resolveContentTranslationState({
179184
dynamicTranslationEnabled: true,
180-
sourceLanguageCode: machineTranslation.sourceLanguageCode,
185+
sourceLanguageCode: toUnionUndefined(machineTranslation.sourceLanguageCode),
181186
displayLanguage: machineTranslation.targetLanguageCode,
182187
spokenLanguages: spokenLanguages.value,
183188
supportedTargetLanguageCodes: [machineTranslation.targetLanguageCode],
@@ -215,7 +220,12 @@ const activityTranslationControl = computed<
215220
}
216221
217222
return {
218-
sourceLanguageLabel: machineTranslation.sourceLanguageLabel,
223+
sourceLanguageLabel: getContentTranslationSourceLanguageLabel({
224+
sourceLanguage: undefined,
225+
fallbackLanguageCode: machineTranslation.sourceLanguageCode,
226+
fallbackLabel: machineTranslation.sourceLanguageLabel,
227+
displayLanguage: machineTranslation.targetLanguageCode,
228+
}),
219229
status: machineTranslation.status,
220230
};
221231
});

services/agora/src/components/project/ProjectConversationView.vue

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -249,17 +249,17 @@
249249
<ProjectAttributionSection
250250
:title="t('sponsorsTitle')"
251251
:entries="sponsorAttributions"
252-
:language-code="selectedLanguageValue"
252+
:language-code="selectedLanguage"
253253
/>
254254
<ProjectAttributionSection
255255
:title="t('projectOwnersTitle')"
256256
:entries="projectOwnerAttributions"
257-
:language-code="selectedLanguageValue"
257+
:language-code="selectedLanguage"
258258
/>
259259
<ProjectAttributionSection
260260
:title="t('partnersTitle')"
261261
:entries="partnerAttributions"
262-
:language-code="selectedLanguageValue"
262+
:language-code="selectedLanguage"
263263
/>
264264
</section>
265265

@@ -272,14 +272,14 @@
272272
</h2>
273273
<ProjectContactCard
274274
:contact="project.contact"
275-
:language-code="selectedLanguageValue"
275+
:language-code="selectedLanguage"
276276
/>
277277
</section>
278278
</aside>
279279

280280
<ProjectPageFooter
281281
class="project-conversation-view__footer"
282-
:language-code="selectedLanguageValue"
282+
:language-code="selectedLanguage"
283283
/>
284284
</div>
285285
</div>
@@ -290,17 +290,17 @@
290290
<ProjectAttributionSection
291291
:title="t('sponsorsTitle')"
292292
:entries="sponsorAttributions"
293-
:language-code="selectedLanguageValue"
293+
:language-code="selectedLanguage"
294294
/>
295295
<ProjectAttributionSection
296296
:title="t('projectOwnersTitle')"
297297
:entries="projectOwnerAttributions"
298-
:language-code="selectedLanguageValue"
298+
:language-code="selectedLanguage"
299299
/>
300300
<ProjectAttributionSection
301301
:title="t('partnersTitle')"
302302
:entries="partnerAttributions"
303-
:language-code="selectedLanguageValue"
303+
:language-code="selectedLanguage"
304304
/>
305305
</ZKBottomDialogContainer>
306306
</q-dialog>
@@ -328,6 +328,7 @@ import ZKLiveStatusDot from "src/components/ui-library/ZKLiveStatusDot.vue";
328328
import {
329329
getLanguageTextDirection,
330330
parseSupportedDisplayLanguageOrUndefined,
331+
type SupportedDisplayLanguageCodes,
331332
} from "src/shared/languages";
332333
import type {
333334
ExtendedConversation,
@@ -362,7 +363,6 @@ const props = defineProps<{
362363
project: ProjectPageData;
363364
conversationData: ExtendedConversation;
364365
languageOptions: readonly ProjectLanguageOption[];
365-
initialLanguage: string;
366366
bannerImageUrl?: string;
367367
reportLayout?: boolean;
368368
}>();
@@ -371,26 +371,17 @@ const emit = defineEmits<{
371371
conversationDeleted: [];
372372
}>();
373373
374-
const selectedLanguage = defineModel<string | readonly string[]>(
374+
const selectedLanguage = defineModel<SupportedDisplayLanguageCodes>(
375375
"selectedLanguage",
376-
{
377-
required: true,
378-
}
376+
{ required: true }
379377
);
380378
const showMobileAttributions = ref(false);
381379
382-
const selectedLanguageValue = computed(() => {
383-
if (Array.isArray(selectedLanguage.value)) {
384-
return selectedLanguage.value.at(0) ?? props.initialLanguage;
385-
}
386-
387-
return selectedLanguage.value;
388-
});
389380
const projectTextDirection = computed(() =>
390-
getLanguageTextDirection(selectedLanguageValue.value)
381+
getLanguageTextDirection(selectedLanguage.value)
391382
);
392383
const selectedSupportedLanguage = computed(
393-
() => parseSupportedDisplayLanguageOrUndefined(selectedLanguageValue.value) ?? "en"
384+
() => parseSupportedDisplayLanguageOrUndefined(selectedLanguage.value) ?? "en"
394385
);
395386
const conversationTitleText = computed<ConversationTitleTranslations>(
396387
() => conversationTitleTranslations[selectedSupportedLanguage.value]
@@ -535,7 +526,7 @@ function t(
535526
params?: Readonly<Record<string, string | number>>
536527
): string {
537528
return translateProjectPageText({
538-
languageCode: selectedLanguageValue.value,
529+
languageCode: selectedLanguage.value,
539530
key,
540531
params,
541532
});
@@ -952,12 +943,17 @@ main {
952943
}
953944
954945
@media (max-width: 860px) {
946+
.project-conversation-view__shell {
947+
width: min(35.9375rem, 100%);
948+
}
949+
955950
.project-conversation-view__content-grid {
956951
grid-template-columns: 1fr;
957952
grid-template-areas:
958953
"title"
959954
"stream"
960955
"footer";
956+
padding-inline: 1rem;
961957
}
962958
963959
.project-conversation-view__aside {
@@ -1001,10 +997,6 @@ main {
1001997
font-size: 0.78rem;
1002998
}
1003999
1004-
.project-conversation-view__shell {
1005-
width: calc(100% - 1rem);
1006-
}
1007-
10081000
.project-conversation-view__conversation-card {
10091001
margin-top: -1.65rem;
10101002
border-radius: 20px;

services/agora/src/components/project/ProjectLanguageSelect.vue

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<ZKSearchableBottomSheetSelect
3-
v-model="selectedLanguage"
3+
:model-value="selectedLanguage"
44
variant="pill"
55
:label="t('languageLabel')"
66
:dialog-title="t('languageDialogTitle')"
@@ -9,12 +9,16 @@
99
search-mode="always"
1010
:options="displayLanguageOptions"
1111
:text-direction="textDirection"
12+
@update:model-value="updateSelectedLanguage"
1213
/>
1314
</template>
1415

1516
<script setup lang="ts">
1617
import ZKSearchableBottomSheetSelect from "src/components/ui-library/ZKSearchableBottomSheetSelect.vue";
17-
import type { LanguageTextDirection } from "src/shared/languages";
18+
import type {
19+
LanguageTextDirection,
20+
SupportedDisplayLanguageCodes,
21+
} from "src/shared/languages";
1822
import { computed } from "vue";
1923
2024
import {
@@ -28,20 +32,14 @@ const props = defineProps<{
2832
textDirection: LanguageTextDirection;
2933
}>();
3034
31-
const selectedLanguage = defineModel<string | readonly string[]>(
35+
const selectedLanguage = defineModel<SupportedDisplayLanguageCodes>(
3236
"selectedLanguage",
33-
{
34-
required: true,
35-
}
37+
{ required: true }
3638
);
3739
38-
const selectedLanguageValue = computed(() => {
39-
if (Array.isArray(selectedLanguage.value)) {
40-
return selectedLanguage.value.at(0) ?? "en";
41-
}
42-
43-
return selectedLanguage.value;
44-
});
40+
type SelectLanguageModelValue =
41+
| SupportedDisplayLanguageCodes
42+
| readonly SupportedDisplayLanguageCodes[];
4543
4644
const displayLanguageOptions = computed<readonly ProjectLanguageOption[]>(
4745
() => {
@@ -76,8 +74,14 @@ function toDisplayLanguageOption(
7674
7775
function t(key: keyof ProjectPageTranslations): string {
7876
return translateProjectPageText({
79-
languageCode: selectedLanguageValue.value,
77+
languageCode: selectedLanguage.value,
8078
key,
8179
});
8280
}
81+
82+
function updateSelectedLanguage(value: SelectLanguageModelValue): void {
83+
selectedLanguage.value = Array.isArray(value)
84+
? value.at(0) ?? selectedLanguage.value
85+
: value;
86+
}
8387
</script>

0 commit comments

Comments
 (0)