Enrich language cms

This commit is contained in:
Sam Becker 2025-05-10 15:20:46 -05:00
parent 665dd39fd7
commit 927b4b85b5
12 changed files with 179 additions and 112 deletions

View File

@ -29,6 +29,7 @@ import IconBroom from '@/components/icons/IconBroom';
import InsightsIndicatorDot from './insights/InsightsIndicatorDot';
import MoreMenuItem from '@/components/more/MoreMenuItem';
import Spinner from '@/components/Spinner';
import { APP_TEXT } from '@/app/config';
export default function AdminAppMenu({
active,
@ -65,7 +66,7 @@ export default function AdminAppMenu({
const sectionUpload: ComponentProps<typeof MoreMenuItem>[] =
useMemo(() => ([{
label: 'Upload Photos',
label: APP_TEXT.admin.uploadPhotos,
icon: <IconUpload
size={15}
className="translate-x-[0.5px] translate-y-[0.5px]"
@ -80,7 +81,7 @@ export default function AdminAppMenu({
if (uploadsCount) {
items.push({
label: 'Uploads',
label: APP_TEXT.admin.uploadPlural,
annotation: `${uploadsCount}`,
icon: <IconFolder
size={16}
@ -91,7 +92,7 @@ export default function AdminAppMenu({
}
if (photosCountNeedSync) {
items.push({
label: 'Updates',
label: APP_TEXT.admin.updates,
annotation: <>
<span className="mr-3">
{photosCountNeedSync}
@ -110,7 +111,7 @@ export default function AdminAppMenu({
}
if (photosCountTotal) {
items.push({
label: 'Manage Photos',
label: APP_TEXT.admin.managePhotos,
...photosCountTotal && {
annotation: `${photosCountTotal}`,
},
@ -123,7 +124,7 @@ export default function AdminAppMenu({
}
if (tagsCount) {
items.push({
label: 'Manage Tags',
label: APP_TEXT.admin.manageTags,
annotation: `${tagsCount}`,
icon: <IconTag
size={15}
@ -134,7 +135,7 @@ export default function AdminAppMenu({
}
if (recipesCount) {
items.push({
label: 'Manage Recipes',
label: APP_TEXT.admin.manageRecipes,
annotation: `${recipesCount}`,
icon: <IconRecipe
size={17}
@ -146,8 +147,8 @@ export default function AdminAppMenu({
if (photosCountTotal) {
items.push({
label: isSelecting
? 'Exit Batch Edit'
: 'Batch Edit ...',
? APP_TEXT.admin.batchExitEdit
: APP_TEXT.admin.batchEditShort,
icon: isSelecting
? <IoCloseSharp
size={18}
@ -173,8 +174,8 @@ export default function AdminAppMenu({
}
items.push({
label: showAppInsightsLink
? 'App Insights'
: 'App Configuration',
? APP_TEXT.admin.appInsights
: APP_TEXT.admin.appConfig,
icon: <AdminAppInfoIcon
size="small"
className="translate-x-[-0.5px] translate-y-[0.5px]"
@ -198,7 +199,7 @@ export default function AdminAppMenu({
const sectionSignOut: ComponentProps<typeof MoreMenuItem>[] =
useMemo(() => ([{
label: 'Sign Out',
label: APP_TEXT.auth.signOut,
icon: <IconSignOut size={15} />,
action: () => signOutAction().then(clearAuthStateAndRedirectIfNecessary),
}]), [clearAuthStateAndRedirectIfNecessary]);

View File

@ -12,6 +12,7 @@ import {
PATH_ADMIN_UPLOADS,
} from '@/app/paths';
import AdminNavClient from './AdminNavClient';
import { APP_TEXT } from '@/app/config';
export default async function AdminNav() {
const [
@ -41,28 +42,28 @@ export default async function AdminNav() {
// Photos
const items = [{
label: 'Photos',
label: APP_TEXT.photo.photoPlural,
href: PATH_ADMIN_PHOTOS,
count: countPhotos,
}];
// Uploads
if (countUploads > 0) { items.push({
label: 'Uploads',
label: APP_TEXT.admin.uploadPlural,
href: PATH_ADMIN_UPLOADS,
count: countUploads,
}); }
// Tags
if (countTags > 0) { items.push({
label: 'Tags',
label: APP_TEXT.category.tagPlural,
href: PATH_ADMIN_TAGS,
count: countTags,
}); }
// Recipes
if (countRecipes > 0) { items.push({
label: 'Recipes',
label: APP_TEXT.category.recipePlural,
href: PATH_ADMIN_RECIPES,
count: countRecipes,
}); }

View File

@ -60,7 +60,7 @@ export default function Footer() {
: SHOW_REPO_LINK
? <RepoLink />
: <Link href={PATH_ADMIN_PHOTOS}>
{APP_TEXT.footer.admin}
{APP_TEXT.nav.admin}
</Link>}
</div>
<div className="flex items-center h-10">

View File

@ -26,19 +26,19 @@ export default function ThemeSwitcher () {
icon={<BiDesktop size={16} />}
onClick={() => setTheme('system')}
active={theme === 'system'}
tooltip={{ content: APP_TEXT.footer.system }}
tooltip={{ content: APP_TEXT.theme.system }}
/>
<SwitcherItem
icon={<BiSun size={18} />}
onClick={() => setTheme('light')}
active={theme === 'light'}
tooltip={{ content: APP_TEXT.footer.light }}
tooltip={{ content: APP_TEXT.theme.light }}
/>
<SwitcherItem
icon={<BiMoon size={16} />}
onClick={() => setTheme('dark')}
active={theme === 'dark'}
tooltip={{ content: APP_TEXT.footer.dark }}
tooltip={{ content: APP_TEXT.theme.dark }}
/>
</Switcher>
);

View File

@ -375,21 +375,21 @@ export default function CommandKClient({
, [tagsIncludingHidden, cameras, lenses, recipes, films, focalLengths]);
const clientSections: CommandKSection[] = [{
heading: 'Theme',
heading: APP_TEXT.theme.theme,
accessory: <IoInvertModeSharp
size={14}
className="translate-y-[0.5px] translate-x-[-1px]"
/>,
items: [{
label: 'Use System',
label: APP_TEXT.theme.system,
annotation: <BiDesktop />,
action: () => setTheme('system'),
}, {
label: 'Light Mode',
label: APP_TEXT.theme.light,
annotation: <BiSun size={16} className="translate-x-[1.25px]" />,
action: () => setTheme('light'),
}, {
label: 'Dark Mode',
label: APP_TEXT.theme.dark,
annotation: <BiMoon className="translate-x-[1px]" />,
action: () => setTheme('dark'),
}],
@ -440,12 +440,16 @@ export default function CommandKClient({
}
const pageFeed: CommandKItem = {
label: GRID_HOMEPAGE_ENABLED ? 'Feed' : 'Feed (Home)',
label: GRID_HOMEPAGE_ENABLED
? APP_TEXT.nav.feed
: `${APP_TEXT.nav.feed} (${APP_TEXT.nav.home})`,
path: PATH_FEED_INFERRED,
};
const pageGrid: CommandKItem = {
label: GRID_HOMEPAGE_ENABLED ? 'Grid (Home)' : 'Grid',
label: GRID_HOMEPAGE_ENABLED
? `${APP_TEXT.nav.grid} (${APP_TEXT.nav.home})`
: APP_TEXT.nav.grid,
path: PATH_GRID_INFERRED,
};
@ -467,40 +471,40 @@ export default function CommandKClient({
if (isUserSignedIn) {
adminSection.items.push({
label: 'Upload Photos',
label: APP_TEXT.admin.uploadPhotos,
annotation: <IconLock narrow />,
action: startUpload,
});
if (uploadsCount) {
adminSection.items.push({
label: `Uploads (${uploadsCount})`,
label: `${APP_TEXT.admin.uploadPlural} (${uploadsCount})`,
annotation: <IconLock narrow />,
path: PATH_ADMIN_UPLOADS,
});
}
adminSection.items.push({
label: `Manage Photos (${photosCountTotal})`,
label: `${APP_TEXT.admin.managePhotos} (${photosCountTotal})`,
annotation: <IconLock narrow />,
path: PATH_ADMIN_PHOTOS,
});
if (tagsCount) {
adminSection.items.push({
label: `Manage Tags (${tagsCount})`,
label: `${APP_TEXT.admin.manageTags} (${tagsCount})`,
annotation: <IconLock narrow />,
path: PATH_ADMIN_TAGS,
});
}
if (recipesCount) {
adminSection.items.push({
label: `Manage Recipes (${recipesCount})`,
label: `${APP_TEXT.admin.manageRecipes} (${recipesCount})`,
annotation: <IconLock narrow />,
path: PATH_ADMIN_RECIPES,
});
}
adminSection.items.push({
label: selectedPhotoIds === undefined
? 'Batch Edit Photos ...'
: 'Exit Batch Edit',
? APP_TEXT.admin.batchEdit
: APP_TEXT.admin.batchExitEdit,
annotation: <IconLock narrow />,
path: selectedPhotoIds === undefined
? PATH_GRID_INFERRED
@ -510,7 +514,7 @@ export default function CommandKClient({
: () => setSelectedPhotoIds?.(undefined),
}, {
label: <span className="flex items-center gap-3">
App Insights
{APP_TEXT.admin.appInsights}
{insightsIndicatorStatus &&
<InsightsIndicatorDot />}
</span>,
@ -518,7 +522,7 @@ export default function CommandKClient({
annotation: <IconLock narrow />,
path: PATH_ADMIN_INSIGHTS,
}, {
label: 'App Config',
label: APP_TEXT.admin.appConfig,
annotation: <IconLock narrow />,
path: PATH_ADMIN_CONFIGURATION,
});
@ -534,14 +538,14 @@ export default function CommandKClient({
});
}
adminSection.items.push({
label: 'Sign Out',
label: APP_TEXT.auth.signOut,
action: () => signOutAction()
.then(clearAuthStateAndRedirectIfNecessary)
.then(() => setIsOpen?.(false)),
});
} else {
adminSection.items.push({
label: 'Sign In',
label: APP_TEXT.auth.signIn,
path: PATH_SIGN_IN,
});
}

View File

@ -7,7 +7,7 @@ export default function RepoLink() {
return (
<span className="inline-flex items-center gap-2 whitespace-nowrap">
<span className="hidden sm:inline-block">
{APP_TEXT.footer.repo}
{APP_TEXT.misc.repo}
</span>
<Link
href={TEMPLATE_REPO_URL}

View File

@ -1,9 +1,27 @@
import { I18NDeepPartial } from '..';
const TEXT: I18NDeepPartial = {
core: {
photo: {
photo: 'Foto',
photoPlural: 'Fotos',
taken: 'Capturado',
created: 'Criado',
updated: 'Atualizado',
},
category: {
camera: 'Câmera',
cameraPlural: 'Câmeras',
lens: 'Lente',
lensPlural: 'Lentes',
tag: 'Tag',
tagPlural: 'Tags',
tagged: 'Marcado',
recipe: 'Receita',
recipePlural: 'Receitas',
film: 'Filme',
filmPlural: 'Filmes',
focalLength: 'Distância Focal',
focalLengthPlural: 'Distâncias Focais',
},
nav: {
home: 'Início',
@ -16,37 +34,9 @@ const TEXT: I18NDeepPartial = {
next: 'Próximo',
nextShort: 'Prox',
},
footer: {
admin: 'Admin',
repo: 'Feito com',
system: 'Sistema',
light: 'Modo Claro',
dark: 'Modo Escuro',
},
cmdk: {
placeholder: 'Pesquisar fotos, visualizações, configurações ...',
},
category: {
camera: 'Câmera',
cameraPlural: 'Câmeras',
lens: 'Lente',
lensPlural: 'Lentes',
tag: 'Tag',
tagPlural: 'Tags',
recipe: 'Receita',
recipePlural: 'Receitas',
film: 'Filme',
filmPlural: 'Filmes',
focalLength: 'Distância Focal',
focalLengthPlural: 'Distâncias Focais',
},
auth: {
signIn: 'Entrar',
signOut: 'Sair',
email: 'Email do Admin',
password: 'Senha do Admin',
invalidEmailPassword: 'Email/senha inválidos',
},
tooltip: {
'35mm': 'Equivalente 35mm',
zoom: 'Aumentar Zoom',
@ -55,6 +45,38 @@ const TEXT: I18NDeepPartial = {
recipeCopy: 'Copiar Texto da Receita',
download: 'Baixar Arquivo Original',
},
theme: {
theme: 'Tema',
system: 'Usar Sistema',
light: 'Modo Claro',
dark: 'Modo Escuro',
},
auth: {
signIn: 'Entrar',
signOut: 'Sair',
email: 'Email do Admin',
password: 'Senha do Admin',
invalidEmailPassword: 'Email/senha inválidos',
},
admin: {
uploadPhotos: 'Enviar Fotos',
upload: 'Enviar',
uploadPlural: 'Envios',
updates: 'Atualizações',
managePhotos: 'Gerenciar Fotos',
manageCameras: 'Gerenciar Câmeras',
manageLenses: 'Gerenciar Lentes',
manageTags: 'Gerenciar Tags',
manageRecipes: 'Gerenciar Receitas',
batchEdit: 'Editar Fotos em Lote ...',
batchEditShort: 'Editar em Lote ...',
batchExitEdit: 'Sair da Edição em Lote',
appInsights: 'Insights do App',
appConfig: 'Configuração do App',
},
misc: {
repo: 'Feito com',
},
};
export default TEXT;

View File

@ -1,7 +1,25 @@
const TEXT = {
core: {
photo: {
photo: 'Photo',
photoPlural: 'Photos',
taken: 'Taken',
created: 'Created',
updated: 'Updated',
},
category: {
camera: 'Camera',
cameraPlural: 'Cameras',
lens: 'Lens',
lensPlural: 'Lenses',
tag: 'Tag',
tagPlural: 'Tags',
tagged: 'Tagged Photos',
recipe: 'Recipe',
recipePlural: 'Recipes',
film: 'Film',
filmPlural: 'Films',
focalLength: 'Focal Length',
focalLengthPlural: 'Focal Lengths',
},
nav: {
home: 'Home',
@ -14,37 +32,9 @@ const TEXT = {
next: 'Next',
nextShort: 'Next',
},
footer: {
admin: 'Admin',
repo: 'Made with',
system: 'System',
light: 'Light Mode',
dark: 'Dark Mode',
},
cmdk: {
placeholder: 'Search photos, views, settings ...',
},
category: {
camera: 'Camera',
cameraPlural: 'Cameras',
lens: 'Lens',
lensPlural: 'Lenses',
tag: 'Tag',
tagPlural: 'Tags',
recipe: 'Recipe',
recipePlural: 'Recipes',
film: 'Film',
filmPlural: 'Films',
focalLength: 'Focal Length',
focalLengthPlural: 'Focal Lengths',
},
auth: {
signIn: 'Sign in',
signOut: 'Sign out',
email: 'Admin Email',
password: 'Admin Password',
invalidEmailPassword: 'Invalid email/password',
},
tooltip: {
'35mm': '35mm Equivalent',
zoom: 'Zoom In',
@ -53,6 +43,45 @@ const TEXT = {
recipeCopy: 'Copy Recipe Text',
download: 'Download Original File',
},
theme: {
theme: 'Theme',
system: 'Use System',
light: 'Light Mode',
dark: 'Dark Mode',
},
auth: {
signIn: 'Sign In',
signOut: 'Sign Out',
email: 'Admin Email',
password: 'Admin Password',
invalidEmailPassword: 'Invalid email/password',
},
admin: {
uploadPhotos: 'Upload Photos',
upload: 'Upload',
uploadPlural: 'Uploads',
updates: 'Updates',
managePhotos: 'Manage Photos',
manageCameras: 'Manage Cameras',
manageLenses: 'Manage Lenses',
manageTags: 'Manage Tags',
manageRecipes: 'Manage Recipes',
batchEdit: 'Batch Edit Photos ...',
batchEditShort: 'Batch Edit ...',
batchExitEdit: 'Exit Batch Edit',
appInsights: 'App Insights',
appConfig: 'App Configuration',
},
misc: {
repo: 'Made with',
},
paginate: (
index: number,
count: number,
verb?: string,
) => verb
? `${verb} ${index} of ${count}`
: `${index} of ${count}`,
};
export default TEXT;

View File

@ -2,6 +2,7 @@ import ResponsiveDate from '@/components/ResponsiveDate';
import { Photo } from '.';
import { useMemo } from 'react';
import { Timezone } from '@/utility/timezone';
import { APP_TEXT } from '@/app/config';
export default function PhotoDate({
photo,
@ -33,11 +34,11 @@ export default function PhotoDate({
const getTitleLabel = () => {
switch (dateType) {
case 'takenAt':
return 'TAKEN';
return APP_TEXT.photo.taken;
case 'createdAt':
return 'CREATED';
return APP_TEXT.photo.created;
case 'updatedAt':
return 'UPDATED';
return APP_TEXT.photo.updated;
}
};
@ -45,7 +46,7 @@ export default function PhotoDate({
<ResponsiveDate {...{
date,
className,
titleLabel: getTitleLabel(),
titleLabel: getTitleLabel().toLocaleUpperCase(),
timezone,
hideTime,
}} />

View File

@ -23,7 +23,7 @@ export default function PhotoHeader({
photos,
selectedPhoto,
entity,
entityVerb = APP_TEXT.core.photo.toLocaleUpperCase(),
entityVerb = APP_TEXT.photo.photo.toLocaleUpperCase(),
entityDescription,
indexNumber,
count,
@ -51,9 +51,8 @@ export default function PhotoHeader({
? photos.findIndex(photo => photo.id === selectedPhoto.id)
: undefined;
const paginationLabel =
(indexNumber || (selectedPhotoIndex ?? 0 + 1)) + ' of ' +
(count ?? photos.length);
const paginationIndex = indexNumber || (selectedPhotoIndex ?? 0 + 1);
const paginationCount = count ?? photos.length;
const headerType = selectedPhotoIndex === undefined
? 'photo-set'
@ -155,8 +154,13 @@ export default function PhotoHeader({
dim: true,
}} />}
</>
: <ResponsiveText shortText={paginationLabel}>
{entityVerb} {paginationLabel}
: <ResponsiveText
shortText={APP_TEXT.paginate(paginationIndex, paginationCount)}
>
{APP_TEXT.paginate(
paginationIndex,
paginationCount,
entityVerb)}
</ResponsiveText>}
</>}
</div>

View File

@ -2,6 +2,7 @@ import { formatFocalLength } from '@/focal';
import { getNextImageUrlForRequest } from '@/platforms/next-image';
import { photoHasFilmData } from '@/film';
import {
APP_TEXT,
HIGH_DENSITY_GRID,
IS_PREVIEW,
SHOW_EXIF_DATA,
@ -17,7 +18,7 @@ import {
formatExposureCompensation,
formatExposureTime,
} from '@/utility/exif-format';
import { parameterize } from '@/utility/string';
import { capitalize, parameterize } from '@/utility/string';
import camelcaseKeys from 'camelcase-keys';
import { isBefore } from 'date-fns';
import type { Metadata } from 'next';
@ -231,10 +232,14 @@ export const titleForPhoto = (
export const altTextForPhoto = (photo: Photo) =>
photo.semanticDescription || titleForPhoto(photo);
export const photoLabelForCount = (count: number, capitalize = true) =>
capitalize
? count === 1 ? 'Photo' : 'Photos'
: count === 1 ? 'photo' : 'photos';
export const photoLabelForCount = (count: number, _capitalize = true) => {
const label = count === 1
? APP_TEXT.photo.photo
: APP_TEXT.photo.photoPlural;
return _capitalize
? capitalize(label)
: label;
};
export const photoQuantityText = (
count: number,

View File

@ -3,7 +3,7 @@ import PhotoTag from './PhotoTag';
import { descriptionForTaggedPhotos, isTagFavs } from '.';
import PhotoHeader from '@/photo/PhotoHeader';
import FavsTag from './FavsTag';
import { AI_TEXT_GENERATION_ENABLED } from '@/app/config';
import { AI_TEXT_GENERATION_ENABLED, APP_TEXT } from '@/app/config';
export default function TagHeader({
tag,
@ -26,7 +26,7 @@ export default function TagHeader({
entity={isTagFavs(tag)
? <FavsTag contrast="high" />
: <PhotoTag tag={tag} contrast="high" />}
entityVerb="Tagged"
entityVerb={APP_TEXT.category.tagged}
entityDescription={descriptionForTaggedPhotos(photos, undefined, count)}
photos={photos}
selectedPhoto={selectedPhoto}