# Localized categories plugin

**URL:** https://meta.discourse.org/t/localized-categories-plugin/45296
**Category:** Plugin
**Tags:** broken
**Created:** [June 5, 2016, 9:42pm UTC](https://meta.discourse.org/t/localized-categories-plugin/45296 "2016-06-05T21:42:21Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [June 5, 2016, 9:42pm UTC](https://meta.discourse.org/t/localized-categories-plugin/45296/1 "2016-06-05T21:42:21Z")

</div>

A plugin to set a category’s locale based off it’s slug.

[https://github.com/scossar/localized-categories](https://github.com/scossar/localized-categories)

This plugin allows you to set the locale for individual categories by basing the category slug off the locale’s language code. For example, for Persian set the category’s slug to `fa-ir`. The locale will be applied to the category and to its subcategories.

When the locale changes, the new locale is automatically reloaded. For non-locale categories, the locale is reset to either the site’s default locale, or the user’s preferred locale.

_Todo: get the locale off the http headers for non-logged in users._

The plugin works, but is still under development. If you are interested in using it on a ‘serious’ website, get in touch with me.

The categories page is displayed in either the site’s default locale or the user’s preferred locale:

 ![](https://global.discourse-cdn.com/meta/original/3X/2/f/2fc67b622ff4637fca0e6252d44d04ecb8b41a91.png)

The category page for localized categories uses the category’s locale:

 ![](https://global.discourse-cdn.com/meta/original/3X/c/1/c1fd0654795d0a9e37b927e8846de3d24c587d54.png)

This is shown when the locale is being updated. The text should probably be replaced with some kind of graphic:

 ![](https://global.discourse-cdn.com/meta/original/3X/e/e/ee7db8db5fd2bd95c16423d32c03537ee7b244d4.png)

---

<div class="post-metadata">

### Author: ![Pad\_Pors](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pad_pors/32/52016_2.png) [@Pad\_Pors](https://meta.discourse.org/u/Pad_Pors)
#### Post date: [June 6, 2016, 6:54am UTC](https://meta.discourse.org/t/localized-categories-plugin/45296/2 "2016-06-06T06:54:13Z")

</div>

this is great 😀

i’d love to try it, and will update about the ups and downs.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [June 6, 2016, 8:01pm UTC](https://meta.discourse.org/t/localized-categories-plugin/45296/3 "2016-06-06T20:01:06Z")

</div>

If you try it make sure to use the latest version.

---

<div class="post-metadata">

### Author: ![Pad\_Pors](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pad_pors/32/52016_2.png) [@Pad\_Pors](https://meta.discourse.org/u/Pad_Pors)
#### Post date: [June 17, 2016, 7:04pm UTC](https://meta.discourse.org/t/localized-categories-plugin/45296/4 "2016-06-17T19:04:35Z")

</div>

just found the time to start testing, cool and useful especially for non-English forums.

meanwhile,

- after i activated the plugin and named a folder-slug into en, i got errors with this log:  
[subcat.txt](https://global.discourse-cdn.com/meta/original/3X/5/0/5064fcb719fc4a9ab2d239aa5018dfd8d9285927.txt) (4.8 KB)  
and after i remove the [topic list preview](https://meta.discourse.org/t/topic-list-previews/41630), everything comes back to normal. is there a way to have both plugins?

- after i changed the local from fa\_IR to en in the user setting, the site couldn’t be loaded, and kept on the message: “The site locale is being updated”. until i changed the user local from en to fa\_IR again. error log:  
[err2.txt](https://global.discourse-cdn.com/meta/original/3X/9/e/9eef5fc992a836dca42c6cac01c8c526d82c63a6.txt) (1.9 KB)

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [June 17, 2016, 7:08pm UTC](https://meta.discourse.org/t/localized-categories-plugin/45296/5 "2016-06-17T19:08:22Z")

</div>

Yes, I ran into the same problem yesterday! I’ll try to fix that this afternoon.

Do you have ‘set locale from accept language header’ set to true? I assumed that was what was causing the problem.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [June 18, 2016, 3:29am UTC](https://meta.discourse.org/t/localized-categories-plugin/45296/6 "2016-06-18T03:29:39Z")

</div>

It’s working now for when there are user set locales and for when ‘set locale from accept language header’ is true. I still want to change the way it is loading the locales.

You can try it out here: [http://constructivelearningspace.com/](http://constructivelearningspace.com/)  
We’re trying to set up an informal group for teaching/learning Persian. It’s just getting started. (I’m still trying to find the letters on the keyboard 🙂 )

* * *

edit: I’ve changed the plugin so that it does not switch the locales for anonymous users. This is because I am using it on a forum where I have the setting ‘set locale from accept language header’ set to true. (Although I have limited it for now to only accept ‘en’, ‘fr’, and ‘fa-IR’). The reason for using this setting is to allow users to sign up for the site in the language they are most comfortable in. The problem this creates for the plugin is that it needs to know what language to switch back to when it is leaving a localized category.

---

<div class="post-metadata">

### Author: ![Pad\_Pors](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pad_pors/32/52016_2.png) [@Pad\_Pors](https://meta.discourse.org/u/Pad_Pors)
#### Post date: [June 18, 2016, 5:57am UTC](https://meta.discourse.org/t/localized-categories-plugin/45296/7 "2016-06-18T05:57:36Z")

</div>

that’s cool, i think i may be able to be handy there 😉 though you should tolerate the way i use English!

i just signed up there, and will participate in the discussion hopefully tonight 😃

---

<div class="post-metadata">

### Author: ![Roxelle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roxelle/32/46924_2.png) [@Roxelle](https://meta.discourse.org/u/Roxelle)
#### Post date: [June 23, 2016, 5:58pm UTC](https://meta.discourse.org/t/localized-categories-plugin/45296/8 "2016-06-23T17:58:32Z")

</div>

This plugin also translates the topic etc? Or only a name category?

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [June 23, 2016, 6:34pm UTC](https://meta.discourse.org/t/localized-categories-plugin/45296/9 "2016-06-23T18:34:20Z")

</div>

It forces the site locale to change. That has the same effect as when you change the locale in your user preferences on sites that allow user locales to be set - it translates the user interface, but not the content of posts.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [September 30, 2016, 10:21pm UTC](https://meta.discourse.org/t/localized-categories-plugin/45296/10 "2016-09-30T22:21:35Z")

</div>

I haven’t looked at this for a while. Get in touch with me if you are going to enable it on a production site.

---

<div class="post-metadata">

### Author: ![Pad\_Pors](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pad_pors/32/52016_2.png) [@Pad\_Pors](https://meta.discourse.org/u/Pad_Pors)
#### Post date: [October 1, 2016, 9:43am UTC](https://meta.discourse.org/t/localized-categories-plugin/45296/11 "2016-10-01T09:43:23Z")

</div>

is the plugin still available in “constructive-learning-space” ? as I couldn’t see it working there.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [October 1, 2016, 5:10pm UTC](https://meta.discourse.org/t/localized-categories-plugin/45296/12 "2016-10-01T17:10:12Z")

</div>

No, but I’m going to try adding it back right away. I took off because I was using the forum to test something.

---

<div class="post-metadata">

### Author: ![permacultureProgram](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/permacultureprogram/32/108924_2.png) [@permacultureProgram](https://meta.discourse.org/u/permacultureProgram)
#### Post date: [January 2, 2019, 11:31pm UTC](https://meta.discourse.org/t/localized-categories-plugin/45296/13 "2019-01-02T23:31:40Z")

</div>

I am looking into setting up a multi-language site (English/Chinese) and am wondering if this plugin works with the latest discourse versions or if there is a better way to enable a multi-language site?

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [January 2, 2019, 11:52pm UTC](https://meta.discourse.org/t/localized-categories-plugin/45296/14 "2019-01-02T23:52:29Z")

</div>

> [@permacultureProgram](#):
>
> am wondering if this plugin works with the latest discourse versions

No, it doesn’t work.

> [@permacultureProgram](#):
>
> if there is a better way to enable a multi-language site?

Have a look at this topic for a few ideas: [Structuring a multilingual community](https://meta.discourse.org/t/how-to-structure-a-multilingual-community/73225).

For the case of a forum where users are unlikely to be able to understand the site’s default locale, probably the most important thing is to make sure the user’s locale set correctly when they create their account. That way they will be able to navigate the forum, even if they can’t read some of the content. To do this, first make sure that the `allow user locale` Site Setting is enabled. When enabled, users will be able to set their locale on their preferences page.

Having to set the locale preferences on a site where users can’t understand the default locale could be difficult. There are two options I know of to get around this. You can either use SSO and set the locale with an SSO parameter, or enable the `set locale from accept language header` Site Setting.

Note: There is an issue with setting the locale for anonymous users for on sites that are using a CDN. It can cause the wrong locale files to be served to anonymous users. See: [Swedish? meta just showed me the UI in Swedish](https://meta.discourse.org/t/swedish-meta-just-showed-me-the-ui-in-swedish/41137).

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [January 2, 2019, 11:52pm UTC](https://meta.discourse.org/t/localized-categories-plugin/45296/15 "2019-01-02T23:52:33Z")

</div>


