Skip to content

Feature request: Add support for I18n context (e.g. frontend/backend) for enum translations #53

@Sotatek-LuanNguyen

Description

@Sotatek-LuanNguyen

Summary

Currently, enum_help supports translating enum values via I18n using a fixed key format: enums.<model_name>.<enum_name>.<value>. However, in many real-world applications, we need different display texts for the same enum value depending on context — for example:

  • In frontend, kind: :power should be displayed as "Power"
  • In backend/admin, kind: :power should be displayed as "Energy"

At the moment, enum_help does not support such context-based translations.


Example use case

class Tenant < ApplicationRecord
  enum kind: { power: 0 }
end

tenant = Tenant.new(kind: :power)

tenant.kind_i18n(:frontend) # => "Power"
tenant.kind_i18n(:backend)  # => "Energy"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions