I am trying to translate the FOLIO User Interface (just translate the “Welcome, the Future Of Libraries Is OPEN!” and so on) as a test, but I am having trouble to find the right files to do so.
If I understood right from this https://github.com/folio-org/stripes-core/blob/master/doc/dev-guide.md, I should create a file with the two letter country code similar with en.json with the translation to Portuguese in the directory /etc/folio/stripes/node_modules/@folio/stripes-core/translations.
But what do I need to do to make Stripes use my file instead of en.json?
I am using the folio/stable vagrant box.
No. Stripes uses the language file based on the organization’s locale. You have to set the language to Portuguese in Settings -> Organization.
Use SafeHTMLMessage component in your code and that’s all:
import SafeHTMLMessage from ‘@folio/react-intl-safe-html’;
- Create JSON file in stripes-core/translations; maybe pt-br.json or pt_br.json, or maybe pt.json
- Add some keys to the file. It should fallback to English for missing keys.
- If using the dev server, start it
- Change locales like Istvan said (Settings -> Organization)
I haven’t tested it myself.
SafeHTMLMessage is not relevant here, since Camila did not mention the need to translate any HTML strings.
Hello, thank you all for your answer.
I am new to node.js and FOLIO, so I am still having trouble. Numbers 1,2 and 4 are fine, but what do you mean with number 3?
Should I install and start stripes using yarn? I am using the folio/stable vagrant box, when I try the command yarn start I get the following error:
Developers run the UI code from source with a dev server-- I’m not sure if you’re trying to do that. That error says there is already a server using 127.0.0.1:3000; if you go there, do you get the UI?
doc for running Stripes (the UI) from source:
I am not trying to do that.
If I go to 127.0.0.1:3000 I get the UI, but I don’t see any modifications about the translations I made.
As a test, I modified everything in the en.json file in /etc/folio/stripes/node_modules/@folio/stripes-core/translations to portuguese (I know that it is not the correct way was just a test, I will create a file pt-BR.json soon) but I don’t see the modifications that I made. Everything continues in English.
Should the modifications appear automatically? Do I have to do anything to make my modifications available?
I’m guessing that the server running at port 3000 is the dev server then. You need to restart it to pick up the new translations.
How to identify the process ID (PID) of the program listening at port 3000:
netstat -vanp tcp | grep 3000
sudo lsof -i tcp:3000
Maybe those commands don’t work for you- google if that’s the case.
Once you have the PID, you can identify it like this:
ps -aef | grep 38624
where 38624 is the PID. Yours will be different. Example:
→ ps -aef | grep 38624
1746259638 38851 13234 0 3:26PM ttys002 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn 38624
1746259638 38624 38623 0 3:22PM ttys004 0:25.10 node /Users/rr214/Code/stripes/stripes-sample-platform/node_modules/.bin/stripescore dev stripes.config.js
So I could
kill -9 38624, then run
node /Users/rr214/Code/stripes/stripes-sample-platform/node_modules/.bin/stripescore dev stripes.config.js to start it again.
Well, something strange is going on.
When I try sudo lsof -i tcp:3000, the result is:
*docker-pr 959 root 4u IPv6 12584 0t0 TCP :3000 (LISTEN)
Which is the vagrant process. If I try ps -aef | grep 959, I get
root 959 440 0 19:53 ? 00:00:00 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 3000 -container-ip 172.18.0.2 -container-port 80
vagrant 2153 1764 0 19:55 pts/0 00:00:00 grep 959
But if I go to localhost:3000 is still showing UI. I am trying all this commands inside the folio/stable (connected using vagrant ssh). Or should I do it from my machine?
docker ps to get the list of running containers. Use
docker restart on one to reload the server its running. If you get an error,
sudo may be necessary. Restarting the container will only help if the container is using the files you changed, like if the container has mounted /etc/folio/stripes. I suppose you could confirm that by checking
docker history for the image.
I’ll post on the Slack #development channel, as I’m sure someone can advise better.
Thank you. I tried the docker restart on the one related to stripes, but my modifications didn’t show on the UI.
I modified only the files in /etc/folio/stripes/node_modules/@folio/stripes-core/translations. Do I have to anything else besides everything we already discussed?
I suspect /etc/folio/stripes is not mounted in the container then.
I recommend deleting the folio/stable box. It’s very old. Instead install folio/testing-backend, and run from stripes source code against it, using the doc I linked to earlier.