Skip to content

Commit 817a73e

Browse files
authored
Merge branch 'dev' into chakra/roadmap
2 parents b3809c8 + 74816b9 commit 817a73e

File tree

124 files changed

+13577
-14285
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+13577
-14285
lines changed

.all-contributorsrc

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9718,6 +9718,62 @@
97189718
"doc",
97199719
"ideas"
97209720
]
9721+
},
9722+
{
9723+
"login": "aguzmant103",
9724+
"name": "aguzmant103",
9725+
"avatar_url": "https://avatars.githubusercontent.com/u/67167307?v=4",
9726+
"profile": "https://github.com/aguzmant103",
9727+
"contributions": [
9728+
"doc"
9729+
]
9730+
},
9731+
{
9732+
"login": "soheil555",
9733+
"name": "Soheil",
9734+
"avatar_url": "https://avatars.githubusercontent.com/u/22212139?v=4",
9735+
"profile": "https://soheil.vercel.app/",
9736+
"contributions": [
9737+
"code"
9738+
]
9739+
},
9740+
{
9741+
"login": "metadiver",
9742+
"name": "metadiver.eth",
9743+
"avatar_url": "https://avatars.githubusercontent.com/u/75746881?v=4",
9744+
"profile": "http://linktr.ee/metadiver",
9745+
"contributions": [
9746+
"code"
9747+
]
9748+
},
9749+
{
9750+
"login": "nuclearfalcon",
9751+
"name": "Jacob",
9752+
"avatar_url": "https://avatars.githubusercontent.com/u/12568736?v=4",
9753+
"profile": "https://github.com/nuclearfalcon",
9754+
"contributions": [
9755+
"ideas",
9756+
"doc"
9757+
]
9758+
},
9759+
{
9760+
"login": "theSamPadilla",
9761+
"name": "Sam Padilla",
9762+
"avatar_url": "https://avatars.githubusercontent.com/u/35386211?v=4",
9763+
"profile": "https://github.com/theSamPadilla",
9764+
"contributions": [
9765+
"doc"
9766+
]
9767+
},
9768+
{
9769+
"login": "terasum",
9770+
"name": "Chen Quan",
9771+
"avatar_url": "https://avatars.githubusercontent.com/u/20042193?v=4",
9772+
"profile": "https://chenquan.me",
9773+
"contributions": [
9774+
"doc",
9775+
"translation"
9776+
]
97219777
}
97229778
],
97239779
"contributorsPerLine": 7,

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ yarn-error.log
7676
src/data/contributors.json
7777
# These files are generated by `yarn merge-translations` command
7878
src/intl/*.json
79-
i18n/locales
8079
# Auto generated code when gatsby build the site
8180
src/gatsby-types.d.ts
8281

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,12 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
15271527
</tr>
15281528
<tr>
15291529
<td align="center"><a href="http://olshansky.info"><img src="https://avatars.githubusercontent.com/u/1892194?v=4?s=100" width="100px;" alt="Daniel Olshansky"/><br /><sub><b>Daniel Olshansky</b></sub></a><br /><a href="https://github.com/ethereum/ethereum-org-website/commits?author=Olshansk" title="Documentation">📖</a> <a href="#ideas-Olshansk" title="Ideas, Planning, & Feedback">🤔</a></td>
1530+
<td align="center"><a href="https://github.com/aguzmant103"><img src="https://avatars.githubusercontent.com/u/67167307?v=4?s=100" width="100px;" alt="aguzmant103"/><br /><sub><b>aguzmant103</b></sub></a><br /><a href="https://github.com/ethereum/ethereum-org-website/commits?author=aguzmant103" title="Documentation">📖</a></td>
1531+
<td align="center"><a href="https://soheil.vercel.app/"><img src="https://avatars.githubusercontent.com/u/22212139?v=4?s=100" width="100px;" alt="Soheil"/><br /><sub><b>Soheil</b></sub></a><br /><a href="https://github.com/ethereum/ethereum-org-website/commits?author=soheil555" title="Code">💻</a></td>
1532+
<td align="center"><a href="http://linktr.ee/metadiver"><img src="https://avatars.githubusercontent.com/u/75746881?v=4?s=100" width="100px;" alt="metadiver.eth"/><br /><sub><b>metadiver.eth</b></sub></a><br /><a href="https://github.com/ethereum/ethereum-org-website/commits?author=metadiver" title="Code">💻</a></td>
1533+
<td align="center"><a href="https://github.com/nuclearfalcon"><img src="https://avatars.githubusercontent.com/u/12568736?v=4?s=100" width="100px;" alt="Jacob"/><br /><sub><b>Jacob</b></sub></a><br /><a href="#ideas-nuclearfalcon" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/ethereum/ethereum-org-website/commits?author=nuclearfalcon" title="Documentation">📖</a></td>
1534+
<td align="center"><a href="https://github.com/theSamPadilla"><img src="https://avatars.githubusercontent.com/u/35386211?v=4?s=100" width="100px;" alt="Sam Padilla"/><br /><sub><b>Sam Padilla</b></sub></a><br /><a href="https://github.com/ethereum/ethereum-org-website/commits?author=theSamPadilla" title="Documentation">📖</a></td>
1535+
<td align="center"><a href="https://chenquan.me"><img src="https://avatars.githubusercontent.com/u/20042193?v=4?s=100" width="100px;" alt="Chen Quan"/><br /><sub><b>Chen Quan</b></sub></a><br /><a href="https://github.com/ethereum/ethereum-org-website/commits?author=terasum" title="Documentation">📖</a> <a href="#translation-terasum" title="Translation">🌍</a></td>
15301536
</tr>
15311537
</tbody>
15321538
</table>

gatsby-browser.tsx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
* See: https://www.gatsbyjs.org/docs/browser-apis/
55
*/
66

7+
import React from "react"
8+
import browserLang from "browser-lang"
9+
import { withPrefix, GatsbyBrowser } from "gatsby"
10+
711
import Prism from "prism-react-renderer/prism"
812
;(typeof global !== "undefined" ? global : window).Prism = Prism
913

@@ -12,6 +16,53 @@ import "@formatjs/intl-locale/polyfill"
1216
import "@formatjs/intl-numberformat/polyfill"
1317
import "@formatjs/intl-numberformat/locale-data/en"
1418

19+
import Layout from "./src/components/Layout"
20+
import {
21+
supportedLanguages,
22+
defaultLanguage,
23+
isLang,
24+
} from "./src/utils/languages"
25+
import { IS_DEV } from "./src/utils/env"
26+
import { Context } from "./src/types"
27+
1528
// Default languages included:
1629
// https://github.com/FormidableLabs/prism-react-renderer/blob/master/src/vendor/prism/includeLangs.js
1730
require("prismjs/components/prism-solidity")
31+
32+
// Prevents <Layout/> from unmounting on page transitions
33+
// https://www.gatsbyjs.com/docs/layout-components/#how-to-prevent-layout-components-from-unmounting
34+
// @ts-ignore: returning `null` is not accepted by the `GatsbyBrowser` type def.
35+
export const wrapPageElement: GatsbyBrowser<
36+
any,
37+
Context
38+
>["wrapPageElement"] = ({ element, props }) => {
39+
const { location, pageContext } = props
40+
const { pathname, search } = location
41+
const { originalPath } = pageContext
42+
43+
const [, pathLocale] = pathname.split("/")
44+
45+
// client side redirect on paths that don't have a locale in them. Most useful
46+
// on dev env where we don't have server redirects
47+
if (IS_DEV && !isLang(pathLocale)) {
48+
let detected =
49+
window.localStorage.getItem("eth-org-language") ||
50+
browserLang({
51+
languages: supportedLanguages,
52+
fallback: defaultLanguage,
53+
})
54+
55+
if (!isLang(detected)) {
56+
detected = defaultLanguage
57+
}
58+
59+
const queryParams = search || ""
60+
const newUrl = withPrefix(`/${detected}${originalPath}${queryParams}`)
61+
window.localStorage.setItem("eth-org-language", detected)
62+
window.location.replace(newUrl)
63+
64+
return null
65+
}
66+
67+
return <Layout {...props}>{element}</Layout>
68+
}

gatsby-config.ts

Lines changed: 18 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ const config: GatsbyConfig = {
3535
editContentUrl: `https://github.com/ethereum/ethereum-org-website/tree/dev/`,
3636
},
3737
plugins: [
38+
// i18n support
39+
{
40+
resolve: `gatsby-theme-i18n`,
41+
options: {
42+
defaultLang: defaultLanguage,
43+
prefixDefault: true,
44+
locales: supportedLanguages.length
45+
? supportedLanguages.join(" ")
46+
: null,
47+
configPath: path.resolve(`./i18n/config.json`),
48+
},
49+
},
50+
{
51+
resolve: `gatsby-theme-i18n-react-intl`,
52+
options: {
53+
defaultLocale: `./src/intl/en.json`,
54+
},
55+
},
3856
// Web app manifest
3957
{
4058
resolve: `gatsby-plugin-manifest`,
@@ -247,56 +265,6 @@ const config: GatsbyConfig = {
247265
generateMatchPathRewrites: false,
248266
},
249267
},
250-
// i18n support
251-
{
252-
resolve: `gatsby-source-filesystem`,
253-
options: {
254-
path: path.resolve(`./i18n/locales`),
255-
name: `locale`,
256-
},
257-
},
258-
// Wraps the entire page with a custom layout component
259-
// Note: keep this before the i18n plugin declaration in order to have the
260-
// i18n provider wrapping the layout component
261-
{
262-
resolve: `gatsby-plugin-layout`,
263-
options: {
264-
component: path.resolve(`./src/components/Layout`),
265-
},
266-
},
267-
{
268-
resolve: `gatsby-plugin-react-i18next`,
269-
options: {
270-
localeJsonSourceName: `locale`, // name given to `gatsby-source-filesystem` plugin.
271-
languages: supportedLanguages,
272-
defaultLanguage: defaultLanguage,
273-
generateDefaultLanguagePage: true,
274-
redirect: false,
275-
siteUrl,
276-
trailingSlash: "always",
277-
// i18next options
278-
i18nextOptions: {
279-
fallbackLng: defaultLanguage,
280-
interpolation: {
281-
escapeValue: false,
282-
},
283-
react: {
284-
transSupportBasicHtmlNodes: true,
285-
transKeepBasicHtmlNodesFor: [
286-
"br",
287-
"strong",
288-
"i",
289-
"bold",
290-
"b",
291-
"em",
292-
"sup",
293-
],
294-
},
295-
keySeparator: false,
296-
nsSeparator: false,
297-
},
298-
},
299-
},
300268
],
301269
// https://www.gatsbyjs.com/docs/reference/release-notes/v2.28/#feature-flags-in-gatsby-configjs
302270
flags: {

0 commit comments

Comments
 (0)