Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions components/community/InstitutionsGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 1 addition & 6 deletions components/community/routes/AboutRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ import '@/app/i18n'
export function AboutRoute() {
const { t, i18n } = useTranslation('about')
const th = (key: string, options?: Record<string, string>) => ({ __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')

Expand Down
44 changes: 38 additions & 6 deletions lib/institutions-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -14,31 +20,55 @@
"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"
},
{
"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"
},
{
"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"
},
{
"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"
}
Expand All @@ -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",
Expand Down
31 changes: 19 additions & 12 deletions lib/institutions.ts
Original file line number Diff line number Diff line change
@@ -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<Record<SupportedLang, string>> & { en: string };

export type Institution = {
id: string;
name: string;
fullName?: string;
role: string;
role: LocalizedText;
url: string;
logo: string;
small?: boolean;
Expand All @@ -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[] {
Expand Down
Loading