Skip to content

I18n namespace configuration per grid#332

Closed
tmikoss wants to merge 1 commit intobogdan:mainfrom
tmikoss:feature/i18n-configuration
Closed

I18n namespace configuration per grid#332
tmikoss wants to merge 1 commit intobogdan:mainfrom
tmikoss:feature/i18n-configuration

Conversation

@tmikoss
Copy link
Contributor

@tmikoss tmikoss commented Jan 16, 2025

Introduces option to configure i18n namespaces per grid.

Example use case - I want to re-use activerecord.attributes.model translation namespace for most of my backoffice app grids.

class ExampleGrid < ApplicationGrid
   self.i18n_configuration = {
     namespace: "...", # applicable to both column & filter headers
     columns_namespace: "...", # only for colums, preferred over `namespace` if defined
     filters_namespace: "...", # only for filters, preferred over `namespace` if defined
  }
end

@bogdan
Copy link
Owner

bogdan commented Jan 18, 2025

This is going the direction I don't want it to go.
I think the best way to do it is through configuring the default options for filters and columns.

self.default_column_options = -> (column) {
  {header: -> { I18n.t(column.name, namespace: "other.columns")}
}

self.default_filter_options = -> (filter) {
  {header: -> {I18n(filter.name, namespace: "other.filters")}
}

Otherwise I believe we can't achieve the options that will fit every use case. This way allows you to redefine translations lookup in your own project in your own way and it would have explicit answers on how it should behave on edge cases.

This is not currently supported, so I am open for feedback on this approach.

@tmikoss
Copy link
Contributor Author

tmikoss commented Jan 18, 2025

@bogdan that could would work for me.

A fitler -> options / column -> options proc, with return value slotting in between gem defaults and per-filter / per-column call arguments. Probably implemented as first (-ish ?) line in filter / column function definition.

Want me to give it a shot and open a different PR?

@bogdan
Copy link
Owner

bogdan commented Jan 18, 2025

100%

@tmikoss
Copy link
Contributor Author

tmikoss commented Jan 27, 2025

@bogdan let's track the idea in #333 - if you don't like the I18n-specific configuration proposal, let's close this PR.

@tmikoss tmikoss closed this Jan 28, 2025
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.

2 participants