dgkf / R

An experimental reimagining of R
https://dgkf.github.io/R
GNU General Public License v3.0
135 stars 5 forks source link

Keyword localization #55

Open dgkf opened 1 year ago

dgkf commented 1 year ago

I'll preface this by saying I'm a native english speaker and have never lived through the experience of trying to program in a language that assumes anything but english fluency. I'm certainly not the right person to plan such a feature, but I want to float the idea in case any non-native english speakers want to weigh in on opportunities for improvement on english-first languages and how they might be addressed.

The history of localized languages seems to indicate that there is at least some interest for this, and I'm very interested in experiments for a more native implementation. I'd like to explore translations early so that they're a central feature of the language.

Although I think it's important that there is an assumed language for the portability of code, there could certainly be a way to opt-in to swap out the grammar's keywords and condition message translations. The idea is that a language might have alternative language modes (r --lang=es) that would allow for localized keywords:

#! usr/bin/env r        # #! usr/bin/env r --lang=es
f <- function(...) {    # f <- funcion(...) {
  if (TRUE) {           #   si (CIERTO) {
  } else {              #   } sino {
  }                     #   }
}                       # }

(apologies to any spanish speakers if this isn't a sensible translation!)

dgkf commented 7 months ago

Not sure if you saw this @sebffischer, but if you speak any non-english languages I'd love to grow the pool of localizations we have available.

If you want to submit any other localizations, the hard part is just filling in files like these: https://github.com/dgkf/R/blob/main/src/grammar/localizations/en.pest (english)

You can probably figure out the rest, but if you want to leave it just at that file, then I don't mind hooking up the other pieces to make it work.

You can check out other localizations in the web demo, such as spanish

sebffischer commented 7 months ago

Thanks for making me aware! I can take care of German when I have the time :)