Advent 2024: Day ι (Translate DrRacket interface in your language)

Hello all,
This is a short, practical guide how you can translate the interface of DrRacket in your language.
As I am currently studying Scribl - it will be added as a pull request for the documentation in string-constants.scrbl

This is how you can translate the interface of DrRacket in your language. As you know DrRacket is a GUI – editor and runner for the many languages you can use via Racket – the language developer’s language. Currently existing translations are English, Danish, French, Finnish, German, Portuguese, Russian, Ukrainian, Bulgarian, Chinese (traditional and simplified) and Japanese. Dutch, Korean and Spanish have not been updated in a long while and they still need re-licensing which makes them hidden in the interface.

There are many languages missing plus some of the existing translations need some work for updates.

If you are interested how much time and effort you will need to invest – currently it is roughly a 1400 string translation, of less than 6000 words of – it is an easy peasy deal.

Here are the steps:

Clone the GitHub - racket/string-constants repo. This is where you will work, translate and finally submit the translation via a pull request.

Go to the string-constants-lib/string-constants/private directory – it contains all the translations. Start with copying the file english-string-constants.rkt to yourlanguage-string-constants.rkt.

Basically English is the master file containing the originals of the strings. Therefore, start with a copy of that. Note that if you continue to update and maintain your translation – English will be the file you will sync with.

Once you have copied the file you will need to declare it so DrRacket knows it exists and has to be included with the rest of the translations in the official builds.

To do that just edit the file string-constants/string-constants-lib/string-constants/string-constant.rkt and add your language in two places:

(require (prefix-in english: "private/english-string-constants.rkt")
...
(prefix-in yourlanguage: "private/yourlanguage-string-constants.rkt"))

and

(define built-in-string-constant-sets
(list
(make-sc 'english english:string-constants #f)
…
(make-sc ' yourlanguage yourlanguage:string-constants #f)))

And with that you are done with the initial work – you have created a template for your language (still filled in with the English originals) and you have told Racket to use it. We are off to the races and all we need to do is fill in the translations.

Open yourlanguage-string-constants.rkt in your favorite text editor. It has a fairly trivial structure: it is basically a map – a long list of key-value pairs. The key is the identifier of the string – how Racket source code is going to refer to the message. Do not change these. Value is the translation. As you started with the English version – you have all the comments and the formatting. I highly recommend keeping these in place because they are very helpful when you need to update the translations.

The first thing you need to do is fix the line

(module english-string-constants "string-constant-lang.rkt"

– it has to become

(module yourlanguage-string-constants "string-constant-lang.rkt"

The second thing is to add some metadata to your file. You can use standard comments in the file – either prefix a line with double semicolon ;; or comment out a block of text via #| commented block |#.

In that part of the file put some basic data – like your name, which version of the private/english-string-constants.rkt file you are syncing with. This is also the place to put out conventions for the translation such as specific terms, style etc. I would also recommend spelling out the license of it. For example in the Bulgarian translation I have explicitly pointed out:

;; This file is distributed under the same terms as Racket

to ease with re-licensing. Currently translations are double licensed – under the Apache 2.0 license and the [MIT] license.

Now all you need is 3 afternoons to go over and translate the strings.

All the translated strings are quoted by double quotes. So if you need to put " in the translation you would need to quote it like \". However I recommend you use proper quotation marks for your language.

A new line is represented by \n.

~a is substituted with whatever parameter is given to the string template. And that is basically it.

You can split strings – a sequence of strings gets concatenated in a single string so:

(install-plt-error-downloading "There was an error when downloading the"
" .plt file.\n\nDetails:\n")

is the same as:

(install-plt-error-downloading "There was an error when downloading the .plt file.\n\nDetails:\n")

You can use this to wrap where you want in case strings get too long. Just make sure you do not have a dangling space at the end of a string portion. So using the current example - this is wrong:

(install-plt-error-downloading "There was an error when downloading the "
" plt file.\n\nDetails:\n")

– note how the space is at the end of the first line. This will cause breaking. There are ways around this but it is better to not need them.

Once you finish the translation – create a pull request to the GitHub - racket/string-constants repo.

If you are interested in how the whole infrastructure of translation works in DrRacket – have a look at the documentation. As usual you can generate am HTML version via executing:

scribble string-constants-doc/string-constants/string-constants.scrbl
4 Likes

And here is the pull request: Add a guide on translating the interface by alshopov · Pull Request #65 · racket/string-constants · GitHub

1 Like

Hi, @al_shopov.

Thanks so much for sharing this.

I am wondering what it would be like to translate DrRacket to Afrikaans, and it strikes me how clumsy much of the computer-related terminology sounds in the language. Just take "run" as an example. There isn't really a word in Afrikaans which has a similar set of connotations; one might conceivably use "speel" (play), or "voer" (feed) but neither feels like "run". Besides which many verbs in Afrikaans have to appear with a preposition to sound complete--e.g. "voer uit" (execute).

Were there any terms or concepts when you were translating that were particularly puzzling?

1 Like

Hi Christiaan,

Re: the translation to Afrikkans - there is an existing Dutch translation that you may have a look at - dutch-string-constants.rkt, AFAIK written Dutch and Afrikkans can be quite similar.
Still the purpose of the translation is to make things more accessible and understandable. If there is a word that gets used in this context - you can use that. Alternatively - what is the word the Afrikaans Windows Language Pack is using https://support.microsoft.com/en-us/windows/language-packs-for-windows-a5094319-a92d-18de-5b53-1cfc697cfca8 ?

Re: the clumsiness - it is largely imagined. We get bombarded by the English variants and people start preferring them as it might be easier. Basically people start treating terms as atoms - indivisible tokens with no internal meaning but what we assign to them. Doing a translation makes you think about lifting that veil - checking what the initial term actually means, how it came into being, what its connection to other terms are and trying to convey that in a different language given the severe constraints of a computer interface where you are trying to shorten things as much as possible without sacrificing understandability.

Re: puzzling concepts - I have been translating OSS for more than 20 years now and even when I started DrRacket I had a lot of experience so puzzling concepts were few. Most difficulties were of technical nature rather than conceptual.

I'd say Racket specific would be:

  • to what extent should we differentiate between "assignment" and "binding" within translation
  • to what extent should we differentiate between "expansion" and "substitution" within translation

Otherwise in Bulgarian there is the fact that both "statement" and "expression" are usually conveyed as "израз" and in a typical computer book this works but in the context of Racket and computer languages the difference is very important and must be explicit.

Kind regards:
al_shopov

На пт, 13.12.2024 г. в 19:42 Christiaan Brand via Racket Discourse <notifications@racket.discoursemail.com> написа:

2 Likes