# Using language codes in URLs

**URL:** <https://discuss.openedx.org/t/using-language-codes-in-urls/5609>\
**Category:** i18n\
**Created:** [August 16, 2021, 9:46pm UTC](https://discuss.openedx.org/t/using-language-codes-in-urls/5609 "2021-08-16T21:46:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kory](https://avatars.discourse-cdn.com/v4/letter/k/6a8cbe/32.png) [@kory](https://discuss.openedx.org/u/kory)\
**Post date:** [August 16, 2021, 9:46pm UTC](https://discuss.openedx.org/t/using-language-codes-in-urls/5609/1 "2021-08-16T21:46:39Z")

</div>

We are in the process of supporting multiple languages on our Open edX site. Accordingly, we have the desired languages added to the dark lang config and have the `SHOW_HEADER_LANGUAGE_SELECTOR` setting set to true in our lms.yml file. Everything is working properly in terms of a language selector appearing in the header that a student can interact with to change the display language. However, we’d like to be able to have the language code appear in the URLs.

For example, the Demo Course URL is like this by default (even if viewing in a language that is _not_ the default site language such as Spanish): [https://our.openedxexample.org/courses/course-v1:edX+DemoX+Demo\_Course/about](https://our.openedxexample.org/courses/course-v1:edX+DemoX+Demo_Course/about) where we’d like it to appear like: [https://our.openedxexample.org/es/courses/course-v1:edX+DemoX+Demo\_Course/about](https://our.openedxexample.org/es/courses/course-v1:edX+DemoX+Demo_Course/about) or [https://our.openedxexample.org/courses/course-v1:edX+DemoX+Demo\_Course/about?lang-code=es](https://our.openedxexample.org/courses/course-v1:edX+DemoX+Demo_Course/about?lang-code=es)

It seems that the language is handled by a cookie called `openedx-language-preference` rather than using language codes in the URL, but the latter is preferable for us so we can send links and advertise our courses in target languages and have potential learners come to the site on a specific language.

---

<div class="post-metadata">

**Author:** ![guruprasad](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/guruprasad/32/303_2.png) [@guruprasad](https://discuss.openedx.org/u/guruprasad)\
**Post date:** [September 6, 2021, 6:17am UTC](https://discuss.openedx.org/t/using-language-codes-in-urls/5609/2 "2021-09-06T06:17:52Z")

</div>

@kory, modifying the URLs will require changing the `urls.py` file directly or via a plugin and I wouldn’t recommend doing that. However, you can create a custom domain and `Site` for each language like `es-courses.example.com` and configure the corresponding language (`LANGUAGE_CODE`) for each site in the `SiteConfiguration` model.

---

<div class="post-metadata">

**Author:** ![kory](https://avatars.discourse-cdn.com/v4/letter/k/6a8cbe/32.png) [@kory](https://discuss.openedx.org/u/kory)\
**Post date:** [September 7, 2021, 3:17pm UTC](https://discuss.openedx.org/t/using-language-codes-in-urls/5609/3 "2021-09-07T15:17:46Z")

</div>

@guruprasad so if we want to support five different languages, you recommend having _five_ separate installations of Open edX, each on its own subdomain? Is there any way to force a language by passing a parameter in the URL (eg. [courses.example.com/?lang=es](http://courses.example.com/?lang=es)) to get the first page load to be in the desired language and then the cookie functionality would take over from there?

---

<div class="post-metadata">

**Author:** ![guruprasad](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/guruprasad/32/303_2.png) [@guruprasad](https://discuss.openedx.org/u/guruprasad)\
**Post date:** [September 7, 2021, 3:55pm UTC](https://discuss.openedx.org/t/using-language-codes-in-urls/5609/4 "2021-09-07T15:55:49Z")

</div>

@kory,

> [@kory](#):
>
> so if we want to support five different languages, you recommend having _five_ separate installations of Open edX, each on its own subdomain?

No, I was suggesting that you use the “Sites” feature in Open edX that allows hosting multiple sites with their own configuration on a single instance of Open edX.

See [4.2. Configuring Open edX Sites — Installing, Configuring, and Running the Open edX Platform documentation](https://edx.readthedocs.io/projects/edx-installing-configuring-and-running/en/latest/configuration/sites/index.html)
