-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add specs covering localisation via procs
The :value_method, :text_method and :hint_method params passed to radio collections and the :hint_method params passed to checkbox collections now accept procs which can be used to customise the value retrieved from the item. This could be used for simple transformations like upcasing the text or more-complex operations like localising the value, as per the provided specs Refs #68
- Loading branch information
1 parent
de79ebe
commit 3c76246
Showing
6 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
colours: | ||
red: Rot | ||
green: Grün | ||
yellow: Gelb | ||
blue: Blau |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
def with_localisations(localisations, locale: :en) | ||
DEFAULT_LOCALE = :en | ||
|
||
def with_localisations(localisations, locale: DEFAULT_LOCALE) | ||
unless locale.eql?(DEFAULT_LOCALE) | ||
I18n.available_locales = [DEFAULT_LOCALE, locale] | ||
I18n.locale = locale | ||
end | ||
I18n.backend.store_translations(locale, localisations[locale]) | ||
|
||
yield | ||
ensure | ||
I18n.available_locales = DEFAULT_LOCALE | ||
I18n.locale = DEFAULT_LOCALE | ||
|
||
I18n.reload! | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters