diff --git a/components/community/InstitutionsGrid.tsx b/components/community/InstitutionsGrid.tsx index c37fe32..794cd09 100644 --- a/components/community/InstitutionsGrid.tsx +++ b/components/community/InstitutionsGrid.tsx @@ -2,12 +2,16 @@ import { useTranslation } from 'react-i18next' import '@/app/i18n' -import { getInstitutions, getFunderLogos } from '@/lib/institutions' +import { getInstitutions, getFunderLogos, getInstitutionRole } from '@/lib/institutions' export function InstitutionsGrid() { - const { t } = useTranslation('about') + const { t, i18n } = useTranslation('about') + const lang = i18n.language || 'en' const institutions = [ - ...getInstitutions(), + ...getInstitutions().map((inst) => ({ + ...inst, + role: getInstitutionRole(inst, lang), + })), ...getFunderLogos().map((f) => ({ id: f.id, name: f.name, diff --git a/components/community/routes/AboutRoute.tsx b/components/community/routes/AboutRoute.tsx index f4181f2..650bd78 100644 --- a/components/community/routes/AboutRoute.tsx +++ b/components/community/routes/AboutRoute.tsx @@ -11,12 +11,7 @@ import '@/app/i18n' export function AboutRoute() { const { t, i18n } = useTranslation('about') const th = (key: string, options?: Record) => ({ __html: t(key, options) }) - const lang = i18n.language?.startsWith('es') - ? 'es' - : i18n.language?.startsWith('pt') - ? 'pt' - : 'en' - const acknowledgment = getAcknowledgmentsText(lang) + const acknowledgment = getAcknowledgmentsText(i18n.language) const [version, setVersion] = useState('0.9.6') diff --git a/lib/institutions-data.json b/lib/institutions-data.json index a3e544c..f97bd0a 100644 --- a/lib/institutions-data.json +++ b/lib/institutions-data.json @@ -5,7 +5,13 @@ "id": "uchile", "name": "University of Chile", "fullName": "Universidad de Chile", - "role": "Leading Institution", + "role": { + "en": "Leading Institution", + "es": "Institución Líder", + "pt": "Instituição Líder", + "de": "Federführende Institution", + "zh": "牵头机构" + }, "url": "https://uchile.cl/", "logo": "institutions/dcc-logo.png", "small": true @@ -14,7 +20,13 @@ "id": "fcfm", "name": "Fcfm", "fullName": "Facultad de Ciencias Físicas y Matemáticas Universidad de Chile", - "role": "Leading Institution", + "role": { + "en": "Leading Institution", + "es": "Institución Líder", + "pt": "Instituição Líder", + "de": "Federführende Institution", + "zh": "牵头机构" + }, "url": "https://www.fcfm.uchile.cl/", "logo": "institutions/fcfm-logo.png" }, @@ -22,7 +34,13 @@ "id": "cenia", "name": "CENIA", "fullName": "National Center for Artificial Intelligence", - "role": "Associated Institution", + "role": { + "en": "Associated Institution", + "es": "Institución Asociada", + "pt": "Instituição Associada", + "de": "Assoziierte Institution", + "zh": "联合机构" + }, "url": "https://www.cenia.cl/", "logo": "institutions/cenia-logo.png" }, @@ -30,7 +48,13 @@ "id": "imfd", "name": "IMFD", "fullName": "Millennium Institute for Foundational Data Research", - "role": "Collaborator", + "role": { + "en": "Collaborator", + "es": "Colaborador", + "pt": "Colaborador", + "de": "Mitwirkender", + "zh": "合作者" + }, "url": "https://imfd.cl/en/", "logo": "institutions/imfd-logo.png" }, @@ -38,7 +62,13 @@ "id": "unholster", "name": "Unholster", "fullName": "Unholster", - "role": "Industry Partner", + "role": { + "en": "Industry Partner", + "es": "Socio Industrial", + "pt": "Parceiro Industrial", + "de": "Industriepartner", + "zh": "行业合作伙伴" + }, "url": "https://unholster.com/", "logo": "institutions/unholster-logo.png" } @@ -47,7 +77,9 @@ "text": { "en": "Supported by ANID through Fondef IDEA ID25I10330, Fondef VIU23P 0110, and grants supporting the centers CENIA (FB210017) and IMFD (ICN17_002). Developed by students of DCC UChile and UTFSM.", "es": "Financiado por ANID a través de Fondef IDEA ID25I10330, Fondef VIU23P 0110 y los fondos que apoyan a los centros CENIA (FB210017) e IMFD (ICN17_002). Desarrollado por estudiantes del DCC UChile y la UTFSM.", - "pt": "Financiado pela ANID por meio do Fondef IDEA ID25I10330, do Fondef VIU23P 0110 e dos fundos que apoiam os centros CENIA (FB210017) e IMFD (ICN17_002). Desenvolvido por estudantes do DCC UChile e da UTFSM." + "pt": "Financiado pela ANID por meio do Fondef IDEA ID25I10330, do Fondef VIU23P 0110 e dos fundos que apoiam os centros CENIA (FB210017) e IMFD (ICN17_002). Desenvolvido por estudantes do DCC UChile e da UTFSM.", + "de": "Unterstützt von ANID durch Fondef IDEA ID25I10330, Fondef VIU23P 0110 sowie durch Fördermittel für die Zentren CENIA (FB210017) und IMFD (ICN17_002). Entwickelt von Studierenden der DCC UChile und der UTFSM.", + "zh": "由 ANID 通过 Fondef IDEA ID25I10330、Fondef VIU23P 0110 项目,以及支持 CENIA(FB210017)和 IMFD(ICN17_002)中心的资助提供支持。由 DCC UChile 和 UTFSM 的学生开发。" }, "grants": [ "ID25I10330", diff --git a/lib/institutions.ts b/lib/institutions.ts index 1ea4f51..32bbe48 100644 --- a/lib/institutions.ts +++ b/lib/institutions.ts @@ -1,10 +1,17 @@ import institutionsData from './institutions-data.json' assert { type: 'json' }; +// Languages published today in institutions.json. If the site adds support for +// a locale not listed here, resolveLocalized() falls back to English rather +// than breaking — but the source JSON should be updated to add it properly. +export type SupportedLang = 'en' | 'es' | 'pt' | 'de' | 'zh'; + +export type LocalizedText = Partial> & { en: string }; + export type Institution = { id: string; name: string; fullName?: string; - role: string; + role: LocalizedText; url: string; logo: string; small?: boolean; @@ -21,28 +28,28 @@ export type FunderLogo = { export type Institutions = { institutions: Institution[]; acknowledgments: { - text: { - en: string; - es: string; - pt?: string; - }; + text: LocalizedText; grants?: string[]; logos?: FunderLogo[]; }; }; +function resolveLocalized(text: LocalizedText | undefined, lang: string): string { + return text?.[lang as SupportedLang] || text?.en || ''; +} + export function getInstitutions(): Institution[] { const data = institutionsData as Institutions; return data.institutions || []; } -export function getAcknowledgmentsText(lang: 'en' | 'es' | 'pt' = 'en'): string { +export function getInstitutionRole(institution: Institution, lang: string): string { + return resolveLocalized(institution.role, lang); +} + +export function getAcknowledgmentsText(lang: string = 'en'): string { const data = institutionsData as Institutions; - return ( - data.acknowledgments?.text?.[lang] || - data.acknowledgments?.text?.en || - '' - ); + return resolveLocalized(data.acknowledgments?.text, lang); } export function getFunderLogos(): FunderLogo[] {