11Mobility . configure do |config |
2- # Sets the default backend to use in models. This can be overridden in models
3- # by passing +backend: ...+ to +translates+.
4- config . default_backend = :key_value
52
6- # By default, Mobility uses the +translates+ class method in models to
7- # describe translated attributes, but you can configure this method to be
8- # whatever you like. This may be useful if using Mobility alongside another
9- # translation gem which uses the same method name.
10- config . accessor_method = :translates
3+ # PLUGINS
4+ config . plugins do
5+ # Backend
6+ #
7+ # Sets the default backend to use in models. This can be overridden in models
8+ # by passing +backend: ...+ to +translates+.
9+ #
10+ # To default to a different backend globally, replace +:key_value+ by another
11+ # backend name.
12+ #
13+ backend :key_value , type : :text
1114
12- # To query on translated attributes, you need to append a scope to your
13- # model. The name of this scope is +i18n+ by default, but this can be changed
14- # to something else .
15- config . query_method = :i18n
15+ # ActiveRecord
16+ #
17+ # Defines ActiveRecord as ORM, and enables ActiveRecord-specific plugins .
18+ active_record
1619
17- # Uncomment and remove (or add) items to (from) this list to completely
18- # disable/enable plugins globally (so they cannot be used and are never even
19- # loaded). Note that if you remove an item from the list, you will not be
20- # able to use the plugin at all, and any options for the plugin will be
21- # ignored by models. (In most cases, you probably don't want to change this.)
22- #
23- # config.plugins = %i[
24- # query
25- # cache
26- # dirty
27- # fallbacks
28- # presence
29- # default
30- # attribute_methods
31- # fallthrough_accessors
32- # locale_accessors
33- # ]
20+ # Accessors
21+ #
22+ # Define reader and writer methods for translated attributes. Remove either
23+ # to disable globally, or pass +reader: false+ or +writer: false+ to
24+ # +translates+ in any translated model.
25+ #
26+ reader
27+ writer
3428
35- # The translation cache is on by default, but you can turn it off by
36- # uncommenting this line. (This may be helpful in debugging.)
37- #
38- # config.default_options[:cache] = false
29+ # Backend Reader
30+ #
31+ # Defines reader to access the backend for any attribute, of the form
32+ # +<attribute>_backend+.
33+ #
34+ backend_reader
35+ #
36+ # Or pass an interpolation string to define a different pattern:
37+ # backend_reader "%s_translations"
3938
40- # Dirty tracking is disabled by default. Uncomment this line to enable it.
41- # If you enable this, you should also enable +locale_accessors+ by default
42- # (see below).
43- #
44- # config.default_options[:dirty] = true
39+ # Query
40+ #
41+ # Defines a scope on the model class which allows querying on
42+ # translated attributes. The default scope is named +i18n+, pass a different
43+ # name as default to change the global default, or to +translates+ in any
44+ # model to change it for that model alone.
45+ #
46+ query
4547
46- # No fallbacks are used by default. To define default fallbacks, uncomment
47- # and set the default fallback option value here. A "true" value will use
48- # whatever is defined by +I18n.fallbacks+ (if defined), or alternatively will
49- # fallback to your +I18n.default_locale+.
50- #
51- config . default_options [ :fallbacks ] = true
48+ # Cache
49+ #
50+ # Comment out to disable caching reads and writes.
51+ #
52+ cache
5253
53- # The Presence plugin converts empty strings to nil when fetching and setting
54- # translations. By default it is on, uncomment this line to turn it off.
55- #
56- # config.default_options[:presence] = false
54+ # Dirty
55+ #
56+ # Uncomment this line to include and enable globally:
57+ # dirty
58+ #
59+ # Or uncomment this line to include but disable by default, and only enable
60+ # per model by passing +dirty: true+ to +translates+.
61+ # dirty false
5762
58- # Set a default value to use if the translation is nil. By default this is
59- # off, uncomment and set a default to use it across all models (you probably
60- # don't want to do that).
61- #
62- # config.default_options[:default] = ...
63+ # Fallbacks
64+ #
65+ # Uncomment line below to enable fallbacks, using +I18n.fallbacks+.
66+ fallbacks
67+ #
68+ # Or uncomment this line to enable fallbacks with a global default.
69+ # fallbacks { :pt => :en }
6370
64- # Uncomment to enable locale_accessors by default on models. A true value
65- # will use the locales defined either in
66- # Rails.application.config.i18n.available_locales or I18n.available_locales.
67- # If you want something else, pass an array of locales instead .
68- #
69- config . default_options [ :locale_accessors ] = true
71+ # Presence
72+ #
73+ # Converts blank strings to nil on reads and writes. Comment out to
74+ # disable .
75+ #
76+ presence
7077
71- # Uncomment to enable fallthrough accessors by default on models. This will
72- # allow you to call any method with a suffix like _en or _pt_br, and Mobility
73- # will catch the suffix and convert it into a locale in +method_missing+. If
74- # you don't need this kind of open-ended fallthrough behavior, it's better
75- # to use locale_accessors instead (which define methods) since method_missing
76- # is very slow. (You can use both fallthrough and locale accessor plugins
77- # together without conflict.)
78- #
79- # Note: The dirty plugin enables fallthrough_accessors by default.
80- #
81- # config.default_options[:fallthrough_accessors] = true
78+ # Default
79+ #
80+ # Set a default translation per attributes. When enabled, passing +default:
81+ # 'foo'+ sets a default translation string to show in case no translation is
82+ # present. Can also be passed a proc.
83+ #
84+ # default 'foo'
8285
83- # You can also include backend-specific default options. For example, if you
84- # want to default to using the text-type translation table with the KeyValue
85- # backend, you can set that as a default by uncommenting this line, or change
86- # it to :string to default to the string-type translation table instead. (For
87- # other backends, this option is ignored.)
88- #
89- config . default_options [ :type ] = :string
90- end
86+ # Fallthrough Accessors
87+ #
88+ # Uses method_missing to define locale-specific accessor methods like
89+ # +title_en+, +title_en=+, +title_fr+, +title_fr=+ for each translated
90+ # attribute. If you know what set of locales you want to support, it's
91+ # generally better to use Locale Accessors (or both together) since
92+ # +method_missing+ is very slow. (You can use both fallthrough and locale
93+ # accessor plugins together without conflict.)
94+ #
95+ # fallthrough_accessors
96+
97+ # Locale Accessors
98+ #
99+ # Uses +def+ to define accessor methods for a set of locales. By default uses
100+ # +I18n.available_locales+, but you can pass the set of locales with
101+ # +translates+ and/or set a global default here.
102+ #
103+ locale_accessors
104+ #
105+ # Or define specific defaults by uncommenting line below
106+ # locale_accessors [:en, :ja]
107+ end
108+ end
0 commit comments