Localized categories plugin


(Simon Cossar) #1

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

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:

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

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


:( Error while trying to load Something went wrong
1 forum for multiple languages or 1 forum per language?
(Pad Pors) #2

this is great :grinning:

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


(Simon Cossar) #3

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


(Pad Pors) #4

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 (4.8 KB)
    and after i remove the topic list preview, 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 (1.9 KB)


(Simon Cossar) #5

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.


(Simon Cossar) #6

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/
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 :slight_smile: )


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.


Geo-targeting banners on Discourse
(Pad Pors) #7

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

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


(Marco) #8

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


(Simon Cossar) #9

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.


(Simon Cossar) #10

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.


(Pad Pors) #11

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


(Simon Cossar) #12

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