Skip to content

Commit

Permalink
Translate the top keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
ZaneH committed Jul 24, 2022
1 parent 44afbac commit 86a8a47
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 51 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
"@types/node": "^16.11.43",
"@types/react": "^18.0.14",
"@types/react-dom": "^18.0.5",
"i18next": "^21.8.14",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^11.18.1",
"react-piano": "^3.1.3",
"react-scripts": "5.0.1",
"react-select": "^5.4.0",
Expand Down Expand Up @@ -50,7 +52,7 @@
]
},
"devDependencies": {
"@tauri-apps/cli": "^1.0.4",
"@tauri-apps/cli": "1.0.5",
"@types/prettier": "^2.6.3",
"@types/styled-components": "^5.1.25",
"@types/testing-library__jest-dom": "^5.14.5",
Expand Down
1 change: 1 addition & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ScreenManager from './components/ScreenManager/ScreenManager'
import SidebarProvider from './components/SidebarProvider/SidebarProvider'
import { TrainerDisplay, TrainerPiano } from './components/Trainer'
import TrainerProvider from './components/TrainerProvider'
import './i18n/config'

const PracticeScreenLayout = styled.div`
display: flex;
Expand Down
8 changes: 7 additions & 1 deletion src/components/Trainer/TrainerPiano.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useCallback, useContext } from 'react'
import { useTranslation } from 'react-i18next'
import { Keyboard, MidiNumbers } from 'react-piano'
import styled from 'styled-components'
import {
Expand Down Expand Up @@ -36,6 +37,7 @@ const TrainerPiano = () => {
noteTracker,
practiceMode,
} = useContext(TrainerContext)
const { t } = useTranslation()

const getActiveNotes = useCallback(
(nextNote?: number) => {
Expand Down Expand Up @@ -123,7 +125,11 @@ const TrainerPiano = () => {
if (modKeyIdx > -1) {
return (
<InKeyMarker>
{Object.values(modScale[modKeyIdx] || {})?.[0]}
{t(
`piano.numeral.${
Object.values(modScale[modKeyIdx] || {})?.[0]
}`
)}
</InKeyMarker>
)
}
Expand Down
14 changes: 14 additions & 0 deletions src/i18n/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import i18n from 'i18next'
import translation from './en/translation.json'
import { initReactI18next } from 'react-i18next'

export const resources = {
en: {
translation,
},
} as const

i18n.use(initReactI18next).init({
lng: 'en',
resources,
})
45 changes: 45 additions & 0 deletions src/i18n/en/translation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"piano": {
"note": {
"Cb": "Cb",
"C": "C",
"C#": "C#",
"Db": "Db",
"D": "D",
"D#": "D#",
"Eb": "Eb",
"E": "E",
"E#": "E#",
"Fb": "Fb",
"F": "F",
"F#": "F#",
"Gb": "Gb",
"G": "G",
"G#": "G#",
"Ab": "Ab",
"A": "A",
"A#": "A#",
"Bb": "Bb",
"B": "B",
"B#": "B#"
},
"numeral": {
"i": "i",
"I": "I",
"ii": "ii",
"iiº": "iiº",
"II": "II",
"iii": "iii",
"III": "III",
"iv": "iv",
"IV": "IV",
"v": "v",
"V": "V",
"vi": "vi",
"viº": "viº",
"VI": "VI",
"viiº": "viiº",
"VII": "VII"
}
}
}
132 changes: 83 additions & 49 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,13 @@
dependencies:
regenerator-runtime "^0.13.4"

"@babel/runtime@^7.14.5", "@babel/runtime@^7.17.2":
version "7.18.9"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.18.9.tgz#b4fcfce55db3d2e5e080d2490f608a3b9f407f4a"
integrity sha512-lkqXDcvlFT5rvEjiu6+QYO+1GXrEHRo2LOtS7E4GtX5ESIZOgepqsZBVIj6Pv+a6zqsya9VCgiK1KAK4BvJDAw==
dependencies:
regenerator-runtime "^0.13.4"

"@babel/template@^7.18.6", "@babel/template@^7.3.3":
version "7.18.6"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.18.6.tgz#1283f4993e00b929d6e2d3c72fdc9168a2977a31"
Expand Down Expand Up @@ -1789,65 +1796,65 @@
dependencies:
type-fest "2.13.1"

"@tauri-apps/cli-darwin-arm64@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.0.4.tgz#fd63fad851c8c899233618af0a9dc2d1a29a8c41"
integrity sha512-hMVTPoinjKYV8fgviQ871ZnVipAVXJV3ZwfiK9FcE9/dkUCUtKtetfwnicRV6YDSFbWY9qAg+Sm0INrLT5Ky+A==
"@tauri-apps/cli-darwin-arm64@1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.0.5.tgz#6fd17a8d9e0e7982b5c9887639407fdec783a744"
integrity sha512-oxpFb9ZeMiC3xPUJ9NsXWCnnwFSVkPbJUvDKpc9IaoDIUpsMTV72W4P0Nh0uQRbyhx4modPpstt7+ONypNVYNg==

"@tauri-apps/cli-darwin-x64@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.0.4.tgz#52e7a4151a26e9333375a82a0cb15614f01cf3e0"
integrity sha512-6bR8WIqJdcutLLcmv4S+bkCRbLAwjl80zPL97vs7Zgum01aeygjUTaZS46fpeDgqF8nR8piFAZkz8Bnco6fbzw==
"@tauri-apps/cli-darwin-x64@1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.0.5.tgz#6aaaadd68739c4c4f86546f3d17b2fb60a5a0c04"
integrity sha512-hRNYC6L9edz2dEqK33tssPylF2ti6x6udidBlGWc5GSoeEb/05qKMEA1MESQYKBG+4q+wjJvACA2vvz6AfgJ3Q==

"@tauri-apps/cli-linux-arm-gnueabihf@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.0.4.tgz#8889ce864dba0763290fa3f05af99f8cd2f574bf"
integrity sha512-NNhz8Nh/CQvAPzR5bj1sC2CgpkUOjZg8Eg1i/Ta/pbrjgT0E/reD+12TGdkNuQNEOUQ1klWcdeHfAptWPicRgQ==
"@tauri-apps/cli-linux-arm-gnueabihf@1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.0.5.tgz#d2d01c8b85ee3771656386bfda3852af8ed811da"
integrity sha512-hc/Jp3TtFpxB8XVkLEwWy7MNcUBlS8rNCafQBUt4KSElXB+/oGo50jPO+wd5GSMSOR59UCzH08v11P0b+sAa/w==

"@tauri-apps/cli-linux-arm64-gnu@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.0.4.tgz#27ae14f15d5fef76dcb70b4d7dac7bbb9e13ea81"
integrity sha512-chzpMgkZyu0MWF75DDiEV06XyI8LM7q0NMxRx7esJwZpypj4AG0Pj4+9Di38zYWZrfYqz/bWrCMPIV30vty1Gg==
"@tauri-apps/cli-linux-arm64-gnu@1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.0.5.tgz#7ca848120c2e90b57188aaa9daee11cf29e2e2f4"
integrity sha512-btFlkD2PG+yzJBZzWeJmyCy8ZV+iys2Jl66Fs4g9lSi3KrBDnyfQ26RpGZb2pRfkkcVP8/x1WSfByO+Rj+PTBA==

"@tauri-apps/cli-linux-arm64-musl@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.0.4.tgz#118a44226c3e0c324b9c842718548b22fcfbd3d2"
integrity sha512-w+wbNoIOdHoV65Q/z29EK4KtFiNXfV+2lIsML/Hw0VEJEzl9FsqGelu1zAycq8hkoQhf0yPlD/m4FfAWnFzg6Q==
"@tauri-apps/cli-linux-arm64-musl@1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.0.5.tgz#5ba65790849e0737f560f3ccd12f7a2a88c25b23"
integrity sha512-p5JFdWab2AWhfgAZW/mgOLu+YiIJXKV0NdATGmdiBgQCMmz1k/FM8iOFApCgGbo3/zkR58cJ7Z7hyWmQ07M6Pw==

"@tauri-apps/cli-linux-x64-gnu@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.0.4.tgz#1724345de55a597a7fbd363f3af33ebf4eaaad4d"
integrity sha512-TiVRk+VBYA2mE4DqwLu/WD6wTHewHVbdMUtfeXdwe/kabLqbJTWuswUv5T8JUp3mYFZKqlPhyi+qWSJOc0Ianw==
"@tauri-apps/cli-linux-x64-gnu@1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.0.5.tgz#d06430c608316cb5a29ec805d4c5d078a293c3ae"
integrity sha512-fOXR635AXxwSO7MCfBhMLnGpcg1H83XGw9ocuyg4jjvtE8QoYPwC4ksfb5lLhDVMui9iIKY93NAK3EkQiSGGmQ==

"@tauri-apps/cli-linux-x64-musl@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.0.4.tgz#b36904c42be4bdab21cefdd052c8c85f9913f6be"
integrity sha512-TKdncZ6aFu9PfHakrrqg3XIoxgl510rN0tOTJuZ1WQT2nDD5zlP3Mo++FNIt6/TfjqayLcubIZp3dG9pU383dA==
"@tauri-apps/cli-linux-x64-musl@1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.0.5.tgz#813c90531f4001453e73b3ad2d4c75929412a249"
integrity sha512-8be4zJVkuMs427JqONhFx5Ia5zWsQ5tbZXd80C3dHNL+5/3VIOK6nGQ0iijyZSLXiE9JKEH2jp1EHB+1TVJRcw==

"@tauri-apps/cli-win32-ia32-msvc@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.0.4.tgz#6db7d26050f15fca0ad067119001e566085990f5"
integrity sha512-KedA4LB/PsePE3BLm2gg/IIA4rLjbyBUzV2FTdpWqx8ws3OzL6BLDGRVJ+zXe/b9SddhhZk7Rqss6y+gtsWKsA==
"@tauri-apps/cli-win32-ia32-msvc@1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.0.5.tgz#a3eb6f56c3f4ba35f6311e1fb31bd30e6892b316"
integrity sha512-WpnIfzS1e4InGhvd1IDSKC3w6kbI5c6oJgMmtkMTBlhjhiZXhZmQF4XA784A5Y13pzsbXnbNJKOp8DuPVkoTRQ==

"@tauri-apps/cli-win32-x64-msvc@1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.0.4.tgz#bf14bb0cfa2c0e74a981c6424dc36f68dbfd4b5c"
integrity sha512-6m1Ie7+YeKdOY7aXZCw/Py30DeMEAukE2+WWuZgfxZTTG9QrnZO+DbaKtjuEG0A8HKHCz63+ZNxOTshS1ognEw==
"@tauri-apps/cli-win32-x64-msvc@1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.0.5.tgz#f1e0860166e8f86b550e35aaf22ef95d6da5a7c8"
integrity sha512-8iEhVD3X4LZfrlxEPOV+mAj4QrJrEqKTICiJnwmgjvhYQOOsNHzg5kca7pcBbqcgorQOBydLpfGJtxWRusVPaw==

"@tauri-apps/cli@^1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli/-/cli-1.0.4.tgz#4a943d10ff022ae6ad9fb33e94cc5c25509bcfb9"
integrity sha512-AqfbQUFU2jDYmkjiowl+Yv1yNkey/e+N23sKyDtXQQNvxE6ieR4voY4i6bShY97F+DbRVdjWcjGiLkWS3i4DHw==
"@tauri-apps/cli@1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli/-/cli-1.0.5.tgz#a15a61e8467be29277b72707c4189c58c33d94bf"
integrity sha512-vbY+MwK+xN65x0R/o16UQPxBtJl8pmzVzC0TZKokZfmeOkomoqOEOinSwznAMeyR1ZMJW+fXVgJCPvGsRQ0LGg==
optionalDependencies:
"@tauri-apps/cli-darwin-arm64" "1.0.4"
"@tauri-apps/cli-darwin-x64" "1.0.4"
"@tauri-apps/cli-linux-arm-gnueabihf" "1.0.4"
"@tauri-apps/cli-linux-arm64-gnu" "1.0.4"
"@tauri-apps/cli-linux-arm64-musl" "1.0.4"
"@tauri-apps/cli-linux-x64-gnu" "1.0.4"
"@tauri-apps/cli-linux-x64-musl" "1.0.4"
"@tauri-apps/cli-win32-ia32-msvc" "1.0.4"
"@tauri-apps/cli-win32-x64-msvc" "1.0.4"
"@tauri-apps/cli-darwin-arm64" "1.0.5"
"@tauri-apps/cli-darwin-x64" "1.0.5"
"@tauri-apps/cli-linux-arm-gnueabihf" "1.0.5"
"@tauri-apps/cli-linux-arm64-gnu" "1.0.5"
"@tauri-apps/cli-linux-arm64-musl" "1.0.5"
"@tauri-apps/cli-linux-x64-gnu" "1.0.5"
"@tauri-apps/cli-linux-x64-musl" "1.0.5"
"@tauri-apps/cli-win32-ia32-msvc" "1.0.5"
"@tauri-apps/cli-win32-x64-msvc" "1.0.5"

"@testing-library/dom@^8.5.0":
version "8.14.0"
Expand Down Expand Up @@ -5079,6 +5086,13 @@ html-minifier-terser@^6.0.2:
relateurl "^0.2.7"
terser "^5.10.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"

html-webpack-plugin@^5.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/html-webpack-plugin/-/html-webpack-plugin-5.5.0.tgz#c3911936f57681c1f9f4d8b68c158cd9dfe52f50"
Expand Down Expand Up @@ -5188,6 +5202,13 @@ husky@^8.0.0:
resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.1.tgz#511cb3e57de3e3190514ae49ed50f6bc3f50b3e9"
integrity sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==

i18next@^21.8.14:
version "21.8.14"
resolved "https://registry.yarnpkg.com/i18next/-/i18next-21.8.14.tgz#03a3a669ef4520aadd9d152c80596f600e287c6a"
integrity sha512-4Yi+DtexvMm/Yw3Q9fllzY12SgLk+Mcmar+rCAccsOPul/2UmnBzoHbTGn/L48IPkFcmrNaH7xTLboBWIbH6pw==
dependencies:
"@babel/runtime" "^7.17.2"

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 @@ -7805,6 +7826,14 @@ react-error-overlay@^6.0.11:
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.11.tgz#92835de5841c5cf08ba00ddd2d677b6d17ff9adb"
integrity sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==

react-i18next@^11.18.1:
version "11.18.1"
resolved "https://registry.yarnpkg.com/react-i18next/-/react-i18next-11.18.1.tgz#ba86ed09069e129b8623a28f2b9a03d7f105ea6f"
integrity sha512-S8cl4mvIOSA7OQCE5jNy2yhv705Vwi+7PinpqKIYcBmX/trJtHKqrf6CL67WJSA8crr2JU+oxE9jn9DQIrQezg==
dependencies:
"@babel/runtime" "^7.14.5"
html-parse-stringify "^3.0.1"

react-is@^16.13.1, react-is@^16.7.0:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
Expand Down Expand Up @@ -9229,6 +9258,11 @@ vary@~1.1.2:
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==

void-elements@3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-3.1.0.tgz#614f7fbf8d801f0bb5f0661f5b2f5785750e4f09"
integrity sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==

w3c-hr-time@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz#0a89cdf5cc15822df9c360543676963e0cc308cd"
Expand Down

0 comments on commit 86a8a47

Please sign in to comment.