Customizing Localizations?


(Jason Dreyzehner) #1

I’m interested in customizing the language used to describe features of our Discourse installation.

Primarily, I’d like to rename the concept of “Categories” to something like “Rooms” to better match the language my userbase expects. There are also a number of other built-in strings that — with some slight tweaking — would significantly improve the usability of my site. These tweaks do not apply to most Discourse sites, so they aren’t fit to be contributed back upstream.

I might be missing something obvious, is there a simple way to do this?

I’ve looked at few options:

CSS-based customization

With some CSS targeting magic, it seems like it’s somewhat possible to overwrite language, though this is extremely hacky. Abandoned this quickly.

Javascript substitution

I’ve also looked at customizing language with somewhat-hacky javascript selection and swapping of innerHTML content, but this doesn’t seem like a very elegant or sustainable solution.

Custom Localization / Localization Customization

This path seems to be the most promising, but I’m having trouble figuring out how to modify localizations in a way that doesn’t require a lot of work from our operations team to keep updated. A plugin seems like a possibility, but as a more design-focused person (without direct access to the code), this also seems to be somewhat roundabout.

From a Discourse UX perspective, the right person to be customizing Discourse strings for a specific installation seems to be the same designer/developer who would be modifying the custom CSS/HTML, and might not be the person who is managing the server.

An Admin Settings interface to overwrite strings per localizations would really top-off Discourse’s theme-ability. Has anyone considered or built something like this?


Hamburger menu: how to change FAQ to Guidelines, add Help link, remove About or make About customizable?
Replacing "New Topic" with "New Document" globally
Where find my client.fr.yml language file
(Jeff Atwood) #2

This has been requested many times. Unfortunately it is technically hard. It is on our list of things to get to, though.


(Jason Dreyzehner) #3

Oh! Glad to hear it’s on the list. Sorry if I’m reposting, couldn’t find any other topics that seemed to address the idea. Should we collect links here? Are there other relevant topics I can follow?


(Kane York) #4

Here’s the temporary workaround:


(Spero Koulouras) #5

I just did exactly this on our site using @riking’s info. I was not able to get the template to work with Discourse/Docker (just my ineptness), so what I did was straightforward, but will not survive upgrades without manual intervention:

  • made a copy of /var/www/discourse/config/client.en.yml
  • carefully edited it down, replacing all instances of category (or anything similar) with “dojo” as appropriate for our site. Ended up with about 100 lines
  • saved the edited file OUTSIDE of the docker container
  • copied the edited file to /var/www/discourse/plugins/locale_override/config/locales creating needed directories along the way
  • created the file /var/www/discourse/plugins/locale_override/plugin.rb containing a single comment line

I think that our localizations include:

  • substituting “dojo” for category in all places, with capitalization and pluralization considered
  • substituting “author” for “Users” in a few spots

Here is the full client.en.yml file. It is YAML so spaces are important!

