Blank topics page when interface language is German

AI-generated summary

A bug report by gerhard revealed that the topics page displays blankly when the interface language is set to German (or French) on meta.discourse.org. The issue was traced to a site customization script that incorrectly hardcoded English translations for ‘Bugs’ and ‘Features’ categories within the buildList function. simon identified that moving these translations out of the function and dynamically referencing the current locale resolves the crash. sam confirmed the root cause was the pattern used for localization in site customizations. He corrected the code to use I18n.translations[I18n.locale] instead of hardcoding .en.js, ensuring translations load correctly for all languages. While the fix works, sam noted minor residual glitches, including unread status translation issues in Hebrew and a formatting error with ‘1.2k’ on the front page.

Since this morning, I’m getting a blank page when I visit meta.discouse.org as long as I’m using German as interface language. I can’t test this anywhere else right now (try.discourse.org doesn’t allow users to change the interface language), but it’s definitely a problem here on meta.

Steps to reproduce:

  • Go to the user preferences
  • Change the interface language to “de”
  • Go back to the topic list and refresh the page

It seems to work with “ru”, but it looks like “fr” doesn’t work either.

「いいね!」 4

Getting the error Cannot set property ‘bugs’ of undefined’,

I18n.translations.en.js.filters.bugs = { title: "Bugs", help: "Open Bugs" };

Yeah, that error has been there for ages. :wink:
Must be something else.

I just updated my forum and everything works fine there. Everything works properly in my development environment too.

「いいね!」 1

Meta seems to be using this customization to create the ‘Bug’ and ‘Features’ nav items.

<script>
Discourse.ExternalNavItem = Discourse.NavItem.extend({
    href: function() {
        return this.get('href');
    }
    .property('href')
});

Discourse.NavItem.reopenClass({
    buildList: function(category, args) {
        var list = this._super(category, args);
        if (!category) {
             I18n.translations.en.js.filters.bugs = {
                title: "Bugs",
                help: "Open Bugs"
            };
            I18n.translations.en.js.filters.features = {
                title: "Features",
                help: "Open Feature Requests"
            };
            list.push(Discourse.ExternalNavItem.create({
                href: '/category/bug?order=op_likes&status=open',
                name: 'bugs'
            }));
            list.push(Discourse.ExternalNavItem.create({
                href: '/category/feature?order=op_likes&status=open',
                name: 'features'
            }));
        }
        return list;
    }
});
</script>

When I add that as a customization to the head section of my site I get similar results to what I’m seeing on meta when I change the locale to ‘fr’ or ‘de’. Moving the ‘bugs’ and ‘features’ translations out of the buildList function seems to solve the problem.

「いいね!」 3

Ahhhh at last I know what happened here will fix

「いいね!」 1

The pattern I used for adding a localization from a site customization was incorrect.

Instead of:

  I18n.translations.en.js.filters.bugs = { title: "Bugs", help: "Open Bugs" };
  I18n.translations.en.js.filters.features = { title: "Features", help: "Open Feature Requests" };

Should have been

  I18n.translations[I18n.locale].js.filters.bugs = { title: "Bugs", help: "Open Bugs" };
  I18n.translations[I18n.locale].js.filters.features = { title: "Features", help: "Open Feature Requests" };
「いいね!」 5

OK, this works, but I did notices some hebrew glitches a unread is not translated properly and @simon it looks like 1.2k has the k in the wrong side on front page

「いいね!」 2