Js.filters.latest.title - incomplete pluralization in Transifex


(Anton) #1

Even though all related translations are in place in Transifex:

… the “zero” translation is not used:

I suspect the issue here is that the js.filters.latest.title key has incomplete pluralization and thus is treated by Transifex as 3 separate keys:

js.filters.latest.title.zero
js.filters.latest.title.one
js.filters.latest.title.other

The few key is missing.


Menu items translation bug
(Gerhard Schlager) #2

Yes, you’re right. And there are a bunch more with the same issue. I fixed most of them in PR 3817, but there are still some unresolved ones:

  • js.filters.latest.title
  • js.filters.unread.title
  • js.filters.new.title
  • js.filters.category.title

I didn’t fix them because those keys are heavily used in JavaScript and Ruby and I was under the false impression that pluralization doesn’t make sense in those cases anyway.
@eviltrout Your weren’t happy about my last changes to the templates. How would you like to fix the pluralizations in this case?


Russian localization trouble
Menu items translation bug
(Alexander) #3

Any updates on this? Will it be fixed in near future? Really annoying in non-english forums :disappointed_relieved:


(Robin Ward) #4

Can you remind me what needs to change in the template for this to work? It has been some time and I can’t seem to figure it out.


(Gerhard Schlager) #5

As you can see in my PR 3817 I had to add a few conditional statements to some templates.

Before:

After:
https://github.com/gschlager/discourse/blob/1e6ff9a83a8c154045a7af28f8d9c0533c90bd15/app/assets/javascripts/admin/templates/modal/admin_badge_preview.hbs#L17-L23

I didn’t fix the remaining four translation keys since they probably need some changes to templates as well and you expressed your concern about those changes in your comment:

The client templates seem to be quite a bit longer with this patch and I thought zero was a nice feature.

Finding all occurrences of those js.filters keys seemed like a lot of work and I wasn’t sure if you even wanted me to change the templates the way I did.

What I need from you in order to finish my PR:

  • A decision regarding my template changes. Are they fine or should I solve this e.g. by using some kind of additional parameter with the i18n method?
  • Maybe some hints where the js.filters keys are used. Looks like the keys are concatenated most of the time which makes them hard to find.

(Robin Ward) #6

Thanks for patience with me on this one! It has lasted so much time I’d forgotten some details.

  1. Having reviewed everything I think your template approach is best. Sorry for the runaround but I think it makes the most sense even if it adds a bunch of logic.

  2. That filter text is built programatically which is unfortunate. I think the following git grep shows most of the locations:

git grep "I18n.t([\"']filters"
app/assets/javascripts/discourse/components/navigation-item.js.es6:    return I18n.t("filters." + name.replace("/", ".") + ".help", extra);
app/assets/javascripts/discourse/components/topic-post-badges.js.es6:    link(buffer, this.get('unseen'), url, 'new-topic', 'new', I18n.t('filters.new.lower_title'));
app/assets/javascripts/discourse/helpers/period-title.js.es6:  const title = I18n.t('filters.top.' + (TITLE_SUBS[period] || 'this_week'));
app/assets/javascripts/discourse/models/nav-item.js.es6:    return I18n.t("filters." + name.replace("/", ".") + ".title", extra);
app/assets/javascripts/discourse/routes/build-category-route.js.es6:      const filterText = I18n.t('filters.' + filter.replace('/', '.') + '.title', { count: 0 }),
app/assets/javascripts/discourse/routes/build-category-route.js.es6:      return I18n.t('filters.with_category', { filter: filterText, category: category.get('name') });
app/assets/javascripts/discourse/routes/build-topic-route.js.es6:      const filterText = I18n.t('filters.' + filter.replace('/', '.') + '.title', {count: 0});
app/assets/javascripts/discourse/routes/build-topic-route.js.es6:      return I18n.t('filters.with_topics', {filter: filterText});
app/assets/javascripts/discourse/routes/discovery-categories.js.es6:    return I18n.t("filters.categories.title");

(Régis Hanol) #7