File tree Expand file tree Collapse file tree 3 files changed +24
-15
lines changed
Expand file tree Collapse file tree 3 files changed +24
-15
lines changed Original file line number Diff line number Diff line change @@ -3,12 +3,9 @@ import { initReactI18next } from 'react-i18next';
33import en from './locales/en.json' ;
44import nl from './locales/nl.json' ;
55
6- import LanguageDetector from 'i18next-browser-languagedetector' ;
7-
86i18n
9- // detect user language
10- // learn more: https://github.com/i18next/i18next-browser-languageDetector
11- . use ( LanguageDetector )
7+ // currently not using the language detector, since we are using url params.
8+ //.use(LanguageDetector)
129 // pass the i18n instance to react-i18next.
1310 . use ( initReactI18next )
1411 // init i18next
Original file line number Diff line number Diff line change @@ -52,15 +52,17 @@ export default function BiasDetection() {
5252 fileName : '' ,
5353 demo : false ,
5454 } ) ;
55- const { t } = useTranslation ( ) ;
56- // Select the content to print
55+ const { t, i18n } = useTranslation ( ) ;
5756
5857 const contentRef = useRef < HTMLDivElement | null > ( null ) ;
5958 const reactToPrintFn = useReactToPrint ( {
6059 contentRef : contentRef ,
6160 pageStyle : PAGE_STYLE ,
6261 } ) ;
6362
63+ const params = new URLSearchParams ( window . location . search ) ;
64+ const lang = params . get ( 'lang' ) ;
65+
6466 const {
6567 loading,
6668 initialised,
@@ -89,11 +91,12 @@ export default function BiasDetection() {
8991 } ;
9092
9193 useEffect ( ( ) => {
92- console . log (
93- 'document.referrer and is nl' ,
94- document . referrer ,
95- document . referrer ?. includes ( '/nl/' )
96- ) ;
94+ if ( lang ) {
95+ i18n . changeLanguage ( lang ) ;
96+ }
97+ } , [ i18n ] ) ;
98+
99+ useEffect ( ( ) => {
97100 if ( pythonCode ) {
98101 initialise ( { code : pythonCode , data : '' } ) ;
99102 }
@@ -135,7 +138,7 @@ export default function BiasDetection() {
135138
136139 return (
137140 < main ref = { contentRef } className = "gap-4 p-4 flex flex-col" >
138- < LanguageSwitcher />
141+ { ! lang && < LanguageSwitcher /> }
139142 < div className = "relative flex-1 flex-col items-start" >
140143 < BiasSettings
141144 onRun = { onRun }
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ export default function SyntheticDataGeneration() {
5252 contentRef : contentRef ,
5353 pageStyle : PAGE_STYLE ,
5454 } ) ;
55- const { t } = useTranslation ( ) ;
55+ const { t, i18n } = useTranslation ( ) ;
5656 const {
5757 loading,
5858 initialised,
@@ -66,6 +66,9 @@ export default function SyntheticDataGeneration() {
6666 isDemo : false ,
6767 } ) ;
6868
69+ const params = new URLSearchParams ( window . location . search ) ;
70+ const lang = params . get ( 'lang' ) ;
71+
6972 const onFileLoad : csvReader [ 'onChange' ] = (
7073 data ,
7174 stringified ,
@@ -75,6 +78,12 @@ export default function SyntheticDataGeneration() {
7578 setData ( { data, stringified, fileName, demo } ) ;
7679 } ;
7780
81+ useEffect ( ( ) => {
82+ if ( lang ) {
83+ i18n . changeLanguage ( lang ) ;
84+ }
85+ } , [ i18n ] ) ;
86+
7887 useEffect ( ( ) => {
7988 if ( pythonCode ) {
8089 initialise ( { code : pythonCode , data : '' } ) ;
@@ -106,7 +115,7 @@ export default function SyntheticDataGeneration() {
106115
107116 return (
108117 < main ref = { contentRef } className = "gap-4 p-4 flex flex-col" >
109- < LanguageSwitcher />
118+ { ! lang && < LanguageSwitcher /> }
110119 < div className = "relative flex-1 flex-col items-start" >
111120 < SyntheticDataSettings
112121 onRun = { onRun }
You can’t perform that action at this time.
0 commit comments