Skip to content

FIX: Enumerize::Value to handle callable i18n_scope dynamically #463

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

devsigner
Copy link

To handle contextual local with proc
Ex:

    enumerize :license_type,
      in: [:student, :teacher, :user],
      i18n_scope: [
        -> { "enum.license_type/#{Current.application_platform}" },
        "models.article.enum.targets"
      ],
      scope: true,
      predicates: true

locales/enumerize.fr.yml

fr:
  enum:
    license_type: &license_types
      student: Élève
      teacher: Enseignant
      user: Particulier

    license_type/academic:
      <<: *license_types

    license_type/other:
      teacher: Enseignant
      student: Apprenant

Expect:

Current.application_platform = nil
Article.license_type.values["student"] # => "Élève"

Current.application_platform = :academic
Article.license_type.values["student"] # => "Élève"

Current.application_platform = :other
Article.license_type.values["student"] # => "Apprenant"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant