Incorrect usage of week/month/year units in a translated string

AI-generated summary

The discussion addresses an issue with the incorrect usage of week, month, and year units in the topic_stat_sentence translation string, particularly for languages like Russian where grammatical cases affect translations. dimsuz highlights that the current approach fails to account for proper grammatical forms of units and contextual phrases like “in the past.” A proposed solution involves replacing the single string with separate, unit-specific translations: topic_stat_sentence_week, topic_stat_sentence_month, topic_stat_sentence_day, and topic_stat_sentence_year. gerhard references a previous discussion and supports the change. saurabhp implemented the fix for week and month, ensuring backward compatibility, and the PR was merged gerhard.

The topic_stat_sentence translateable string looks like this:

topic_stat_sentence:
  one: "%{count} new topic in the past %{unit}."
  other: "%{count} new topics in the past %{unit}."

And upon formatting this string at category-list.js.es6 count is applied as a plural argument, but the thing is that this is not enough, there are 2 issues for some languages:

  • unit can be not in nominative form here, so it is not correct to simply use translation of js.week string (for example ) as a unit
  • in the past part translation can change too depending on the unit value

For example in Russian the phrase in the past %{unit}% translates differently depending on unit:

week → “за предыдущую неделю”
month → “за предыдущий месяц”
day → “за предыдущий день”
minute → “за предыдущую минуту”

things to note above:

  • in the past (за предыдущую) changes depending on unit
  • {unit} is not nominative in the translation. Nominative for week/month/day/minute is неделя/месяц/день/минута, but in the phrase we use неделю/месяц/день/минуту for Russian.

Current behavior

is to translate in the past week as “за предыдущий неделя” which has both words wrong.

Proposed solution:

Unit should not be used here separately, instead the whole in the past week/month/day/year phrase should be made available for translation as 3 (or 4?) different translatable strings.

4 Likes

I brought that up 4 years ago in https://meta.discourse.org/t/its-not-possible-to-correctly-translate-topic-stat-sentence/18359
This could be a great #starter-task if someone wants to fix the translation. :wink:

I’d recommend replacing the existing translation with 4 new ones:

  • topic_stat_sentence_day
  • topic_stat_sentence_week
  • topic_stat_sentence_month
  • topic_stat_sentence_year
7 Likes

Hi @gerhard
I saw code corresponding to it, topic_stat_sentence string is used for translation only when unit is month or week. I have started with them only for now.

I m not an expert at translating so I have just added new variables and kept things backward compatible till we have translations available.

PR for same: FEAT: split topic_stat_sentence to topic_stat_sentence_week and topic… by mrfinch · Pull Request #6663 · discourse/discourse · GitHub

Let me know if that works.

Thanks

3 Likes

PR has been merged. Thanks @saurabhp! :+1:

The old string was replaced with the following two:

  • topic_stat_sentence_week
  • topic_stat_sentence_month
6 Likes