Closed hellais closed 7 years ago
I'll do:
37 src/routes/Measurements/components/nettests/HttpHeaderFieldManipulation.js 91 src/routes/Measurements/components/nettests/HttpInvalidRequestLine.js 55 src/routes/Measurements/components/nettests/VanillaTor.js
I assume we can now close this issue, given e4607e7! 🎉
Now that we are going to add support for translations, all the templates containing strings need to be refactored so that they use the new translation system.
It's actually very easy to do, but to do it on all the template files is actually a lot of work, so if you want to help out that would be super useful!
If you want to help out with this here is what you should do:
Write in the comment to this ticket which files you are going to be editing (see list of files in this ticket)
Look inside of the file for strings that are written in english that need translation.
Check if
FormattedMessage
is being imported. If it's not add the line:This is how you would transform the following string for translation support:
The
id
needs to be unique across all the repository. I have been using so far as a naming convention the name of the parent directory.
the component name. For examplenettests/TcpConnect.js
would have id's in the formnettests.tcpConnect.someString
. Do not be afraid to add too much text in the id and add too many dots.For more complicated strings that include also parameters or styling in the text you will have to parametrise them.
Here is an example of how you do that:
Would become:
For a complete example of how this looks like see: https://github.com/TheTorProject/ooni-wui/blob/16d1f81b85484e21a1c1a29396a00ca19971a243/src/routes/Measurements/components/nettests/WebConnectivity.js (Note: I have not yet finished all the strings in there)
Here is a listing of the files that are currently in need of this:
The most high priority ones are those required by the mobile app. These would be:
To make this process less painful I have setup a Live Template in WebStorm that allows me to select the text and wrap it in the
<FormattedMessage/>
.This is the content of the Live Template:
You need to ensure that the context for it is set to JSX HTML and you can then access it by selecting the text and doing
CMD-SHIFT-J
.