Skip to content

Commit 4975c88

Browse files
committed
Translations
1 parent 83f95d2 commit 4975c88

17 files changed

Lines changed: 129 additions & 40 deletions

File tree

apps/web/src/components/ActivityFeed.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { formatDistanceToNow } from "date-fns";
1111
import { fetchActivityFeed } from "../redux/social/actions";
1212
import { getLanguageLabel } from "../lib/lang";
1313
import ProjectThumbnail from "./ProjectThumbnail";
14-
import { useTranslation } from "@zxplay/i18n";
14+
import { useTranslation, useDateFnsLocale } from "@zxplay/i18n";
1515
import { sep } from "../constants";
1616

1717
function getLanguageColor(lang) {
@@ -29,6 +29,7 @@ function getLanguageColor(lang) {
2929

3030
export default function ActivityFeed() {
3131
const { t } = useTranslation();
32+
const locale = useDateFnsLocale();
3233
const dispatch = useDispatch();
3334

3435
const currentUserId = useSelector((state) => state?.identity.userId);
@@ -139,7 +140,7 @@ export default function ActivityFeed() {
139140
{t("feed.updated")}{" "}
140141
{formatDistanceToNow(
141142
new Date(project.updated_at),
142-
{ addSuffix: true }
143+
{ addSuffix: true, locale }
143144
)}
144145
</div>
145146
</div>

apps/web/src/components/FollowList.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { sep } from "../constants";
1515
import { formatDistanceToNow } from "date-fns";
1616
import { followUser, unfollowUser } from "../redux/social/actions";
1717
import { generateRetroAvatar } from "../lib/avatar";
18-
import { useTranslation } from "@zxplay/i18n";
18+
import { useTranslation, useDateFnsLocale } from "@zxplay/i18n";
1919

2020
const GET_USER_WITH_FOLLOWS = gql`
2121
query GetUserWithFollows(
@@ -88,6 +88,7 @@ const CHECK_FOLLOWING_STATUS = gql`
8888

8989
function UserCard({ user, isFollowing, onFollowToggle, currentUserId }) {
9090
const { t } = useTranslation();
91+
const locale = useDateFnsLocale();
9192
const isOwnProfile = currentUserId === user.user_id;
9293
// Fall back to the user id if a slug is missing; /u/<uuid> canonicalises to the slug.
9394
const profileUrl = `/u/${user.slug || user.user_id}`;
@@ -138,6 +139,7 @@ function UserCard({ user, isFollowing, onFollowToggle, currentUserId }) {
138139
{t("follow.joined", {
139140
when: formatDistanceToNow(new Date(user.created_at), {
140141
addSuffix: true,
142+
locale,
141143
}),
142144
})}
143145
</span>

apps/web/src/components/ProjectList.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ import {
1111
} from "../redux/projectList/actions";
1212
import { Dropdown } from "primereact/dropdown";
1313
import { getLanguageLabel } from "../lib/lang";
14-
import { useTranslation } from "@zxplay/i18n";
14+
import { useTranslation, useDateFnsLocale } from "@zxplay/i18n";
1515

1616
export default function ProjectList() {
1717
const { t } = useTranslation();
18+
const locale = useDateFnsLocale();
1819
const dispatch = useDispatch();
1920

2021
const projects = useSelector((state) => state?.projectList.projectList);
@@ -64,12 +65,12 @@ export default function ProjectList() {
6465

6566
function formatCreated(data) {
6667
const date = new Date(data["created_at"]);
67-
return formatDistance(date, now, { addSuffix: true });
68+
return formatDistance(date, now, { addSuffix: true, locale });
6869
}
6970

7071
function formatUpdated(data) {
7172
const date = new Date(data["updated_at"]);
72-
return formatDistance(date, now, { addSuffix: true });
73+
return formatDistance(date, now, { addSuffix: true, locale });
7374
}
7475

7576
const onPage = (event) => {

apps/web/src/components/PublicProfiles.jsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect, useState } from "react";
22
import { Link } from "react-router-dom";
33
import { Titled } from "react-titled";
4-
import { useTranslation } from "@zxplay/i18n";
4+
import { useTranslation, useDateFnsLocale } from "@zxplay/i18n";
55
import { Card } from "primereact/card";
66
import { Avatar } from "primereact/avatar";
77
import { Dropdown } from "primereact/dropdown";
@@ -77,6 +77,8 @@ const SORT_OPTIONS = [
7777
];
7878

7979
function ProfileCard({ user }) {
80+
const { t } = useTranslation();
81+
const locale = useDateFnsLocale();
8082
const projectCount = user.projects_aggregate?.aggregate?.count || 0;
8183
const followerCount = user.followers_aggregate?.aggregate?.count || 0;
8284
const followingCount = user.following_aggregate?.aggregate?.count || 0;
@@ -108,16 +110,18 @@ function ProfileCard({ user }) {
108110
<p className="text-400 m-0 mt-2 text-sm">{user.bio}</p>
109111
)}
110112
<div className="text-400 text-sm mt-2">
111-
<span>{projectCount} public projects</span>
113+
<span>{t("profiles.projectsCount", { count: projectCount })}</span>
112114
<span className="mx-2">·</span>
113-
<span>{followerCount} followers</span>
115+
<span>{t("profiles.followersCount", { count: followerCount })}</span>
114116
<span className="mx-2">·</span>
115-
<span>{followingCount} following</span>
117+
<span>{t("profiles.followingCount", { count: followingCount })}</span>
116118
<span className="mx-2">·</span>
117119
<span>
118-
Joined{" "}
119-
{formatDistanceToNow(new Date(user.created_at), {
120-
addSuffix: true,
120+
{t("follow.joined", {
121+
when: formatDistanceToNow(new Date(user.created_at), {
122+
addSuffix: true,
123+
locale,
124+
}),
121125
})}
122126
</span>
123127
</div>

apps/web/src/components/PublicUserProfile.jsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import ProjectThumbnail from "./ProjectThumbnail";
4040
import { generateRetroAvatar } from "../lib/avatar";
4141
import { generateRetroSpriteAvatar } from "../lib/retroSpriteAvatar";
4242
import AvatarSelector from "./AvatarSelector";
43-
import { useTranslation } from "@zxplay/i18n";
43+
import { useTranslation, useDateFnsLocale } from "@zxplay/i18n";
4444

4545
const UPDATE_PROJECT_ORDER = gql`
4646
mutation UpdateProjectOrder($projectId: uuid!, $displayOrder: Int!) {
@@ -149,6 +149,7 @@ const GET_USER_BY_ID = gql`
149149
// Sortable project card component for drag and drop
150150
function SortableProjectCard({ project, projectUrl, isDragging }) {
151151
const { t } = useTranslation();
152+
const locale = useDateFnsLocale();
152153
const navigate = useNavigate();
153154
const {
154155
attributes,
@@ -230,9 +231,10 @@ function SortableProjectCard({ project, projectUrl, isDragging }) {
230231
/>
231232

232233
<div className="mt-auto text-400 text-sm relative z-1">
233-
Updated{" "}
234+
{t("feed.updated")}{" "}
234235
{formatDistanceToNow(new Date(project.updated_at), {
235236
addSuffix: true,
237+
locale,
236238
})}
237239
</div>
238240
</div>
@@ -256,6 +258,7 @@ function getLanguageColor(lang) {
256258

257259
export default function PublicUserProfile() {
258260
const { t } = useTranslation();
261+
const locale = useDateFnsLocale();
259262
const { id } = useParams(); // This could be either slug or UUID
260263
const navigate = useNavigate();
261264
const dispatch = useDispatch();
@@ -539,6 +542,7 @@ export default function PublicUserProfile() {
539542
const displayName = user.greeting_name || t("profile.defaultName");
540543
const memberSince = formatDistanceToNow(new Date(user.created_at), {
541544
addSuffix: true,
545+
locale,
542546
});
543547

544548
return (
@@ -663,11 +667,15 @@ export default function PublicUserProfile() {
663667
<Card
664668
title={
665669
<div className="flex align-items-center justify-content-between">
666-
<span>Public Projects ({projects?.length || 0})</span>
670+
<span>
671+
{t("profile.publicProjects", {
672+
count: projects?.length || 0,
673+
})}
674+
</span>
667675
{isOwnProfile && isSaving && (
668676
<Tag
669677
severity="info"
670-
value="Saving order..."
678+
value={t("profile.savingOrder")}
671679
icon="pi pi-spin pi-spinner"
672680
/>
673681
)}
@@ -742,10 +750,10 @@ export default function PublicUserProfile() {
742750
/>
743751

744752
<div className="mt-auto text-400 text-sm relative z-1">
745-
Updated{" "}
753+
{t("feed.updated")}{" "}
746754
{formatDistanceToNow(
747755
new Date(project.updated_at),
748-
{ addSuffix: true }
756+
{ addSuffix: true, locale }
749757
)}
750758
</div>
751759
</div>
@@ -761,9 +769,7 @@ export default function PublicUserProfile() {
761769
<i className="pi pi-inbox text-4xl text-300 mb-3" />
762770
<p className="text-500">{t("profile.noProjects")}</p>
763771
{isOwnProfile && (
764-
<p className="text-sm">
765-
Make your projects public to display them here
766-
</p>
772+
<p className="text-sm">{t("profile.makePublicHint")}</p>
767773
)}
768774
</div>
769775
)}

apps/web/src/locales/bg/web.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
},
3737
"profiles": {
3838
"title": "Публични профили",
39-
"none": "Все още няма публични профили"
39+
"none": "Все още няма публични профили",
40+
"projectsCount": "{{count}} публични проекта",
41+
"followersCount": "{{count}} последователи",
42+
"followingCount": "{{count}} следвани"
4043
},
4144
"follow": {
4245
"networkTitle": "Мрежа на {{name}}",
@@ -58,7 +61,10 @@
5861
"dragToReorder": "Плъзнете за пренареждане",
5962
"defaultName": "Потребител",
6063
"private": "Този профил е частен",
61-
"privateOwn": "Профилът ви в момента е частен"
64+
"privateOwn": "Профилът ви в момента е частен",
65+
"publicProjects": "Публични проекти ({{count}})",
66+
"savingOrder": "Запазване на реда...",
67+
"makePublicHint": "Направете проектите си публични, за да се показват тук"
6268
},
6369
"about": {
6470
"createProjects": "Създаване на проекти",

apps/web/src/locales/cs/web.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
},
3737
"profiles": {
3838
"title": "Veřejné profily",
39-
"none": "Zatím žádné veřejné profily"
39+
"none": "Zatím žádné veřejné profily",
40+
"projectsCount": "{{count}} veřejných projektů",
41+
"followersCount": "{{count}} sledujících",
42+
"followingCount": "{{count}} sledováno"
4043
},
4144
"follow": {
4245
"networkTitle": "Síť uživatele {{name}}",
@@ -58,7 +61,10 @@
5861
"dragToReorder": "Přetažením změníte pořadí",
5962
"defaultName": "Uživatel",
6063
"private": "Tento profil je soukromý",
61-
"privateOwn": "Váš profil je momentálně soukromý"
64+
"privateOwn": "Váš profil je momentálně soukromý",
65+
"publicProjects": "Veřejné projekty ({{count}})",
66+
"savingOrder": "Ukládání pořadí...",
67+
"makePublicHint": "Zveřejněte své projekty, aby se zde zobrazily"
6268
},
6369
"about": {
6470
"createProjects": "Vytváření projektů",

apps/web/src/locales/en/web.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
},
3737
"profiles": {
3838
"title": "Public Profiles",
39-
"none": "No public profiles yet"
39+
"none": "No public profiles yet",
40+
"projectsCount": "{{count}} public projects",
41+
"followersCount": "{{count}} followers",
42+
"followingCount": "{{count}} following"
4043
},
4144
"follow": {
4245
"networkTitle": "{{name}}'s Network",
@@ -58,7 +61,10 @@
5861
"dragToReorder": "Drag to reorder",
5962
"defaultName": "User",
6063
"private": "This profile is private",
61-
"privateOwn": "Your profile is currently private"
64+
"privateOwn": "Your profile is currently private",
65+
"publicProjects": "Public Projects ({{count}})",
66+
"savingOrder": "Saving order...",
67+
"makePublicHint": "Make your projects public to display them here"
6268
},
6369
"about": {
6470
"createProjects": "Create Projects",

apps/web/src/locales/es/web.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
},
3737
"profiles": {
3838
"title": "Perfiles públicos",
39-
"none": "Aún no hay perfiles públicos"
39+
"none": "Aún no hay perfiles públicos",
40+
"projectsCount": "{{count}} proyectos públicos",
41+
"followersCount": "{{count}} seguidores",
42+
"followingCount": "{{count}} siguiendo"
4043
},
4144
"follow": {
4245
"networkTitle": "Red de {{name}}",
@@ -58,7 +61,10 @@
5861
"dragToReorder": "Arrastra para reordenar",
5962
"defaultName": "Usuario",
6063
"private": "Este perfil es privado",
61-
"privateOwn": "Tu perfil es actualmente privado"
64+
"privateOwn": "Tu perfil es actualmente privado",
65+
"publicProjects": "Proyectos públicos ({{count}})",
66+
"savingOrder": "Guardando orden...",
67+
"makePublicHint": "Haz públicos tus proyectos para mostrarlos aquí"
6268
},
6369
"about": {
6470
"createProjects": "Crear proyectos",

apps/web/src/locales/pl/web.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
},
3737
"profiles": {
3838
"title": "Profile publiczne",
39-
"none": "Brak publicznych profili"
39+
"none": "Brak publicznych profili",
40+
"projectsCount": "{{count}} publicznych projektów",
41+
"followersCount": "{{count}} obserwujących",
42+
"followingCount": "{{count}} obserwowanych"
4043
},
4144
"follow": {
4245
"networkTitle": "Sieć użytkownika {{name}}",
@@ -58,7 +61,10 @@
5861
"dragToReorder": "Przeciągnij, aby zmienić kolejność",
5962
"defaultName": "Użytkownik",
6063
"private": "Ten profil jest prywatny",
61-
"privateOwn": "Twój profil jest obecnie prywatny"
64+
"privateOwn": "Twój profil jest obecnie prywatny",
65+
"publicProjects": "Projekty publiczne ({{count}})",
66+
"savingOrder": "Zapisywanie kolejności...",
67+
"makePublicHint": "Ustaw projekty jako publiczne, aby wyświetlić je tutaj"
6268
},
6369
"about": {
6470
"createProjects": "Twórz projekty",

0 commit comments

Comments
 (0)