en:
  js:
    categories:
      all: "all dojos"
      category: "Dojo"

    user:
      mailing_list_mode: "Receive an email for every new post (unless you mute the topic or dojo)"
      watched_categories_instructions: "You will automatically watch all new topics in these dojos. You will be notified of all new posts and topics, plus the count of unread and new posts will also appear next to the topic's listing."
      tracked_categories_instructions: "You will automatically track all new topics in these dojos. A count of unread and new posts will appear next to the topic."
      muted_categories_instructions: "You will not be notified of anything about new topics in these dojos, and they will not appear on your unread tab."

      categories_settings: "dojos"

      error:
        categorymissing: "You must choose a dojo"

    search:
      title: "search topics, posts, users, or dojos"

      context:
        category: "Search the \"{{category}}\"dojo"

    site_map: "go to another topic list or dojo"

    topics:
      bulk:
        change_category: "Change dojo"

    topic:
      browse_all_categories: Browse all dojos
      create: 'Compose'
      suggest_create_topic: Why not compose a topic?

      notifications:
        reasons:
          "3_6": 'You will receive notifications because you are watching this dojo.'
          "2_8": 'You will receive notifications because you are tracking this dojo.'
          "0_7": 'You are ignoring all notifications in this dojo.'

    category:
      none: 'no dojo'
      choose: 'Select a dojo'
      view: 'View Topics in dojo'
      delete: 'Delete dojo'
      create: 'Create dojo'
      save: 'Save dojo'
      creation_error: There has been an error during the creation of the dojo
      save_error: There was an error saving the dojo
      name: "dojo name"
      description: "Description"
      topic: "dojo topic"
      logo: "dojo logo image"
      background_image: "dojo background image"
      delete_confirm: "Are you sure you want to delete this dojo"
      delete_error: "There was an error deleting the dojo"
      list: "List dojos"
      no_description: "Please add a description for this dojo"
      already_used: 'This color has been used by another dojo'
      allow_badges_label: "Allow badges to be awarded in this dojo"
      position_disabled: "Dojos will be displayed in order of activity. To control the order of dojos in lists, "
      position_disabled_click: 'enable the "fixed dojo positions" setting.'
      parent: "Parent dojo"
      notifications:
        watching:
          description: "You will automatically watch all new topics in these dojos. You will be notified of all new posts and topics, plus the count of unread and new posts will also appear next to the topic."
        tracking:
          description: "You will automatically track all new topics in these dojos. A count of unread and new posts will appear next to the topic."
        muted:
          description: "You will not be notified of anything about new topics in these dojos, and they will not appear on your unread tab."

    topic_statuses:
      pinned:
        help: "This topic is pinned; it will display at the top of its dojo"

    composer:
      error:
        category_missing: "You must choose a dojo"
      create_topic: "Compose"

    users: "Author"
    users_lowercase: "author"
    category_title: "Dojo"

    categories_list: "Dojo List"

    filters:
      categories:
        title: "Dojos"
        title_in: "dojo- {{categoryName}}"
        help: "all topics grouped by dojo"
      category:
        help: "latest topics in the {{categoryName}} dojo"

    keyboard_shortcuts_help:
      jump_to:
        categories: '<b>g</b>, <b>c</b> Dojo'

    badges:
      badge:
        regular:
          description: <a href="https://meta.discourse.org/t/what-do-user-trust-levels-do/4924/6">Granted</a> change dojo, rename, followed links and lounge

Replacing "New Topic" with "New Document" globally
(Kane York) #6

Yes, that’s the correct solution. Glad you got it worked out.


(Marcin Rataj) #7

You may take a look at my discourse-locale-override plugin, which seems to do just that.

It is similar to @riking’s solution, but may be easier to maintain:
If you fork it and invite your team as collaborators, they can edit translations in .yml files directly via github’s web interface.
It will also make possible to update plugin on your instance via docker_manager’s web interface (/admin/upgrade).

I tested it a bit on my instance and also with @winterbox and it seems to do the job.


Custom message above login/signup forms?
(Jason Dreyzehner) #8

@lidel that’s perfect, thank you for sharing! Not sure how I missed your plugin in my initial search, hopefully this thread will send some others in the right direction.

I’ll still be crossing my fingers for a simple admin interface for quicker overrides, but this certainly fills our needs.

Thanks!


(Utkarsh Agarwal) #9

I tried doing something similar. I added a line in the email sent to users via invites in the server.en.yml file and rebuilt the app. Still nothing, doesn’t reflect any changes in the email that’s sent out.

Any suggestions?


(Spero Koulouras) #10

If you edited /var/www/discourse/config/locales/server.en.yml then it gets overwritten on the rebuild. You need to do this in a site localization as described earlier in this post and in the message from @lidel


(Joseph Pullan) #11

How do yu use this plugin? I mean, how can you customize stuff?


(Marcin Rataj) #12

If you ask about discourse-locale-override there is no GUI.
You just fork it at github and create/modify config/locales/*.xx_XX.yml by hand.
More details in FAQ, you can also take a look at existing forks.