18F/identity-idp

View on GitHub
app/views/shared/_email_languages.html.erb

Summary

Maintainability
Test Coverage
<%#
locals:
* f: from simple_form_for
* selection: the current language selection
* hint: optional hint override
%>
<%= f.input(
      :email_language,
      as: :radio_buttons,
      label: t('forms.registration.labels.email_language'),
      hint: local_assigns.fetch(
        :hint,
        t('account.email_language.languages_list', app_name: APP_NAME),
      ),
      collection: I18n.available_locales.map do |locale|
        label = locale == I18n.locale ?
          t('account.email_language.default', language: t("i18n.locale.#{locale}")) :
          t("i18n.locale.#{locale}")

        [
          content_tag(
            :span,
            label,
            lang: locale,
            aria: { hidden: true },
          ),
          locale,
          checked: selection ? selection.to_s == locale.to_s : I18n.locale.to_s == locale.to_s,
          lang: locale,
          aria: { label: label },
        ]
      end,
    ) %>