Repository navigation
Expand file tree
/
Copy pathlanguages.js
More file actions
167 lines (150 loc) · 3.93 KB
/
Copy pathlanguages.js
File metadata and controls
167 lines (150 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* @emails react-core
* @flow
*/
import Layout from 'components/Layout';
import Container from 'components/Container';
import Header from 'components/Header';
import TitleAndMetaTags from 'components/TitleAndMetaTags';
import React from 'react';
import {urlRoot} from 'site-constants';
import {media, sharedStyles} from 'theme';
// $FlowFixMe This is a valid path
import languages from '../../content/languages.yml';
// Status enums indicate what percentage of "core" content has been translated:
// 0: Incomplete (0–49%)
// 1: Partially complete (50–94%)
// 2: Complete (95–100%)
const {complete, incomplete, partial} = languages.reduce(
(reduced, language) => {
switch (language.status) {
case 0:
reduced.incomplete.push(language);
break;
case 1:
reduced.partial.push(language);
break;
case 2:
reduced.complete.push(language);
break;
}
return reduced;
},
{complete: [], incomplete: [], partial: []},
);
type Props = {
location: Location,
};
const Languages = ({location}: Props) => (
<Layout location={location}>
<Container>
<div css={sharedStyles.articleLayout.container}>
<div css={sharedStyles.articleLayout.content}>
<Header>Languages</Header>
<TitleAndMetaTags
canonicalUrl={`${urlRoot}/languages/`}
title="React - Languages"
/>
<div css={sharedStyles.markdown}>
<p>
The React documentation is available in the following languages:
</p>
<LanguagesGrid languages={complete} />
<h2>In Progress</h2>
<LanguagesGrid languages={partial} />
<h2>Needs Contributors</h2>
<LanguagesGrid languages={incomplete} />
<p>
Don't see your language above?{' '}
<a
href="https://github.com/reactjs/reactjs.org-translation#reactjsorg-translation"
target="_blank"
rel="noopener">
Let us know
</a>
.
</p>
</div>
</div>
</div>
</Container>
</Layout>
);
const LanguagesGrid = ({languages}) => (
<ul
css={{
display: 'flex',
flexWrap: 'wrap',
marginLeft: -20,
}}>
{languages
.sort((a, b) => a.code.localeCompare(b.code))
.map(({code, name, status, translated_name}) => (
<Language
key={code}
code={code}
name={name}
status={status}
translatedName={translated_name}
/>
))}
</ul>
);
const Language = ({code, name, status, translatedName}) => {
const prefix = code === 'en' ? '' : `${code}.`;
return (
<li
css={{
paddingLeft: 20,
paddingTop: 20,
borderTop: '1px dotted #ececec',
paddingBottom: 20,
width: '100%',
listStyle: 'none',
[media.size('small')]: {
width: '50%',
},
[media.size('medium')]: {
width: '33.33%',
},
[media.greaterThan('large')]: {
width: '25%',
},
}}
key={code}>
<div css={{}}>{name}</div>
<div
css={{
fontSize: 22,
fontWeight: 'bold',
marginBottom: 8,
marginTop: 8,
}}>
{status === 0 && translatedName}
{status > 0 && (
<a
href={`https://${prefix}reactjs.org/`}
rel="nofollow"
lang={code}
hrefLang={code}>
{translatedName}
</a>
)}
</div>
<div css={{marginTop: 10}}>
<a
css={{
fontSize: 12,
}}
href={`https://github.com/reactjs/${prefix}reactjs.org/`}
target="_blank"
rel="noopener">
Contribute
</a>
</div>
</li>
);
};
export default Languages;