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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ yarn-error.log

.temp
.env*
!.env.sample
!.env.sample

build/
6 changes: 5 additions & 1 deletion langs/langs.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
{ "code": "ml", "name": "മലയാളം", "enName": "Malayalam" },
{ "code": "mn", "name": "Монгол хэл", "enName": "Mongolian" },
{ "code": "pl", "name": "Polski", "enName": "Polish" },
{ "code": "pt-br", "name": "Português do Brasil", "enName": "Portuguese (Brazil)" },
{
"code": "pt-br",
"name": "Português do Brasil",
"enName": "Portuguese (Brazil)"
},
{ "code": "ru", "name": "Русский", "enName": "Russian" },
{ "code": "si", "name": "සිංහල", "enName": "Sinhala" },
{ "code": "sr", "name": "Srpski", "enName": "Serbian" },
Expand Down
3 changes: 3 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@

# Copied on build
src/langs.json

.next/
out/
File renamed without changes.
20 changes: 20 additions & 0 deletions website/app/layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'what-input'
import '../src/reset.css'
import '../src/box-sizing.css'
import '../src/a11y.css'

export const metadata = {
title: 'Is React Translated Yet?',
description: 'The global React community is translating react.dev into multiple languages',
}

export default function RootLayout({ children }) {
return (
<html lang="en">
<head>
<link rel="icon" href="/app/favicon.ico" />
</head>
<body>{children}</body>
</html>
)
}
92 changes: 92 additions & 0 deletions website/app/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import App from '../src/App'
import langs from '../src/langs.json'
import { graphql } from '@octokit/graphql'
import fromPairs from 'lodash/fromPairs'

function getLangProgress(lang, issue) {
const { body, createdAt, lastEditedAt = createdAt, ...issueProps } = issue
let coreCompletion = 0
let otherCompletion = 0
body.split(/^##\s+/gm).forEach((section) => {
const [heading, ...content] = section.split('\n')
const items = content.filter((line) => {
return /[-*] *\[[ x]\]/.test(line)
})
const finishedItems = items.filter((line) => /[-*] \[x\]/.test(line))
if (/MAIN_CONTENT/.test(heading)) {
coreCompletion = finishedItems.length / items.length
} else if (/SECONDARY_CONTENT/.test(heading)) {
otherCompletion = finishedItems.length / items.length
}
})
return {
...lang,
...issueProps,
createdAt,
lastEditedAt,
coreCompletion,
otherCompletion,
}
}

async function getProgressList(langs) {
const { search } = await graphql(
`
query ($limit: Int!) {
search(
type: ISSUE
query: "org:reactjs Translation Progress in:title is:open"
first: $limit
) {
nodes {
... on Issue {
title
body
createdAt
lastEditedAt
number
repository {
name
}
}
}
}
}
`,
{
headers: {
authorization: `token ${process.env.REACT_APP_GITHUB_AUTH_TOKEN}`,
},
limit: langs.length + 15,
},
)

const issuesMap = fromPairs(
search.nodes
.filter((issue) => !!issue && issue.repository)
.map((issue) => [issue.repository.name.toLowerCase(), issue]),
)

return langs
.map((lang) => {
const issue = issuesMap[`${lang.code.toLowerCase()}.react.dev`]
return issue ? getLangProgress(lang, issue) : null
})
.filter(Boolean)
}

export default async function HomePage() {
let progressList
try {
progressList = await getProgressList(langs)
} catch (e) {
progressList = langs.map(lang => ({
...lang,
coreCompletion: undefined,
otherCompletion: undefined,
createdAt: undefined,
lastEditedAt: undefined,
}))
}
return <App progressList={progressList} />
}
25 changes: 25 additions & 0 deletions website/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { dirname } from 'path'
import { fileURLToPath } from 'url'
import { FlatCompat } from '@eslint/eslintrc'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

const compat = new FlatCompat({
baseDirectory: __dirname,
})

const eslintConfig = [
...compat.extends('next'),
{
ignores: [
'node_modules/**',
'.next/**',
'out/**',
'build/**',
'next-env.d.ts',
],
},
]

export default eslintConfig
5 changes: 5 additions & 0 deletions website/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
}

module.exports = nextConfig
Loading