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

Use I18n translations for custom labels on dashboards #492

Merged
merged 1 commit into from
May 3, 2016

Conversation

c-lliope
Copy link
Contributor

Problem:

There was uncertainty about how to create custom labels for fields. In #451, it was suggested that we could use I18n translations to solve the problem.

If we accept that as the standard way to set custom labels, we should have a test for it.

Solution:

  • Add a test to verify that labels can be customized through I18n.
  • Add documentation about how to customize labels

To Do:

  • Update view code so the same translation definition applies on the show and collection pages, in addition to the form page.

cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>
<th class="cell-label
cell-label--<%= attr_type.html_class %>
cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change: improve spacing of a super-long HTML tag

@c-lliope c-lliope changed the title Add a test to verify that translated labels work Use I18n translations for custom labels on dashboards Apr 12, 2016
@c-lliope
Copy link
Contributor Author

@mcmire, can I get a review? Thanks!

Problem:

At the moment, developers can customize a field's label on form pages
with the following translation structure:

```
en:
  helpers:
    label:
      customer:
        name: Full Name
```

Many developers expect this label change to take effect
on the `show` and `index` pages, as well as the form page.

Solution:

Translate attribute labels with I18n before displaying them
on `show` and `index` pages.
@c-lliope c-lliope force-pushed the gw-custom-labels branch from 4ad2eb2 to b0c6d31 Compare May 3, 2016 05:01
@c-lliope c-lliope merged commit b0c6d31 into master May 3, 2016
@c-lliope c-lliope deleted the gw-custom-labels branch May 3, 2016 07:45
c-lliope added a commit that referenced this pull request May 18, 2016
Changes:

* [#573] [FEATURE] Render custom javascripts and stylesheets to the page
  by registering them with Administrate in an initializer.
  For example, you can create `config/initializers/administrate.rb`
  with the contents:
    ```
    Administrate::Engine.add_javascript "my_plugin/script"
    Administrate::Engine.add_stylesheet "my_plugin/styles"
    ```
* [#567] [FEATURE] Add a partial for rendering HTML links to stylesheets.
  This is useful for plugin developers,
  as well as people who want to add custom stylesheets on a page-by-page basis
  using `content_for(:stylesheet)`.
* [#492] [FEATURE] Translate attribute labels on show and index pages.
  To customize an attribute label, add translations according to the structure:
    ```
    en:
      helpers:
        label:
          customer:
            name: Full Name
    ```
@c-lliope c-lliope mentioned this pull request May 18, 2016
@kuboon
Copy link

kuboon commented Sep 1, 2016

Administrate already use Model.human to translate model name.
How about using Model.human_attribute_name for attributes?
http://apidock.com/rails/ActiveModel/Translation/human_attribute_name

heyogrady pushed a commit to heyogrady/administrate that referenced this pull request Sep 6, 2016
Changes:

* [thoughtbot#573] [FEATURE] Render custom javascripts and stylesheets to the page
  by registering them with Administrate in an initializer.
  For example, you can create `config/initializers/administrate.rb`
  with the contents:
    ```
    Administrate::Engine.add_javascript "my_plugin/script"
    Administrate::Engine.add_stylesheet "my_plugin/styles"
    ```
* [thoughtbot#567] [FEATURE] Add a partial for rendering HTML links to stylesheets.
  This is useful for plugin developers,
  as well as people who want to add custom stylesheets on a page-by-page basis
  using `content_for(:stylesheet)`.
* [thoughtbot#492] [FEATURE] Translate attribute labels on show and index pages.
  To customize an attribute label, add translations according to the structure:
    ```
    en:
      helpers:
        label:
          customer:
            name: Full Name
    ```
fwolfst pushed a commit to fwolfst/administrate that referenced this pull request Mar 8, 2017
Changes:

* [thoughtbot#573] [FEATURE] Render custom javascripts and stylesheets to the page
  by registering them with Administrate in an initializer.
  For example, you can create `config/initializers/administrate.rb`
  with the contents:
    ```
    Administrate::Engine.add_javascript "my_plugin/script"
    Administrate::Engine.add_stylesheet "my_plugin/styles"
    ```
* [thoughtbot#567] [FEATURE] Add a partial for rendering HTML links to stylesheets.
  This is useful for plugin developers,
  as well as people who want to add custom stylesheets on a page-by-page basis
  using `content_for(:stylesheet)`.
* [thoughtbot#492] [FEATURE] Translate attribute labels on show and index pages.
  To customize an attribute label, add translations according to the structure:
    ```
    en:
      helpers:
        label:
          customer:
            name: Full Name
    ```
@nickcharlton nickcharlton added the i18n translations and language support label Mar 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i18n translations and language support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants