diff --git a/web/src/App.js b/web/src/App.js index ec5468a..5c1e2bf 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -19,105 +19,135 @@ import UserStatus from "./component/UserStatus"; import ReviewPage from "./component/ReviewPage"; import UserProfile from "./component/UserProfile"; import FeedbackPage from "./component/FeedbackPage"; -import { useState } from "react"; +import { useEffect, useState } from "react"; +import { Tr, langCodeContext, LANG_OPTIONS } from "./translate"; function App() { const [playingFile, setPlayingFile] = useState({}); const [user, setUser] = useState({}); + const [langCode, setLangCode] = useState("en_US"); + + // select language + useEffect(() => { + const browserCode = window.navigator.language; + for (const key in LANG_OPTIONS) { + for (const i in LANG_OPTIONS[key].matches) { + const code = LANG_OPTIONS[key].matches[i]; + if (code === browserCode) { + setLangCode(key); + return; + } + } + } + // fallback to english + setLangCode('en-US'); + }, []); + return (
- -
-

- logo - MSW Open Music Project - -

- -
-
- - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } /> - } /> - } - /> - } - /> - } - /> - } - /> - } - /> - - } - /> - -
- -
+ + +
+

+ logo + MSW Open Music Project + +

+ +
+
+ + } + /> + } + /> + } + /> + } + /> + + } + /> + } + /> + } + /> + } + /> + } /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + + } + /> + +
+ +
+
); } diff --git a/web/src/component/AudioPlayer.js b/web/src/component/AudioPlayer.js index 8397ab4..6f10126 100644 --- a/web/src/component/AudioPlayer.js +++ b/web/src/component/AudioPlayer.js @@ -3,6 +3,7 @@ import { useNavigate } from "react-router"; import { CalcReadableFilesizeDetail } from "./Common"; import FfmpegConfig from "./FfmpegConfig"; import FileDialog from "./FileDialog"; +import { Tr } from "../translate"; function AudioPlayer(props) { // props.playingFile @@ -67,7 +68,7 @@ function AudioPlayer(props) { return (