Closed jfrcom closed 4 years ago
If the result is translated it will be displayed in the same language as the questions. It will use english as default. The module responsible for results is b5-result-text so feel free to translate if anything is missing. If you want to override the selected language this is the line you'll have to change https://github.com/Alheimsins/bigfive-web/blob/master/pages/showResult.js#L25
Is it possible to display the results in another language that questions were?
Edit: I just found out the possibility to change the lang in the database. But is there another possibility without creating new document and ID?
Edit 2: Where to change in the result page where it should redirect. When I change line 27 to another page (I duplicated showresult
file and made one with en and the another one with de but I always get the showresult file. It doesnt matter if there is Router.pushRoute('shworesultde', { id })
or Router.pushRoute('shworesult', { id })
. I always get redirected to the showresult
file.
So this is what happens when you load a result:
This means that result does not care about the original language. It shows whatever you sends it. In this version we only shows the language selector on the test page and use chosen language for the results. But you do not have to do it that way. You can have a selector on the showResults page or you can hard code another language id if that is what you prefer. Here's an example of a result page with language selector
This is from another implementation I did for a pure static version b5-web but mechanics are the same.
You redirect to showresult in pages/result https://github.com/Alheimsins/bigfive-web/blob/master/pages/result.js#L27 if you want to load a result and from pages/test https://github.com/Alheimsins/bigfive-web/blob/master/pages/test.js#L126 if you just have taken a test
If you always want to show results in German you can override this line https://github.com/Alheimsins/bigfive-web/blob/master/pages/showResult.js#L25 with something like
return getResult({ scores, lang: 'de' })
Happy Hacking :-)
Thanks a lot for your answer! Where is the code for the language selector?
For the test site pages/test.js
The component is here https://github.com/Alheimsins/bigfive-web/blob/master/components/LanguageBar.js
ahhh
methods are required here https://github.com/zrrrzzt/b5-web/blob/master/pages/result.js#L9 and here here's the translate function https://github.com/zrrrzzt/b5-web/blob/master/pages/result.js#L127 and this is where the language bar is rendered https://github.com/zrrrzzt/b5-web/blob/master/pages/result.js#L142
I tried to implement this to the showresult.js
page but I still get an error. I replaced in this function translateResume (e) { e.preventDefault() const language = e.target.dataset.language const scores = this.state.scores const resume = getResult({ scores: scores, lang: language }) this.setState({ resume: resume, viewLanguage: language }) }
the line this.state.scores
with calculateScore
but when I try to change the language I get this error
TypeError: Cannot read property 'setState' of undefined
I would really appreciate if you could help me!
b5-web
and bigfive-web
are two different solutions for doing simple big five testing. Even though they are using the same modules they are not necessarily compatible enough to do copy-paste between them.
Do you have a repo for your version? I can take a look but no guarantees.
You can of course add "language selector for result page" to the feature request document https://github.com/Alheimsins/bigfive-web/issues/95
I would like to know how to change the results language. Can I decide in which language the results will be displayed?