-
Notifications
You must be signed in to change notification settings - Fork 0
Localization feature
Necessity of supporting to provide settings depending on current locale is high. For example, you have in settings your site name, and this site is multilanguage. So you need to provide different site name in different languages and depending on current language proper name is using.
From version v0.0.5 settingify has builtin ability for supporting multilocaled settings. This feature may be either active or not. But be careful! Are localization feature active or not expects proper DB schema for Setting model.
For more detail understanding localization feature work lets consider several real world examples.
You do not need some additional configuration. Just use provided install generator. Enjoy!
You need to provide additional options for install generator. For example:
rails g settingify:install --localization --locales=fr,nl
Provided options affects on several parts:
- Generated Setting model schema: there are will be no
value
column, but will be columns likevalue_fr
andvalue_nl
; - Enables traco provided logic on Setting model.
After that fetched setting's value will be depending on I18n.locale
value.
Just follow next steps:
- Go to
config/initializers/settingify.rb
and add the following lines to the beginning:
Settingify.config do |config|
config.localization do |localization|
localization.active = true
localization.available_locales = [:locale1, :locale2]
end
end
# rest of the file
- Make migration for removing
value
column insettingify_settings
table and add independent column for each available locales using patternvalue_<LOCALE>
. It must be done because oftraco
is works so.