I was thinking of using https://crates.io/crates/sys-locale to add an effect to basic-cli and basic-webserver so that people could build apps (and/packages) in future that support different locales.
Something like this which returns IETF BCP 47 strings like en-AU or en-US etc...
Locale.get : Task Str [NotAvailable]
# or with purity-inference
Locale.get! {} => Result Str [NotAvailable]
can the locale change in the middle of a running program? :thinking:
I guess so
if so, that makes sense to me!
Richard Feldman said:
can the locale change in the middle of a running program? :thinking:
I'm not sure, I guess we could pass it into the app on init
For purity inference, there's always going to be at least an empty record passed in, why not have that contain useful information about the current environment
Like we could move the current OS/Arch in there too -- instead of that being a effect
I think if it can change in the middle of the program, we should go with the API above
if a program doesn't want to support that, they can always call this once during initialization and then store it
but having the option means you can potentially also support live-updating it if it does change in the middle of the program
For webservers wouldn't locale depend on the request?
HTTP Accept-Language request header indicates the natural language and locale that the client prefers
oh cool, TIL!
I assumed that was just a server thing
then in that case yeah probably makes sense for basic-webserver to go off that
For basic-cli
https://github.com/roc-lang/basic-cli/pull/258
So it would live in Request then?
Request : {
method : Method,
headers : List Header,
url : Str,
mimeType : Str,
body : List U8,
timeout : TimeoutConfig,
acceptedLocales: List Str,
}
I think you could parse it out of the headers
that feels like maybe it should be opt-in, since some webservers wouldn't bother to do anything with the locale info
e.g. Header.acceptedLocales which takes a List Header and returns all the accepted locales it finds in there
:man_facepalming:
Lol, it doesn't need to be an effect
yeah if it's not asking the OS, then it can be pure! :smiley:
Last updated: Jun 16 2026 at 16:19 UTC