Skip to content

Commit

Permalink
Localize JobList
Browse files Browse the repository at this point in the history
  • Loading branch information
derneuere committed Dec 11, 2023
1 parent 08f82d1 commit 2d55da9
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/components/album/ModalAlbumEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function ModalAlbumEdit(props: Props) {
{t("modalalbum.items", { count: item.photo_count })}
<br />
{t("modalalbum.updated", {
duration: DateTime.fromISO(item.created_on).setLocale(i18nResolvedLanguage).toRelative(),
duration: DateTime.fromISO(item.created_on).setLocale(i18nResolvedLanguage()).toRelative(),
})}
{}
</Text>
Expand Down
6 changes: 3 additions & 3 deletions src/components/charts/LocationDurationStackedBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ export function LocationDurationStackedBar() {
return t("locationstimeline.fromto", {
location: loc,
start: DateTime.fromSeconds(start)
.setLocale(i18nResolvedLanguage)
.setLocale(i18nResolvedLanguage())
.toLocaleString({ year: "numeric", month: "short" }),
end: DateTime.fromSeconds(end)
.setLocale(i18nResolvedLanguage)
.setLocale(i18nResolvedLanguage())
.toLocaleString({ year: "numeric", month: "short" }),
});
}
Expand All @@ -56,7 +56,7 @@ export function LocationDurationStackedBar() {
<XAxis
tickFormat={(v: any) =>
DateTime.fromSeconds(parseFloat(locationTimeline[0].start + v))
.setLocale(i18nResolvedLanguage)
.setLocale(i18nResolvedLanguage())
.toLocaleString({ year: "numeric", month: "2-digit" })
}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/facedashboard/FaceTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function FaceTooltip({ tooltipOpened, cell, children }: Props) {
: null;

const dateTimeLabel = DateTime.fromISO(cell.timestamp).isValid
? DateTime.fromISO(cell.timestamp).setLocale(i18nResolvedLanguage).toLocaleString(DateTime.DATETIME_MED)
? DateTime.fromISO(cell.timestamp).setLocale(i18nResolvedLanguage()).toLocaleString(DateTime.DATETIME_MED)
: null;

const tooltipIsEmpty = confidencePercentageLabel === null && dateTimeLabel === null;
Expand Down
2 changes: 1 addition & 1 deletion src/components/job/JobDuration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function JobDuration({ matches, finished, finishedAt, startedAt }: IJobDu
<td>
{DateTime.fromISO(finishedAt)
.diff(DateTime.fromISO(startedAt))
.reconfigure({ locale: i18nResolvedLanguage })
.reconfigure({ locale: i18nResolvedLanguage() })
.rescale()
.toHuman()}
</td>
Expand Down
6 changes: 3 additions & 3 deletions src/components/job/JobList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function JobList() {
<td>
<JobIndicator job={Object.create(job)} />
</td>
<td>{job.job_type_str}</td>
<td>{t(job.job_type_str)}</td>
<td>
<JobProgress
target={job.result.progress.target}
Expand All @@ -73,10 +73,10 @@ export function JobList() {
</td>
{matches && (
<>
<td>{DateTime.fromISO(job.queued_at).setLocale(i18nResolvedLanguage).toRelative()}</td>
<td>{DateTime.fromISO(job.queued_at).setLocale(i18nResolvedLanguage()).toRelative()}</td>
<td>
{job.started_at
? DateTime.fromISO(job.started_at!).setLocale(i18nResolvedLanguage).toRelative()
? DateTime.fromISO(job.started_at!).setLocale(i18nResolvedLanguage()).toRelative()
: ""}
</td>
</>
Expand Down
2 changes: 1 addition & 1 deletion src/components/lightbox/TimestampItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function TimestampItem({ photoDetail }: Props) {
const [editMode, setEditMode] = useState(false);

const { t } = useTranslation();
const lang = i18nResolvedLanguage;
const lang = i18nResolvedLanguage();
import(`dayjs/locale/${lang}.js`);

const dispatch = useAppDispatch();
Expand Down
2 changes: 1 addition & 1 deletion src/components/photolist/DefaultHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export function DefaultHeader(props: Props) {
<b>
{dayHeaderPrefix}
{DateTime.fromISO(date).isValid
? DateTime.fromISO(date).setLocale(i18nResolvedLanguage).toLocaleString(DateTime.DATE_HUGE)
? DateTime.fromISO(date).setLocale(i18nResolvedLanguage()).toLocaleString(DateTime.DATE_HUGE)
: date}
</b>
</Text>
Expand Down
2 changes: 1 addition & 1 deletion src/components/scrollscrubber/ScrollScrubber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export function ScrollScrubber({ type, scrollPositions, targetHeight, scrollToY,
pos.year = item.year;
if (item.year && item.month) {
pos.month = DateTime.fromISO(`${item.year}-${item.month.toString().padStart(2, "0")}-01`)
.setLocale(i18nResolvedLanguage)
.setLocale(i18nResolvedLanguage())
.toLocaleString({ year: "numeric", month: "short" });
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/sharing/ModalPhotosShare.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function ModalPhotosShare(props: Props) {
<Title order={4}>{displayName}</Title>
<Text size="sm" color="dimmed">
{t("modalphotosshare.joined")}{" "}
{DateTime.fromISO(item.date_joined).setLocale(i18nResolvedLanguage).toRelative()}
{DateTime.fromISO(item.date_joined).setLocale(i18nResolvedLanguage()).toRelative()}
</Text>
</div>
</Group>
Expand Down
2 changes: 1 addition & 1 deletion src/components/sharing/UserEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function UserEntry(props: UserEntryProps) {
<Title order={4}>{getDisplayName(user)}</Title>
<Text size="sm" color="dimmed">
{t("modalphotosshare.joined")}{" "}
{DateTime.fromISO(user.date_joined).setLocale(i18nResolvedLanguage).toRelative()}
{DateTime.fromISO(user.date_joined).setLocale(i18nResolvedLanguage()).toRelative()}
</Text>
</div>
</Group>
Expand Down
2 changes: 1 addition & 1 deletion src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import translationVi from "./locales/vi/translation.json";
import translationZh_Hans from "./locales/zh_Hans/translation.json";
import translationZh_Hant from "./locales/zh_Hant/translation.json";

export const i18nResolvedLanguage = i18n.resolvedLanguage ? i18n.resolvedLanguage.replace("_", "-") : "en";
export const i18nResolvedLanguage = () => (i18n?.resolvedLanguage ? i18n.resolvedLanguage.replace("_", "-") : "en");

const resources = {
en: {
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/albums/AlbumAuto.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function AlbumAuto() {
}
const album = albums[index];
const dateTimeLabel = DateTime.fromISO(album.timestamp).isValid
? DateTime.fromISO(album.timestamp).setLocale(i18nResolvedLanguage).toLocaleString(DateTime.DATE_MED)
? DateTime.fromISO(album.timestamp).setLocale(i18nResolvedLanguage()).toLocaleString(DateTime.DATE_MED)
: null;

return (
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/albums/AlbumAutoGalleryView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function AlbumAutoGalleryView() {
useEffect(() => {}, [album]);

function formatTimestamp(timestamp: string): string {
return DateTime.fromISO(timestamp).setLocale(i18nResolvedLanguage).toLocaleString(DateTime.DATE_MED);
return DateTime.fromISO(timestamp).setLocale(i18nResolvedLanguage()).toLocaleString(DateTime.DATE_MED);
}

if (isFetching || !album) {
Expand Down Expand Up @@ -150,7 +150,7 @@ export function AlbumAutoGalleryView() {
<div>
<Title order={5}>
{t("autoalbumgallery.day", { day: i + 1 })} -{" "}
{DateTime.fromISO(v[0]).setLocale(i18nResolvedLanguage).toLocaleString(DateTime.DATE_HUGE)}
{DateTime.fromISO(v[0]).setLocale(i18nResolvedLanguage()).toLocaleString(DateTime.DATE_HUGE)}
</Title>
<Text color="dimmed">
<Breadcrumbs separator="/">{uniqueLocations}</Breadcrumbs>
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/settings/AdminPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function UserTable() {
<td>{user.scan_directory ? user.scan_directory : t("adminarea.notset")}</td>
{matches && <td>{user.confidence ? user.confidence : t("adminarea.notset")}</td>}
{matches && <td>{user.photo_count}</td>}
{matches && <td>{DateTime.fromISO(user.date_joined).setLocale(i18nResolvedLanguage).toRelative()}</td>}
{matches && <td>{DateTime.fromISO(user.date_joined).setLocale(i18nResolvedLanguage()).toRelative()}</td>}
</tr>
))}
</tbody>
Expand Down
1 change: 1 addition & 0 deletions src/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@
"albumalreadyexists": "Album {{name}} exisitiert bereits.",
"albumplaceholder": "Titel des Albums"
},
"Download Models": "Modelle herunterladen",
"faces": "Gesichter",
"events": "Ereignisse",
"days": "Tage",
Expand Down
10 changes: 10 additions & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,16 @@
"unknownfacescounter_one": "{{count}} Unkown Face",
"unknownfacescounter_other": "{{count}} Unkown Faces"
},
"Scan Photos": "Scan Photos",
"Generate Event Albums": "Generate Event Albums",
"Regenerate Event Titles": "Regenerate Event Titles",
"Train Faces": "Train Faces",
"Delete Missing Photos": "Delete Missing Photos",
"Scan Faces": "Scan Faces",
"Calculate Clip Embeddings": "Calculate Clip Embeddings",
"Find Similar Faces": "Find Similar Faces",
"Download Selected Photos": "Download Selected Photos",
"Download Models": "Download Models",
"scan": "Scan",
"socialgraph": "Social Graph",
"facecluster": "Face Clusters",
Expand Down
2 changes: 1 addition & 1 deletion src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function formatDateForPhotoGroups(photoGroups: DatePhotosGroup[]): DatePh
...photoGroup,
year: date.year,
month: date.month,
date: date.setLocale(i18nResolvedLanguage).toLocaleString(DateTime.DATE_HUGE),
date: date.setLocale(i18nResolvedLanguage()).toLocaleString(DateTime.DATE_HUGE),
};
}
return photoGroup;
Expand Down

0 comments on commit 2d55da9

Please sign in to comment.