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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#66093] Translate error messages
Tobias Dillmannc32c5d70d3ed
diff --git a/app/models/calculated_value_error.rb b/app/models/calculated_value_error.rbindex 56ad78af475..4c0515c246d 100644--- a/app/models/calculated_value_error.rb+++ b/app/models/calculated_value_error.rb@@ -32,9 +32,11 @@ class CalculatedValueError < ApplicationRecordbelongs_to :projectbelongs_to :custom_field- VALID_ERROR_CODES = %w[- ERROR_MATHEMATICAL- ].freeze+ ERROR_TRANSLATIONS = {+ "ERROR_MATHEMATICAL" => "calculated_values.errors.mathematical"+ }.freeze++ VALID_ERROR_CODES = ERROR_TRANSLATIONS.keys.freezevalidates :project_id, presence: truevalidates :custom_field_id, presence: true@@ -42,6 +44,8 @@ class CalculatedValueError < ApplicationRecordvalidates :error_code, inclusion: { in: VALID_ERROR_CODES }def error_message- "TODO: humanize error code into a nice, translated error message"+ translation_key = ERROR_TRANSLATIONS.fetch(error_code, "calculated_values.errors.unknown")++ I18n.t(translation_key)endenddiff --git a/config/locales/en.yml b/config/locales/en.ymlindex 7d112f89d4f..6a1d79be5df 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -360,6 +360,11 @@ en:no_results_title_text: There are currently no custom fields.no_results_content_text: Create a new custom field+ calculated_values:+ errors:+ unknown: "An unknown error occurred during calculation. Please review the formula and try again."+ mathematical: "A mathematical error occurred. Please review the formula and try again."+concatenation:single: "or"