-
Notifications
You must be signed in to change notification settings - Fork 76
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
i18n_key for derived record is the same as parent record #115
Comments
fsateler
added a commit
to fsateler/active_type
that referenced
this issue
Feb 12, 2020
This allows creating translations for the derived classes themselves instead of polluting the base class translations Fixes: makandra#115
I've posted a PR implementing the third option. Seems like the less intrusive to me. |
fsateler
added a commit
to fsateler/active_type
that referenced
this issue
Jul 21, 2020
This allows creating translations for the derived classes themselves instead of polluting the base class translations. For this we need to create an ActiveModel::Name, which uses the parent class name, but derived class reference. We then override the i18n_key, but not the other ones, to override i18n lookup but keep the same parameter and route names. A test is added to ensure the behavior Fixes: makandra#115
fsateler
added a commit
to fsateler/active_type
that referenced
this issue
Jul 21, 2020
This allows creating translations for the derived classes themselves instead of polluting the base class translations. For this we need to create an ActiveModel::Name, which uses the parent class name, but derived class reference. We then override the i18n_key, but not the other ones, to override i18n lookup but keep the same parameter and route names. A test is added to ensure the behavior Fixes: makandra#115
fsateler
added a commit
to fsateler/active_type
that referenced
this issue
Jul 21, 2020
This allows creating translations for the derived classes themselves instead of polluting the base class translations. For this we need to create an ActiveModel::Name, which uses the parent class name, but derived class reference. We then override the i18n_key, but not the other ones, to override i18n lookup but keep the same parameter and route names. A test is added to ensure the behavior Fixes: makandra#115
fsateler
added a commit
to fsateler/active_type
that referenced
this issue
Jul 21, 2020
This allows creating translations for the derived classes themselves instead of polluting the base class translations. For this we need to create an ActiveModel::Name, which uses the parent class name, but derived class reference. We then override the i18n_key, but not the other ones, to override i18n lookup but keep the same parameter and route names. A test is added to ensure the behavior Fixes: makandra#115
fsateler
added a commit
to fsateler/active_type
that referenced
this issue
Jul 22, 2020
This allows creating translations for the derived classes themselves instead of polluting the base class translations. For this we need to create an ActiveModel::Name, which uses the parent class name, but derived class reference. We then override the i18n_key, but not the other ones, to override i18n lookup but keep the same parameter and route names. A test is added to ensure the behavior Fixes: makandra#115
fsateler
added a commit
to fsateler/active_type
that referenced
this issue
Jul 24, 2020
This allows creating translations for the derived classes themselves instead of polluting the base class translations. For this we need to create an ActiveModel::Name, which uses the parent class name, but derived class reference. We then override the i18n_key, but not the other ones, to override i18n lookup but keep the same parameter and route names. A test is added to ensure the behavior Fixes: makandra#115
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Which creates pollution for the base class translations.
The setup
Expected Result
Actual Result
Investigation
Turns out that
ActiveType::RecordExtension::Inheritance
simply delegatesmodel_name
to the base record class:active_type/lib/active_type/record_extension/inheritance.rb
Lines 30 to 32 in 0973a8f
AFAICT, this necessary because it is desired that
param_key
and friends be the same. However, this has the problem thati18n_key
is the same too:This results in having to declare the extended properties in the translation for the base record class, which is confusing and pollutes the translations.
Solutions
My first local hack was to do this:
Which is of course super hacky. An alternative would be to create a Name subclass:
and then redefine
model_name
:A third alternative would be to monkey_patch
i18n_key
:The text was updated successfully, but these errors were encountered: