sonic-pi-net / sonic-pi

Code. Music. Live.
https://sonic-pi.net
Other
10.82k stars 922 forks source link

Translation of error messages #792

Closed stefan-hoehn closed 8 years ago

stefan-hoehn commented 8 years ago

When I use sonic pi in a german environment, the whole GUI is translated to german which is great. It is fine that the coding the language of PI is not translated. However, could we make it possible that error message would be completely in german, ie.

Syntax Error: [Arbeitsbereich 3, line 4] syntax error, unexpected $end, expecting keyword_end [Line 4]:

would become

Syntax Error: [Arbeitsbereich 3, line 4] syntax error, unerwartes $end, erwartet keyword_end [Line 4]:

cheers Stefan

stefan-hoehn commented 8 years ago

btw, I am happy do it If I knew how :-)

samaaron commented 8 years ago

Unfortunately this error comes deep from the system and we currently have no way to offer translations for internals like this.

However, if someone wanted to work on a system that offered the ability to translate messages like this - then I'd be happy to consider pull-requests.

stefan-hoehn commented 8 years ago

Funny enough, some parts are already in German like "Arbeitsbereich", which is why I though there might already something in it...

samaaron commented 8 years ago

I'm sure it's possible - it's just not something high on my priority list at this stage. As I said, if someone wants to pick this up and work on it, that would be wonderful :-)

stefan-hoehn commented 8 years ago

If you leave out a number at the play command it even results into a "syntax error, unexpected tIDENTIFIER, expecting ')". It seems this even comesfrom actually a message that is produced within ruby...

I researched the code a bit and I found the line 104 in oschandler.cpp which, if I am not mistaken, constructs the error line. At this point we could actually find/replace text in the error_line string.

However we needed to know the required locale (ie. german) at this point. Not sure how. Maybe we could also do the same in the method that calls OscHandler::oscMessage, which is in the SonicPiUDPServer and SonicPiTCPServer but oscMessage is probably more central.

Btw, this approach, even though it looks a bit dirty, actually provides the chance to brush up "ugly" ruby message by replacing particular known "technical" ones into "understandable" messages for humans...

Wouldn't it be nice if "syntax error, unexpected tIDENTIFIER, expecting ')'" would be "Syntax Error: Number missing behind command"....or "syntax error, unexpected $end, expecting keyword_end" would become "Syntax Error: Keyword 'END" is missing. Please try adding end to the block".

Of course those then could be provided in different languages.

So, the above may be a way to move forward. However I would really dig deeper into that if it is the right approach as I am not involved with the development with sonic PI and setup up the windows build environment seems to be kind of a challenge ;-)

hzulla commented 8 years ago

I doubt that this is possible. The error message are generated by the ruby interpreter (correct?) and it's be really difficult to translate all possible error messages it can report back.

stefan-hoehn commented 8 years ago

The problem is that kids that are not aware of the english language really have a challenge to interprete the errors.

Basically you are right but in most cases that happen when editing the code there is only a few that are really happening. I more or less follow a 80/20 approach. I tried it with several kids and there were actually only a few (I would <=5) error message that typically come up.

The alternative: Maybe someone has an idea how we can at least ruby tell how to use other languages/locales when providing error messages.

xavriley commented 8 years ago

Interpreting errors is always challenging for new programmers - I can appreciate it would be really hard if you were learning English at the same time :smile:

So whilst I sympathise with the idea, I did look into this briefly but I'm not sure that Ruby core has translations at all. Like you say, the only method would be find and replace on the error string and I'm not sure that's practical given the number of potential error messages. Sadly I don't think it's going to be possible.

stefan-hoehn commented 8 years ago

It is a pity indeed.Thanks anyway for giving it a try and looking into it. So let's teach our children english as well - they need to learn the sonicpi commands anyway that are in english as well (I do not in in any way propose to translate the sonic pi language! ) :)

stefan-hoehn commented 8 years ago

Let's close the ticket then. (can I do that?)

xavriley commented 8 years ago

I've recently got the ability to close tickets so I'm going to go head and do that :)

The discussion is here for others in future. If anyone reading in future has suggestions for how to make this happen then let us know!