Skip to content

Commit 31b903f

Browse files
committed
Add more strings, fix language swithcer routing and add more translations
1 parent d40df96 commit 31b903f

File tree

14 files changed

+276
-54
lines changed

14 files changed

+276
-54
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"extract": "lingui extract",
88
"compile": "lingui compile",
99
"dev": "next dev",
10-
"build": "yarn extract && next build",
10+
"build": "yarn extract && yarn compile && next build",
1111
"start": "next start",
1212
"lint": "next lint"
1313
},

public/atom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<feed xmlns="http://www.w3.org/2005/Atom">
33
<id>https://xarray.dev/blog</id>
44
<title>Xarray Blog Feed</title>
5-
<updated>2025-05-03T18:37:55.874Z</updated>
5+
<updated>2025-05-04T15:06:18.664Z</updated>
66
<generator>https://github.com/jpmonette/feed</generator>
77
<link rel="alternate" href="https://xarray.dev/blog"/>
88
<link rel="self" href="https://xarray.dev/atom.xml"/>

public/rss.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<title>Xarray Blog Feed</title>
55
<link>https://xarray.dev/blog</link>
66
<description>The latest news, insights, and practices about Xarray from the Xarray team</description>
7-
<lastBuildDate>Sat, 03 May 2025 18:37:55 GMT</lastBuildDate>
7+
<lastBuildDate>Sun, 04 May 2025 15:06:18 GMT</lastBuildDate>
88
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
99
<generator>https://github.com/jpmonette/feed</generator>
1010
<language>en</language>

