Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Use string keys for translation

Christophe Bliard956834b5fb31
diff --git a/app/seeders/source/filter_translatables.rb b/app/seeders/source/filter_translatables.rb
index 57170be5fc8..4304fbf8449 100644
--- a/app/seeders/source/filter_translatables.rb
+++ b/app/seeders/source/filter_translatables.rb
@@ -58,12 +58,13 @@ module Source::FilterTranslatables
def filter_translatables_in_array(array, translatable: false)
array.map.with_index.to_h do |value, i|
+ key = i.to_s
if value.is_a?(Hash)
- [i, filter_translatables_in_object(value)]
+ [key, filter_translatables_in_object(value)]
elsif translatable
- [i, value]
+ [key, value]
else
- [i, nil]
+ [key, nil]
end
end
.compact
diff --git a/spec/seeders/source/filter_translatables_spec.rb b/spec/seeders/source/filter_translatables_spec.rb
index f40dc0a49e3..d2a8cc6873d 100644
--- a/spec/seeders/source/filter_translatables_spec.rb
+++ b/spec/seeders/source/filter_translatables_spec.rb
@@ -78,9 +78,9 @@ RSpec.describe Source::FilterTranslatables do
}
expect(loader.filter_translatables(hash)).to eq(
'categories' => {
- 0 => 'First',
- 1 => 'Second',
- 2 => 'Third'
+ '0' => 'First',
+ '1' => 'Second',
+ '2' => 'Third'
}
)
end
@@ -95,8 +95,8 @@ RSpec.describe Source::FilterTranslatables do
}
expect(loader.filter_translatables(hash)).to eq(
'categories' => {
- 1 => { 'name' => 'kept as it is translatable' },
- 2 => 'Kept too as the parent key is translatable'
+ '1' => { 'name' => 'kept as it is translatable' },
+ '2' => 'Kept too as the parent key is translatable'
}
)
end
@@ -117,9 +117,9 @@ RSpec.describe Source::FilterTranslatables do
}
expect(loader.filter_translatables(hash)).to eq(
'categories' => {
- 0 => { 'name' => 'First' },
- 1 => { 'name' => 'Second' },
- 3 => { 'name' => 'Fourth' }
+ '0' => { 'name' => 'First' },
+ '1' => { 'name' => 'Second' },
+ '3' => { 'name' => 'Fourth' }
}
)
end