Setting default site settings and scss based on locale

Site settings

The default site setting may not make sense for different language. I’ll list my Chinese(zh_CN) forum site setting to illustrate:

  • min_post_length: 3, default: 20
  • min_topic_title_length: 4, default: 15
  • min_search_term_length: 1, default: 3
  • uncategorized_description: need translation

Chinese characters can express more per word which requires to change the default site setting anyway. If not to do so, Discourse can’t even post moderator post since the character of some translation for that moderator post is less than 20. it’s also suggested by @sam.

Basically, it can be done by load separate default setting file to override based on locale settings, like config/site_settings.<LANG>.yml

scss

It’s also good to set default font size and font family based on locale! foundation/variables.<LANG>.scss do the work, but would look horrible. And have to respect the user’s locale.

4 Likes

Yes we support adding support for per-language defaults for site settings. PR welcome.

Though your guys are busy these days @sam @riking, but I am confused by approach. Can you just go through the code and give me some advice to help me move on? Should roughly take your 5 minutes.

https://github.com/discourse/discourse/pull/3326/files

  • Separate files for override site setting. self.override_default_settings tries to load the default values.
  • self.refresh_defaults! is used to load the overrided the settings.
    • first load the defaults and refresh! to get the default_locale.
    • load the overrides and refresh! to refresh current and containers.
  • when default_locale changed, reload the site setting to get the right default values.

My question is:

  • better to put overrides in one file or merge into site_settings.yml?
  • refresh! twice is weird, but how can I get the right