Skip to content

Bug 870 translate dropdown data #879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 13, 2025
27 changes: 24 additions & 3 deletions app/helpers/person_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ def nationality_string(nationality, nationality2)
end

def person_role_string(person_role)
"#{person_role.role.name} #{person_role.person_role_level&.level}
role_level = person_role.person_role_level&.level
role_level = I18n.t('language_skills.none') if role_level == 'Keine'
"#{person_role.role.name} #{role_level}
#{person_role.percent.nil? ? '' : "#{person_role.percent.to_i}%"}"
end

Expand Down Expand Up @@ -39,7 +41,9 @@ def group_person_skills_by_category(person)
end

def common_languages_translated
I18nData.languages('DE').collect do |language|
locale = I18n.locale
locale = 'de' if I18n.locale == :'de-CH'
I18nData.languages(locale).collect do |language|
if LanguageList::LanguageInfo.find(language[0])&.common?
[language.first, "#{language.last} (#{language.first})"]
end
Expand All @@ -58,7 +62,24 @@ def uneditable_language?(lang)
end

def language_skill_levels
%w[Keine A1 A2 B1 B2 C1 C2 Muttersprache]
[
[I18n.t('language_skills.none').to_s, 'Keines'],
%w[A1],
%w[A2],
%w[B1],
%w[B2],
%w[C1],
%w[C2],
[I18n.t('language_skills.native').to_s, 'Muttersprache']
]
end

def role_skill_levels
PersonRoleLevel.order(:level).each do |role|
if role.level == 'Keine'
role.level = I18n.t('language_skills.none')
end
end
end

