docs/i18n.md in bullet_train-1.1.10 vs docs/i18n.md in bullet_train-1.2.0

- old
+ new

@@ -1,3 +1,31 @@ # Translations and Internationalization Bullet Train and views generated by Super Scaffolding are localized by default, meaning all of the human-readable text in your application has been extracted into a YAML configuration file in `config/locales/en` and can be translated into any language you would like to target. + +We override the native I18n translation method to automatically include the current team name or other objects depending on the string. For example, here's a description of a membership which you can find on a membership's show page: + +``` +The following are the details for David’s Membership on Your Team. +``` + +The view can be found here in the `bullet_train-base` gem:<br/>[bullet_train-base/app/views/account/memberships/show.html.erb](https://github.com/bullet-train-co/bullet_train-base/blob/657e932cb4eb3e0c1f56c88c8365c2611de90e06/app/views/account/memberships/show.html.erb#L16)<br/> +<br/> +Looking at the view, you can see we are only passing a key to the translation method for I18n to process: + +```erb +<%= t('.description') %> +``` + +However, looking at the [locale itself](https://github.com/bullet-train-co/bullet_train-base/blob/657e932cb4eb3e0c1f56c88c8365c2611de90e06/config/locales/en/memberships.en.yml#L82), you can see that the string takes two variables, `memberships_possessive` and `team_name`, to complete the string: +```yaml +description: The following are the details for %{memberships_possessive} Membership on %{team_name}. +``` + +Usually, you would pass the variable as a keyword argument: +```ruby +t('.description', memberships_possessive: memberships_possessive, team_name: current_team.name) +``` + +However, in Bullet Train, we override the original translation method to include variable names like this automatically in our locales. Check out the [locale helper](https://github.com/bullet-train-co/bullet_train-base/blob/main/app/helpers/account/locale_helper.rb) to get a closer look at how we handle strings for internationalization. For example, the two variables above are generated by the method `model_locales` in the locale helper. + +You can find more information in the [indirection documentation](indirection) about using `bin/resolve` and logs to pinpoint where your locales are coming from.