Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the locale belong on the path or as a request parameter on the URI?

I have seen the locale added to an URI as a path variable:

/en-US/blah/

or

/blah/en-US

and I have seen it as a request parameter:

/blah?lang=en-US

Is there a standard way that I should be doing it? If not what are the pros and cons of each approach?

I kind of like the request parameter approach because it doesn't require you to pass the locale with every URI (unless you use the second approach and add the locale to the end of the path). Any additional thoughts?

like image 823
testing123 Avatar asked Oct 28 '25 05:10

testing123


1 Answers

I believe the "standard way" is to use an HTTP "accept language" header. Other than that, if you think it ought to be a parameter (because it's a system-system call or you might request a language other than the browser locale) then it's just a parameter the same as anything else and you should handle it in a similar fashion.

like image 163
PaulProgrammer Avatar answered Oct 30 '25 10:10

PaulProgrammer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!