Project

General

Profile

Actions

Defect #42580

closed

Array#to_sentence produces incorrect output due to missing translation keys

Added by Katsuya HIDAKA 4 days ago. Updated 3 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Translations
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Currently, most locales define translations for Array#to_sentence using sentence_connector and skip_last_comma. However, these keys were replaced in Rails 2.3 (Release note) by last_word_connector, two_words_connector, and words_connector.

This patch updates the old keys to the new ones so that Array#to_sentence works as expected. The changes follow these rules:

  • Values for the new keys are taken from the rails-i18n gem's locale settings .
  • Locales that already define the new keys are left unchanged.
  • zh (zh-CN) is aligned with the zh-TW settings.

Redmine currently does not use Array#to_sentence, so this patch should not affect any functionality or UI. However, some third-party plugins might use it.

I confirmed that all tests, including system tests, pass after applying this patch. Here’s how Array#to_sentence behaves with the updated translations:

$ bin/rails console
redmine-app(dev)> array = ['Redmine', 'Ruby', 'Rails', 'ルビー', '紅寶石']
=> ["Redmine", "Ruby", "Rails", "ルビー", "紅寶石"]
redmine-app(dev)> array.to_sentence(locale: :en)
=> "Redmine, Ruby, Rails, ルビー, and 紅寶石" 
redmine-app(dev)> array.to_sentence(locale: :ja)
=> "Redmine、Ruby、Rails、ルビー、紅寶石" 
redmine-app(dev)> array.to_sentence(locale: :zh)
=> "Redmine, Ruby, Rails, ルビー, 和 紅寶石" 

Files

Actions #1

Updated by Go MAEDA 4 days ago

  • Tracker changed from Patch to Defect
  • Subject changed from Updates translations for Array#to_sentence to Array#to_sentence produces incorrect output due to missing translation keys
  • Status changed from New to Confirmed
  • Target version set to 6.1.0
Actions #2

Updated by Go MAEDA 4 days ago

Currently, Array#to_sentence produces incorrect output as follows. The patch fixes this behavior.

Current behavior:

redmine-app(dev)> %w(a b c).to_sentence(locale: :ja)
=> "a, b, and c" 
redmine-app(dev)> %w(a b c).to_sentence(locale: :zh)
=> "a, b, and c" 
redmine-app(dev)> %w(a b c).to_sentence(locale: :en)
=> "a, b, and c" 

Expected behavior:

redmine-app(dev)> %w(a b c).to_sentence(locale: :ja)
=> "a、b、c" 
redmine-app(dev)> %w(a b c).to_sentence(locale: :zh)
=> "a, b, 和 c" 
redmine-app(dev)> %w(a b c).to_sentence(locale: :en)
=> "a, b, and c" 

Actions #3

Updated by Go MAEDA 3 days ago

  • Status changed from Confirmed to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the fix in r23659. Thank you.

Actions

Also available in: Atom PDF