For custom langs I imagine this would be somewhat more complicated, but for any s-exp based language certainly and for the base Racket language in particular it's certainly very possible to have "localised lisps" with locale-specific "aliases" for e.g. define
, struct
, and anything else except for the #lang line in a way that's easy to add new "locale strings" for new modules and methods to the local project and contribute them upstream.
Specifically, in a way wherein, for example, a user struct with name and email fields may either be define as normal (in the default en-US locale assumed in Racket) as (struct user (name email))
and alias it for e.g. Spanish as (localise-struct 'es-ES 'user '(name email) 'usuario '(nombre email))
or some such, or vice versa with e.g. (estructura usario (nombre email))
and localising to 'en-US
, but in a way where both user
and usario
structures return #t
interchangeably for user?
and usario?
and respond interchangeable to user-email
and usario-nombre
etc.
In particular, I'm not looking for anything to localise Racket values (like those returned by the aforementioned user-email
and usario-nombre
functions), as that's a solved problem (though, considering this, it might be good to build around one of those solutions?). Custom langs would likely require plugging into the lexer, which might be the way to go in any case?
Really I'm just trying to write lisp interchangeably between multiple languages (rather, I expose simple lisp interfaces to clients and I have a new client who can't speak English), and having some lisp experience I figured Racket would be perfect for the job and even somewhat surprised not to find anything online about it. I'm only just working my way through the Racket guide so I'm very much a newbie Racketeer but I threw an LLM at the problem in hopes of here illustrating my intent, the results thereof which you're welcome to peruse/rewrite/burn with fire I put up on Github (which I understand is traditional for AI slop).
In any case this seems to me like both an important ability and one which suits Racket particularly well, so if there is an existing solution I'd love to just use it, and if there isn't is there anyone willing to collab on an open source lib?