Skip to content
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

Allow I18n hint_key to be customized to include custom variable and allow i18n in html format when specified. #2741

Open
bekicot opened this issue Jan 3, 2025 · 0 comments

Comments

@bekicot
Copy link
Contributor

bekicot commented Jan 3, 2025

What would you like to be able to do? Can you provide some examples?

# config/locales/id.yml

id:
	administrate:
		field_hints:
			order:
				customer_html: "Id Pelanggan. Bila tidak ada, silahkan <a href='%{new_admin_customer_url}'>Buat Pelanggan Baru</a>"

How could we go about implementing that?

  • In the dashboard, add a new method to expose the required custom variables
def i18n_variables(resources)
  {
    new_admin_customer_url: Rails.application.routes.url_helper.new_admin_customer_url
  }
end
  • Update the view to reads from administrate.field_hints.resource.{field.html | field_html | field} ( assuming we are prioritizing the html version of translations`

Can you think of other approaches to the problem?
Customize the view

Resources:
I18n Guides
https://guides.rubyonrails.org/i18n.html#using-safe-html-translations

Field Hints Implementation

<% hint_key = "administrate.field_hints.#{page.resource_name}.#{attribute.name}" %>

Field Hints Documentation

### Form Fields' Hints

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

No branches or pull requests

1 participant