Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement i18n #37 #50

Merged
merged 5 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
13 changes: 8 additions & 5 deletions client/components/Landing.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Image, Heading, Box } from '@chakra-ui/react';

import { useTranslation } from 'next-i18next';
import NextLink from 'next/link';

import {
Expand All @@ -9,6 +10,8 @@ import {
} from '../styles/ui-components/Chakra-Button';

export default function Landing() {
const { t } = useTranslation('common');

return (
<Box>
<Box w="auto" h="auto" m="auto" mt="2.5%">
Expand All @@ -24,21 +27,21 @@ export default function Landing() {

<Box textAlign="center">
<Heading m="10px" fontSize="28px">
Looking for Web3 talent?
{t('landing.looking_for_talent')}
</Heading>
<NextLink href="/developers">
<ButtonGreen as="a">Search Devs</ButtonGreen>
<ButtonGreen as="a">{t('landing.search_devs')}</ButtonGreen>
</NextLink>

<NextLink href="/post-job">
<ButtonBlue as="a">Post a Job</ButtonBlue>
<ButtonBlue as="a">{t('landing.post_job')}</ButtonBlue>
</NextLink>

<Heading m="10px" fontSize="28px">
Looking for Web3 work?
{t('landing.looking_for_work')}
</Heading>
<NextLink href="/jobs">
<ButtonRed as="a">Search Jobs</ButtonRed>
<ButtonRed as="a">{t('landing.search_jobs')}</ButtonRed>
</NextLink>
</Box>
</Box>
Expand Down
8 changes: 8 additions & 0 deletions client/next-i18next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
i18n: {
defaultLocale: 'en',
locales: ['en', ],
defaultLanguage: 'en',
fallbackLng: ['en'],
},
};
3 changes: 3 additions & 0 deletions client/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const { i18n } = require('./next-i18next.config');

module.exports = {
i18n,
reactStrictMode: true,
env: {
SUPABASE_URL: process.env.SUPABASE_URL,
Expand Down
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"cross-env": "^7.0.3",
"framer-motion": "^4.1.17",
"next": "12.0.1",
"next-i18next": "^9.2.0",
"nextjs": "0.0.3",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down
7 changes: 5 additions & 2 deletions client/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import Navbar from '../components/navigation/Navbar';
import { ChakraProvider, ColorModeScript } from '@chakra-ui/react';
import { theme } from '../styles/theme';
import { DAppProvider } from '@usedapp/core';
import { AuthProvider } from '../hooks/useAuth';

import { AuthProvider } from '@/hooks/useAuth';
import { appWithTranslation } from 'next-i18next';


function MyApp({ Component, pageProps }: AppProps) {
return (
Expand All @@ -19,4 +22,4 @@ function MyApp({ Component, pageProps }: AppProps) {
);
}

export default MyApp;
export default appWithTranslation(MyApp);
12 changes: 11 additions & 1 deletion client/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import Landing from '../components/Landing';
import Head from 'next/head';
import { useTranslation } from 'next-i18next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import Navbar from '../components/navigation/Navbar';

export default function Home() {
const { t } = useTranslation('common');
return (
<div>
<Head>
<title>Job Board</title>
<title>{t('common.title')}</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/DeveloperDaoFavicon.ico" />
</Head>
<Landing />
</div>
);
}

export const getStaticProps = async ({ locale }: { locale: string }) => ({
props: {
...(await serverSideTranslations(locale, ['common'])),
},
});
17 changes: 17 additions & 0 deletions client/public/locales/en/common.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"common": {
"title": "Job Board"
},
"login": {
"sign_up": "Sign Up"
},
"landing": {
"looking_for_talent": "Looking for Web3 talent?",
"looking_for_work": "Looking for Web3 work?",
"search_devs": "Search Devs",
"search_jobs": "Search Jobs",
"post_job": "Post Job",
"post_gig": "Post Gig",
"search_gig": "Search Gig"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the s from the original string

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah should be "search_gigs": "Search Gigs" instead of it being singular since we'd be doing a text full search

}
}
63 changes: 61 additions & 2 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
dependencies:
regenerator-runtime "^0.13.4"

"@babel/runtime@^7.0.0", "@babel/runtime@^7.10.2", "@babel/runtime@^7.12.13", "@babel/runtime@^7.13.10", "@babel/runtime@^7.16.3", "@babel/runtime@^7.7.2":
"@babel/runtime@^7.0.0", "@babel/runtime@^7.10.2", "@babel/runtime@^7.12.0", "@babel/runtime@^7.12.13", "@babel/runtime@^7.13.10", "@babel/runtime@^7.13.17", "@babel/runtime@^7.14.5", "@babel/runtime@^7.16.3", "@babel/runtime@^7.7.2":
version "7.16.3"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.16.3.tgz#b86f0db02a04187a3c17caa77de69840165d42d5"
integrity sha512-WBwekcqacdY2e9AF/Q7WLFUWmdJGJTkbjqTjoMDgXkVZ3ZRUvOPsLb5KdwISoQVsbP+DQzVZW4Zhci0DvpbNTQ==
Expand Down Expand Up @@ -1669,6 +1669,14 @@
"@supabase/realtime-js" "^1.2.1"
"@supabase/storage-js" "^1.5.0"

"@types/hoist-non-react-statics@^3.3.1":
version "3.3.1"
resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f"
integrity sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==
dependencies:
"@types/react" "*"
hoist-non-react-statics "^3.3.0"

"@types/json5@^0.0.29":
version "0.0.29"
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
Expand Down Expand Up @@ -2340,6 +2348,11 @@ core-js-pure@^3.19.0:
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.19.1.tgz#edffc1fc7634000a55ba05e95b3f0fe9587a5aa4"
integrity sha512-Q0Knr8Es84vtv62ei6/6jXH/7izKmOrtrxH9WJTHLCMAVeU+8TF8z8Nr08CsH4Ot0oJKzBzJJL9SJBYIv7WlfQ==

core-js@^3:
version "3.19.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.19.1.tgz#f6f173cae23e73a7d88fa23b6e9da329276c6641"
integrity sha512-Tnc7E9iKd/b/ff7GFbhwPVzJzPztGrChB8X8GLqoYGdEOG8IpLnK1xPyo3ZoO3HsK6TodJS58VGPOxA+hLHQMg==

cosmiconfig@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-6.0.0.tgz#da4fee853c52f6b1e6935f41c1a2fc50bd4a9982"
Expand Down Expand Up @@ -3277,13 +3290,21 @@ hmac-drbg@^1.0.1:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.1"

hoist-non-react-statics@^3.3.1:
hoist-non-react-statics@^3.2.0, hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.1:

version "3.3.2"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
dependencies:
react-is "^16.7.0"

html-parse-stringify@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz#dfc1017347ce9f77c8141a507f233040c59c55d2"
integrity sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg==
dependencies:
void-elements "3.1.0"

http-errors@1.7.3:
version "1.7.3"
resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.3.tgz#6c619e4f9c60308c38519498c14fbb10aacebb06"
Expand All @@ -3300,6 +3321,18 @@ https-browserify@1.0.0:
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=

i18next-fs-backend@^1.0.7:
version "1.1.4"
resolved "https://registry.yarnpkg.com/i18next-fs-backend/-/i18next-fs-backend-1.1.4.tgz#d0e9b9ed2fa7a0f11002d82b9fa69c3c3d6482da"
integrity sha512-/MfAGMP0jHonV966uFf9PkWWuDjPYLIcsipnSO3NxpNtAgRUKLTwvm85fEmsF6hGeu0zbZiCQ3W74jwO6K9uXA==

i18next@^21.5.3:
version "21.5.3"
resolved "https://registry.yarnpkg.com/i18next/-/i18next-21.5.3.tgz#b2d4fd24bef7ea4ec4eba2ed3cadc0c28c0e3b4c"
integrity sha512-9R8127a0/N5okiD7eeo6XBPQsHgHsLr1GdQEa35Pcw305ArC9KZDLs9kbgdn3xuVUNYlVu8+gWzz73eVkna0gA==
dependencies:
"@babel/runtime" "^7.12.0"

iconv-lite@0.4.24:
version "0.4.24"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b"
Expand Down Expand Up @@ -3785,6 +3818,19 @@ neo-async@^2.6.1:
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f"
integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==

next-i18next@^9.2.0:
version "9.2.0"
resolved "https://registry.yarnpkg.com/next-i18next/-/next-i18next-9.2.0.tgz#00d9c1f817648b492e017e0b956cd2b818f0c0d2"
integrity sha512-cWhrgxYz9IZZQ81Vc4NgogaKSANN827qHRkyVuoscOerJBHNMr7t3vO1szj/M1qnyE7yIV0NHczCS4VyqWbQAg==
dependencies:
"@babel/runtime" "^7.13.17"
"@types/hoist-non-react-statics" "^3.3.1"
core-js "^3"
hoist-non-react-statics "^3.2.0"
i18next "^21.5.3"
i18next-fs-backend "^1.0.7"
react-i18next "^11.8.13"

next-tick@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c"
Expand Down Expand Up @@ -4271,6 +4317,14 @@ react-focus-lock@2.5.2:
use-callback-ref "^1.2.5"
use-sidecar "^1.0.5"

react-i18next@^11.8.13:
version "11.14.3"
resolved "https://registry.yarnpkg.com/react-i18next/-/react-i18next-11.14.3.tgz#b44b5c4d1aadac5211be011827a2830be60f2522"
integrity sha512-Hf2aanbKgYxPjG8ZdKr+PBz9sY6sxXuZWizxCYyJD2YzvJ0W9JTQcddVEjDaKyBoCyd3+5HTerdhc9ehFugc6g==
dependencies:
"@babel/runtime" "^7.14.5"
html-parse-stringify "^3.0.1"

react-is@17.0.2:
version "17.0.2"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
Expand Down Expand Up @@ -4926,6 +4980,11 @@ vm-browserify@1.1.2:
resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0"
integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==

void-elements@3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-3.1.0.tgz#614f7fbf8d801f0bb5f0661f5b2f5785750e4f09"
integrity sha1-YU9/v42AHwu18GYfWy9XhXUOTwk=

warning@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/warning/-/warning-4.0.3.tgz#16e9e077eb8a86d6af7d64aa1e05fd85b4678ca3"
Expand Down
Loading