Use better localization helper

allows to remove redundant localizations
pull/2536/head
Jan Sandbrink 10 years ago
parent 9d7911064a
commit 08225b63b4
  1. 13
      config/locales/de.yml
  2. 13
      config/locales/en.yml
  3. 16
      lib/api/v3/work_packages/schema/work_package_schema_representer.rb
  4. 24
      spec/lib/api/v3/work_packages/work_package_schema_representer_spec.rb

@ -170,30 +170,18 @@ de:
parent_title: "Übergeordnete Seite"
redirect_existing_links: "Existierende Links umleiten"
work_package:
assigned_to: "Zugewiesen an"
author: "Autor"
created_at: "Erstellt am"
description: "Beschreibung"
done_ratio: "% erledigt"
due_date: "Abgabedatum"
estimated_time: "Geschätzter Aufwand"
fixed_version: "Version"
id: "ID"
parent: "Übergeordnete Aufgabe"
parent_issue: "Übergeordnete Aufgabe"
parent_work_package: "Übergeordnete Aufgabe"
priority: "Priorität"
progress: "% erledigt"
project: "Projekt"
responsible: "Verantwortlicher"
spent_time: "Aufgewendete Zeit"
start_date: "Beginn"
status: "Status"
subject: "Thema"
subproject: "Unterprojekt"
time_entries: "Logzeit"
type: "Typ"
updated_at: "Aktualisiert am"
watcher: "Beobachter"
errors:
messages:
@ -322,6 +310,7 @@ de:
display_sums: "Summen anzeigen"
due_date: "Abgabedatum"
estimated_hours: "Geschätzter Aufwand"
estimated_time: "Geschätzter Aufwand"
firstname: "Vorname"
group: "Gruppe"
groupname: "Gruppenname"

@ -170,30 +170,18 @@ en:
reported_project_status: Project status
created_at: Created
work_package:
assigned_to: "Assignee"
author: "Author"
created_at: "Created at"
description: "Description"
done_ratio: "% done"
due_date: "Due date"
estimated_time: "Estimated time"
fixed_version: "Version"
id: "ID"
parent: "Parent"
parent_issue: "Parent"
parent_work_package: "Parent"
priority: "Priority"
progress: "% done"
project: "Project"
responsible: "Responsible"
spent_time: "Spent time"
start_date: "Start date"
status: "Status"
subject: "Subject"
subproject: "Subproject"
time_entries: "Log time"
type: "Type"
updated_at: "Updated at"
watcher: "Watcher"
errors:
messages:
@ -321,6 +309,7 @@ en:
display_sums: "Display Sums"
due_date: "Due date"
estimated_hours: "Estimated time"
estimated_time: "Estimated time"
firstname: "First name"
group: "Group"
groupname: "Group name"

