Add i18n for project activity details

implementation/45083-update-look-of-activity-items-in-activity-module-for-project-and-work-packages
Christophe Bliard 2 years ago
parent 02a01f69f3
commit 35c22fbcb3
No known key found for this signature in database
GPG Key ID: 2BC07603210C3FA4
  1. 12
      config/locales/en.yml
  2. 13
      lib/open_project/journal_formatter/active_status.rb
  3. 13
      lib/open_project/journal_formatter/template.rb
  4. 13
      lib/open_project/journal_formatter/visibility.rb
  5. 2
      spec/factories/journal_factory.rb
  6. 2
      spec/lib/journal_formatter/active_status_spec.rb
  7. 2
      spec/lib/journal_formatter/template_spec.rb
  8. 2
      spec/lib/journal_formatter/visibility_spec.rb

@ -537,14 +537,24 @@ en:
member:
roles: "Roles"
project:
active_value:
true: "unarchived"
false: "archived"
identifier: "Identifier"
latest_activity_at: "Latest activity at"
parent: "Subproject of"
public_value:
title: "Visibility"
true: "public"
false: "private"
queries: "Queries"
templated: "Template project"
templated_value:
true: "marked as template"
false: "unmarked as template"
types: "Types"
versions: "Versions"
work_packages: "Work Packages"
templated: 'Template project'
projects/status:
code: 'Status'
explanation: 'Status description'

@ -28,9 +28,16 @@
class OpenProject::JournalFormatter::ActiveStatus < JournalFormatter::Base
def render(_key, values, options = { html: true })
label_text = options[:html] ? content_tag('strong', "Project") : "Project"
activated_text = values.last ? "unarchived" : "archived"
label_text = label('project')
label_text = content_tag('strong', label_text) if options[:html]
I18n.t(:text_journal_label_value, label: label_text, value: activated_text)
value = \
if values.last
I18n.t('activerecord.attributes.project.active_value.true')
else
I18n.t('activerecord.attributes.project.active_value.false')
end
I18n.t(:text_journal_label_value, label: label_text, value:)
end
end

@ -28,9 +28,16 @@
class OpenProject::JournalFormatter::Template < JournalFormatter::Base
def render(_key, values, options = { html: true })
label_text = options[:html] ? content_tag('strong', "Project") : "Project"
activated_text = values.last ? "marked as template" : "unmarked as template"
label_text = label('project')
label_text = content_tag('strong', label_text) if options[:html]
I18n.t(:text_journal_label_value, label: label_text, value: activated_text)
value = \
if values.last
I18n.t('activerecord.attributes.project.templated_value.true')
else
I18n.t('activerecord.attributes.project.templated_value.false')
end
I18n.t(:text_journal_label_value, label: label_text, value:)
end
end

@ -28,9 +28,16 @@
class OpenProject::JournalFormatter::Visibility < JournalFormatter::Base
def render(_key, values, options = { html: true })
label_text = options[:html] ? content_tag('strong', "Visibility") : "Visibility"
activated_text = "set to #{values.last ? 'public' : 'private'}"
label_text = I18n.t('activerecord.attributes.project.public_value.title')
label_text = content_tag('strong', label_text) if options[:html]
I18n.t(:text_journal_label_value, label: label_text, value: activated_text)
value = \
if values.last
I18n.t('activerecord.attributes.project.public_value.true')
else
I18n.t('activerecord.attributes.project.public_value.false')
end
I18n.t(:text_journal_set_to, label: label_text, value:)
end
end

@ -57,7 +57,7 @@ FactoryBot.define do
end
factory :project_journal, class: 'Journal' do
journable_type { 'Project' }
journable factory: :project
data { build(:journal_project_journal) }
end
end

@ -29,7 +29,7 @@
require 'spec_helper'
describe OpenProject::JournalFormatter::ActiveStatus do
let(:instance) { described_class.new(build(:journal)) }
let(:instance) { described_class.new(build(:project_journal)) }
it "renders correctly when unarchiving" do
html = instance.render("active", [false, true], html: true)

@ -29,7 +29,7 @@
require 'spec_helper'
describe OpenProject::JournalFormatter::Template do
let(:instance) { described_class.new(build(:journal, journable: build(:project))) }
let(:instance) { described_class.new(build(:project_journal)) }
it "renders correctly when marked as template" do
html = instance.render("templated", [false, true], html: true)

@ -29,7 +29,7 @@
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper.rb")
describe OpenProject::JournalFormatter::Visibility do
let(:instance) { described_class.new(build(:journal)) }
let(:instance) { described_class.new(build(:project_journal)) }
it "renders correctly when setting visibility" do
html = instance.render("public", [nil, true], html: true)

Loading…
Cancel
Save