def people_skills_of_category(category)
Expand Down
6 changes: 3 additions & 3 deletions app/views/people/_language_skill_fields.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
%div.visually-hidden= f.collection_select :language, common_languages_translated, :first, :last, { selected: f.object.language }
%div.d-flex
%div.w-25.me-2
= f.label :level
= f.collection_select :level, language_skill_levels, :itself, :itself, {}, class: "form-select mw-100 language-level-select"
= f.label t("global.people_skills.levels.level")
= f.collection_select :level, language_skill_levels, :last, :first, {}, class: "form-select mw-100 language-level-select"
%div.w-75
= f.label :certificate
= f.label t("global.people_skills.certificate")
= f.text_field :certificate, class: "mw-100 form-control language-certificate-input"
- unless uneditable_language?(f.object.language)
%div{"data-controller"=>"dynamic-fields"}
Expand Down
8 changes: 4 additions & 4 deletions app/views/people/_person_role_fields.html.haml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
%div.border.border-dark-subtle.rounded.p-1.fw-light.nested-fields
= f.hidden_field :_destroy
= f.label :role
= f.label t("activerecord.attributes.activity.role")
= f.collection_select :role_id, Role.order(:name), :id, :name, {}, class: "form-select w-100 role-select"
%div
= f.label :person_role_level
= f.label t("global.people_skills.levels.level")
%div.d-flex.fw-light
= f.collection_select :person_role_level_id, PersonRoleLevel.order(:level), :id, :level, {}, class: "form-select w-50 me-1 role-level-select"
= f.collection_select :person_role_level_id, role_skill_levels, :id, :level, {}, class: "form-select w-50 me-1 role-level-select"
= f.number_field :percent, in: 0..200, step: 1, class: "form-control w-50 person-role-percent"
%div{"data-controller"=>"dynamic-fields"}= link_to "Remove", "#", { class: "remove_fields", 'data-action' => 'dynamic-fields#removeField' }
%div{"data-controller"=>"dynamic-fields"}= link_to ti("link.remove"), "#", { class: "remove_fields", 'data-action' => 'dynamic-fields#removeField' }
5 changes: 5 additions & 0 deletions config/locales/de-CH.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ de-CH:
one: Witerbiudig
other: Witerbiudigä
birthdate: Geburtsdatum
company: Firma
competence_notes: Notizä Member
department: Organisationsiheit
display_competence_notes_in_cv: Im CV Export inkludierä.
Expand All @@ -60,6 +61,7 @@ de-CH:
one: Usbiudig
other: Usbiudigä
email: Email
language_skills: Sprachkenntniss
languages:
one: Sprach
other: Sprachä
Expand Down Expand Up @@ -264,6 +266,9 @@ de-CH:
add: "%{model} hinzuefügä"
delete: Löschä
edit: "%{model} bearbeitä"
language_skills:
native: Muetersprach
none: Kes
marital_statuses:
divorced: gschiedä
married: verhüratet
Expand Down
5 changes: 5 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ de:
one: Weiterbildung
other: Weiterbildungen
birthdate: Geburtsdatum
company: Firma
competence_notes: Notizen Member
department: Organisationseinheit
display_competence_notes_in_cv: Im CV Export inkludieren
Expand All @@ -60,6 +61,7 @@ de:
one: Ausbildung
other: Ausbildungen
email: Email
language_skills: Sprachkenntnisse
languages:
one: Sprache
other: Sprachen
Expand Down Expand Up @@ -247,6 +249,9 @@ de:
add: "%{model} hinzufügen"
delete: Löschen
edit: "%{model} bearbeiten"
language_skills:
native: Muttersprache
none: Keines
marital_statuses:
divorced: geschieden
married: verheiratet
Expand Down
5 changes: 5 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ en:
one: Further training
other: Further training
birthdate: Date of birth
company: Company
competence_notes: Notes Member
department: Department
display_competence_notes_in_cv: Include in CV export
Expand All @@ -60,6 +61,7 @@ en:
one: Education
other: Educations
email: Email
language_skills: Language skills
languages:
one: Language
other: Languages
Expand Down Expand Up @@ -243,6 +245,9 @@ en:
add: "%{model} add"
delete: Delete
edit: "%{model} edit"
language_skills:
native: Native speaker
none: None
marital_statuses:
divorced: divorced
married: married
Expand Down
5 changes: 5 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ fr:
one: Formation continue
other: Formations continues
birthdate: Date de naissance
company: Société
competence_notes: Notes Member
department: Unité organisationnelle
display_competence_notes_in_cv: Inclure dans l'exportation du CV
Expand All @@ -60,6 +61,7 @@ fr:
one: Formation
other: Formations
email: Email
language_skills: Compétences linguistiques
languages:
one: Langue
other: Langues
Expand Down Expand Up @@ -243,6 +245,9 @@ fr:
add: "%{model} ajouter"
delete: Supprimer
edit: "%{model} éditer"
language_skills:
native: Locuteur natif
none: Aucun
marital_statuses:
divorced: divorcé(e)
married: marié(e)
Expand Down
5 changes: 5 additions & 0 deletions config/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ it:
one: Formazione continua
other: Formazione continua
birthdate: Data di nascita
company: Azienda
competence_notes: Note Membro
department: Unità organizzativa
display_competence_notes_in_cv: Includere nell'esportazione del CV
Expand All @@ -60,6 +61,7 @@ it:
one: Istruzione
other: Programmi di formazione
email: E-mail
language_skills: Competenze linguistiche
languages:
one: Lingua
other: Le lingue
Expand Down Expand Up @@ -243,6 +245,9 @@ it:
add: "%{model} aggiungere"
delete: Cancellare
edit: "%{model} modifica"
language_skills:
native: Madrelingua
none: Nessuno
marital_statuses:
divorced: divorziato
married: sposato
Expand Down
2 changes: 1 addition & 1 deletion spec/features/people_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def check_edit_fields(person, editing)
expect(language_select.value).to eql(default_languages[i])
end
language_level_selects.each do |language_level_select|
expect(language_level_select.value).to eql('Keine')
expect(language_level_select.value).to eql('Keines')
end
language_certificate_inputs.each do |language_certificate_input|
expect(language_certificate_input.value).to eql('')
Expand Down
2 changes: 1 addition & 1 deletion spec/serializer/error_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
expect(json[:errors].first).to include(:id)
expect(json[:errors].first).to include(:title)
expect(json[:errors].first[:id]).to eq(:company)
expect(json[:errors].first[:title]).to eq('Company muss ausgefüllt werden')
expect(json[:errors].first[:title]).to eq('Firma muss ausgefüllt werden')
expect(json[:errors].second[:id]).to eq(:birthdate)
expect(json[:errors].second[:title]).to eq('Geburtsdatum muss ausgefüllt werden')
end
Expand Down