@ -35,8 +35,6 @@ module API
module WorkPackages
module Schema
class WorkPackageSchemaRepresenter < ::API::Decorators::Single
I18N_WORK_PACKAGE = 'activerecord.attributes.work_package'
def self.schema(property,
type: nil,
title: nil,
@ -46,7 +44,7 @@ module API
max_length: nil)
raise ArgumentError if property.nil? || type.nil?
title = I18n.t("#{I18N_WORK_PACKAGE}.#{property}") unless title
title = WorkPackage.human_attribute_name(property) unless title
schema = ::API::Decorators::PropertySchemaRepresenter.new(type: type,
name: title)
@ -69,7 +67,7 @@ module API
raise ArgumentError if property.nil? || href_callback.nil?
type = property.to_s.camelize unless type
title = I18n.t("#{I18N_WORK_PACKAGE}.#{property}") unless title
title = WorkPackage.human_attribute_name(property) unless title
property property,
exec_context: :decorator,
@ -129,7 +127,7 @@ module API
schema :percentage_done,
type: 'Integer',
title: I18n.t("#{I18N_WORK_PACKAGE}.done_ratio"),
title: WorkPackage.human_attribute_name(:done_ratio),
writable: false
schema :created_at,
@ -154,7 +152,6 @@ module API
schema_with_allowed_link :assignee,
type: 'User',
title: I18n.t("#{I18N_WORK_PACKAGE}.assigned_to"),
required: false,
href_callback: -> (*) {
api_v3_paths.available_assignees(represented.project.id)
@ -162,7 +159,6 @@ module API
schema_with_allowed_link :responsible,
type: 'User',
title: I18n.t("#{I18N_WORK_PACKAGE}.responsible"),
required: false,
href_callback: -> (*) {
api_v3_paths.available_responsibles(represented.project.id)
@ -174,7 +170,7 @@ module API
assignable_statuses = represented.assignable_statuses_for(current_user)
representer = ::API::Decorators::AllowedValuesByCollectionRepresenter.new(
type: 'Status',
name: I18n.t("#{I18N_WORK_PACKAGE}.status"),
name: WorkPackage.human_attribute_name(:status),
current_user: current_user,
value_representer: API::V3::Statuses::StatusRepresenter,
link_factory: -> (status) {
@ -196,7 +192,7 @@ module API
getter: -> (*) {
representer = ::API::Decorators::AllowedValuesByCollectionRepresenter.new(
type: 'Version',
name: I18n.t("#{I18N_WORK_PACKAGE}.fixed_version"),
name: WorkPackage.human_attribute_name(:version),
current_user: current_user,
value_representer: API::V3::Versions::VersionRepresenter,
link_factory: -> (version) {
@ -220,7 +216,7 @@ module API
getter: -> (*) {
representer = ::API::Decorators::AllowedValuesByCollectionRepresenter.new(
type: 'Priority',
name: I18n.t("#{I18N_WORK_PACKAGE}.priority"),
name: WorkPackage.human_attribute_name(:priority),
current_user: current_user,
value_representer: API::V3::Priorities::PriorityRepresenter,
link_factory: -> (priority) {

@ -137,7 +137,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
it_behaves_like 'has basic schema properties' do
let(:path) { 'id' }
let(:type) { 'Integer' }
let(:name) { I18n.t('activerecord.attributes.work_package.id') }
let(:name) { I18n.t('attributes.id') }
let(:required) { true }
let(:writable) { false }
end
@ -147,7 +147,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
it_behaves_like 'has basic schema properties' do
let(:path) { 'subject' }
let(:type) { 'String' }
let(:name) { I18n.t('activerecord.attributes.work_package.subject') }
let(:name) { I18n.t('attributes.subject') }
let(:required) { true }
let(:writable) { true }
end
@ -165,7 +165,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
it_behaves_like 'has basic schema properties' do
let(:path) { 'description' }
let(:type) { 'Formattable' }
let(:name) { I18n.t('activerecord.attributes.work_package.description') }
let(:name) { I18n.t('attributes.description') }
let(:required) { true }
let(:writable) { true }
end
@ -175,7 +175,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
it_behaves_like 'has basic schema properties' do
let(:path) { 'startDate' }
let(:type) { 'Date' }
let(:name) { I18n.t('activerecord.attributes.work_package.start_date') }
let(:name) { I18n.t('attributes.start_date') }
let(:required) { false }
let(:writable) { true }
end
@ -185,7 +185,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
it_behaves_like 'has basic schema properties' do
let(:path) { 'dueDate' }
let(:type) { 'Date' }
let(:name) { I18n.t('activerecord.attributes.work_package.due_date') }
let(:name) { I18n.t('attributes.due_date') }
let(:required) { false }
let(:writable) { true }
end
@ -195,7 +195,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
it_behaves_like 'has basic schema properties' do
let(:path) { 'estimatedTime' }
let(:type) { 'Duration' }
let(:name) { I18n.t('activerecord.attributes.work_package.estimated_time') }
let(:name) { I18n.t('attributes.estimated_time') }
let(:required) { false }
let(:writable) { false }
end
@ -225,7 +225,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
it_behaves_like 'has basic schema properties' do
let(:path) { 'createdAt' }
let(:type) { 'DateTime' }
let(:name) { I18n.t('activerecord.attributes.work_package.created_at') }
let(:name) { I18n.t('attributes.created_at') }
let(:required) { true }
let(:writable) { false }
end
@ -235,7 +235,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
it_behaves_like 'has basic schema properties' do
let(:path) { 'updatedAt' }
let(:type) { 'DateTime' }
let(:name) { I18n.t('activerecord.attributes.work_package.updated_at') }
let(:name) { I18n.t('attributes.updated_at') }
let(:required) { true }
let(:writable) { false }
end
@ -245,7 +245,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
it_behaves_like 'has basic schema properties' do
let(:path) { 'author' }
let(:type) { 'User' }
let(:name) { I18n.t('activerecord.attributes.work_package.author') }
let(:name) { I18n.t('attributes.author') }
let(:required) { true }
let(:writable) { false }
end
@ -255,7 +255,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
it_behaves_like 'has basic schema properties' do
let(:path) { 'project' }
let(:type) { 'Project' }
let(:name) { I18n.t('activerecord.attributes.work_package.project') }
let(:name) { I18n.t('attributes.project') }
let(:required) { true }
let(:writable) { false }
end
@ -275,7 +275,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
it_behaves_like 'has basic schema properties' do
let(:path) { 'status' }
let(:type) { 'Status' }
let(:name) { I18n.t('activerecord.attributes.work_package.status') }
let(:name) { I18n.t('attributes.status') }
let(:required) { true }
let(:writable) { true }
end
@ -392,7 +392,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
it_behaves_like 'has basic schema properties' do
let(:path) { 'assignee' }
let(:type) { 'User' }
let(:name) { I18n.t('activerecord.attributes.work_package.assigned_to') }
let(:name) { I18n.t('attributes.assigned_to') }
let(:required) { false }
let(:writable) { true }
end

Loading…
Cancel
Save