src/components/dashboard/issue-tracker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ export const IssueTracker = () => {
1717
<SimpleGrid columns={{ base: 1, md: 2 }} spacing={{ base: 5, lg: 8 }}>
1818
{' '}
1919
<TimeseriesAggStatsCard
20-
title={'Median time a pull request is open'}
20+
title={t`Median time a pull request is open`}
2121
query={
2222
'https://xarray-datasette.fly.dev/github.json?_shape=array&&sql=select%0D%0A++id%2C%0D%0A++number%2C%0D%0A++state%2C%0D%0A++created_at%2C%0D%0A++closed_at%2C%0D%0A++julianday%28closed_at%29+-+julianday%28created_at%29+as+age_in_days%0D%0Afrom%0D%0A++issues+as+data%0D%0Awhere%0D%0A++type+%3D+%27pull%27%0D%0A++and+state+%3D+%27closed%27%0D%0Aorder+by%0D%0A++id'
2323
}
2424
icon={<GiDuration size={'3em'} />}
2525
/>
2626
<TimeseriesAggStatsCard
27-
title={'Median time an issue is open'}
27+
title={t`Median time an issue is open`}
2828
icon={<GiDuration size={'3em'} />}
2929
query={
3030
'https://xarray-datasette.fly.dev/github.json?_shape=array&&sql=select%0D%0A++id%2C%0D%0A++number%2C%0D%0A++state%2C%0D%0A++created_at%2C%0D%0A++closed_at%2C%0D%0A++julianday%28closed_at%29+-+julianday%28created_at%29+as+age_in_days%0D%0Afrom%0D%0A++issues+as+data%0D%0Awhere%0D%0A++type+%3D+%27issue%27%0D%0A++and+state+%3D+%27closed%27%0D%0Aorder+by%0D%0A++id'

src/components/dashboard/project-metrics.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ export const ProjectMetrics = () => {
4141
</Heading>
4242
<SimpleGrid columns={{ base: 1, md: 3 }} spacing={{ base: 5, lg: 8 }}>
4343
<StatisticsCard
44-
title={'Core Maintainers'}
44+
title={t`Core Maintainers`}
4545
stat={'15'}
4646
icon={<BsPerson size={'3em'} />}
4747
link={'https://docs.xarray.dev/en/stable/team.html'}
4848
/>
4949
<DatasetteStatsCard
50-
title={'Contributors'}
50+
title={t`Contributors`}
5151
query={
5252
'https://xarray-datasette.fly.dev/github/_analyze_tables_/contributors,user_id.json?_shape=array'
5353
}
@@ -56,7 +56,7 @@ export const ProjectMetrics = () => {
5656
/>
5757

5858
<DatasetteStatsCard
59-
title={'Stargazers'}
59+
title={t`Stargazers`}
6060
icon={<GoStar size={'3em'} />}
6161
query={
6262
'https://xarray-datasette.fly.dev/github/_analyze_tables_/stars,user.json?_shape=array'
@@ -65,20 +65,20 @@ export const ProjectMetrics = () => {
6565
/>
6666

6767
<StatisticsCard
68-
title={'Dependent Packages/Repos'}
68+
title={t`Dependent Packages/Repos`}
6969
stat={21275}
7070
icon={<GoPackage size={'3em'} />}
7171
link={'https://github.com/pydata/xarray/network/dependents'}
7272
/>
7373

7474
<StatisticsCard
75-
title={`${month}/${year} Docs Visitors`}
75+
title={t`Docs Visitors` + ` - ${month}/${year}`}
7676
stat={monthlyViews.users}
7777
icon={<GoBook size={'3em'} />}
7878
/>
7979

8080
<DatasetteStatsCard
81-
title={'Releases'}
81+
title={t`Releases`}
8282
query={
8383
'https://xarray-datasette.fly.dev/github/_analyze_tables_/releases,id.json?_shape=array'
8484
}

src/components/dashboard/timeseries-agg-stats-card.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import useSWR from 'swr'
77
import { useLingui } from '@lingui/react/macro'
88

99
export const TimeseriesAggStatsCard = ({ query, title, icon }) => {
10+
const { t } = useLingui()
1011
let { data, error } = useSWR(query, fetcher)
1112
if (error) return <Text>{t`failed to load`}</Text>
1213
if (!data)
@@ -52,8 +53,8 @@ export const TimeseriesAggStatsCard = ({ query, title, icon }) => {
5253
icon={icon}
5354
stat={
5455
result <= 2
55-
? `${d3.format('.1f')(result * 24)} hours`
56-
: `${d3.format('.1f')(result)} days`
56+
? `${d3.format('.1f')(result * 24)} ` + t`hours`
57+
: `${d3.format('.1f')(result)} ` + t`days`
5758
}
5859
diff={change}
5960
/>
Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,39 @@
11
'use client'
2-
import { Select } from '@chakra-ui/react'
32
import { useLingui } from '@lingui/react/macro'
43
import { i18n } from '@lingui/core'
54
import { useRouter, usePathname } from 'next/navigation'
6-
import { useState, useEffect } from 'react'
5+
import { useEffect } from 'react'
6+
import {
7+
Menu,
8+
MenuButton,
9+
MenuList,
10+
MenuItem,
11+
Link,
12+
Button,
13+
} from '@chakra-ui/react'
14+
15+
function getLocales() {
16+
const { t } = useLingui()
17+
return [
18+
{ locale: 'en', label: t`English` },
19+
{ locale: 'es', label: t`Spanish` },
20+
{ locale: 'pt', label: t`Portuguese` },
21+
]
22+
}
23+
24+
function getLocaleLabel(locale) {
25+
const locales = getLocales()
26+
const localeObject = locales.find((object) => object.locale === locale)
27+
return localeObject ? localeObject.label : locale
28+
}
729

830
export const LanguageSwitcher = () => {
931
const { t } = useLingui()
1032
const router = useRouter()
1133
const pathname = usePathname()
12-
const [selectedValue, setSelectedValue] = useState('')
1334

14-
async function changeLocale(event) {
15-
const localeString = event.target.value
16-
setSelectedValue(localeString)
35+
async function changeLocale() {
36+
const localeString = i18n.locale
1737
localStorage.setItem('locale', localeString)
1838
const catalog = await import(`../locales/${localeString}/messages.js`)
1939
i18n.load(localeString, catalog.messages)
@@ -28,16 +48,19 @@ export const LanguageSwitcher = () => {
2848
}
2949
}, [])
3050
return (
31-
<Select
32-
name='selectedLocale'
33-
variant='flushed'
34-
size='xs'
35-
value={selectedValue}
36-
onChange={changeLocale}
37-
>
38-
<option value='en'>{t`English`}</option>
39-
<option value='es'>{t`Spanish`}</option>
40-
<option value='pt'>{t`Portuguese`}</option>
41-
</Select>
51+
<Menu>
52+
<MenuButton as={Button} size='xs' variant='outline'>
53+
{getLocaleLabel(i18n.locale)}
54+
</MenuButton>
55+
<MenuList>
56+
{getLocales().map((object) => (
57+
<Link href={'/' + object.locale + pathname} onClick={changeLocale}>
58+
<MenuItem as={Button} size='xs' command={object.locale}>
59+
{object.label}
60+
</MenuItem>
61+
</Link>
62+
))}
63+
</MenuList>
64+
</Menu>
4265
)
4366
}

0 commit comments

Comments
 (0)