danger-packwerk 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/danger-packwerk/packwerk_wrapper.rb +2 -2
- data/lib/danger-packwerk/version.rb +1 -1
- data/sorbet/config +1 -0
- data/sorbet/rbi/gems/actionview@7.0.4.rbi +11543 -0
- data/sorbet/rbi/gems/activesupport@7.0.4.rbi +12959 -0
- data/sorbet/rbi/gems/addressable@2.8.1.rbi +1505 -0
- data/sorbet/rbi/gems/ast@2.4.2.rbi +522 -0
- data/sorbet/rbi/gems/better_html@2.0.1.rbi +286 -0
- data/sorbet/rbi/gems/builder@3.2.4.rbi +8 -0
- data/sorbet/rbi/gems/claide-plugins@0.9.2.rbi +791 -0
- data/sorbet/rbi/gems/claide@1.1.0.rbi +1132 -0
- data/sorbet/rbi/gems/coderay@1.1.3.rbi +2256 -0
- data/sorbet/rbi/gems/colored2@3.1.2.rbi +130 -0
- data/sorbet/rbi/gems/concurrent-ruby@1.1.10.rbi +8695 -0
- data/sorbet/rbi/gems/cork@0.3.0.rbi +248 -0
- data/sorbet/rbi/gems/crass@1.0.6.rbi +436 -0
- data/sorbet/rbi/gems/danger-plugin-api@1.0.0.rbi +8 -0
- data/sorbet/rbi/gems/danger@9.0.0.rbi +4722 -0
- data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +862 -0
- data/sorbet/rbi/gems/erubi@1.11.0.rbi +102 -0
- data/sorbet/rbi/gems/faraday-em_http@1.0.0.rbi +266 -0
- data/sorbet/rbi/gems/faraday-em_synchrony@1.0.0.rbi +209 -0
- data/sorbet/rbi/gems/faraday-excon@1.1.0.rbi +212 -0
- data/sorbet/rbi/gems/faraday-http-cache@2.4.1.rbi +805 -0
- data/sorbet/rbi/gems/faraday-httpclient@1.0.1.rbi +221 -0
- data/sorbet/rbi/gems/faraday-multipart@1.0.4.rbi +266 -0
- data/sorbet/rbi/gems/faraday-net_http@1.0.1.rbi +216 -0
- data/sorbet/rbi/gems/faraday-net_http_persistent@1.2.0.rbi +206 -0
- data/sorbet/rbi/gems/faraday-patron@1.0.0.rbi +212 -0
- data/sorbet/rbi/gems/faraday-rack@1.0.0.rbi +225 -0
- data/sorbet/rbi/gems/faraday-retry@1.0.3.rbi +222 -0
- data/sorbet/rbi/gems/faraday@1.10.2.rbi +1862 -0
- data/sorbet/rbi/gems/git@1.12.0.rbi +1936 -0
- data/sorbet/rbi/gems/i18n@1.12.0.rbi +1643 -0
- data/sorbet/rbi/gems/json@2.6.2.rbi +1418 -0
- data/sorbet/rbi/gems/kramdown-parser-gfm@1.1.0.rbi +8 -0
- data/sorbet/rbi/gems/kramdown@2.4.0.rbi +2168 -0
- data/sorbet/rbi/gems/loofah@2.19.0.rbi +646 -0
- data/sorbet/rbi/gems/method_source@1.0.0.rbi +199 -0
- data/sorbet/rbi/gems/minitest@5.16.3.rbi +997 -0
- data/sorbet/rbi/gems/multipart-post@2.2.3.rbi +165 -0
- data/sorbet/rbi/gems/nap@1.1.0.rbi +351 -0
- data/sorbet/rbi/gems/no_proxy_fix@0.1.2.rbi +8 -0
- data/sorbet/rbi/gems/nokogiri@1.13.8.rbi +4916 -0
- data/sorbet/rbi/gems/octokit@5.6.1.rbi +8939 -0
- data/sorbet/rbi/gems/open4@1.3.4.rbi +8 -0
- data/sorbet/rbi/gems/{packwerk@2.1.1.rbi → packwerk@2.2.1.rbi} +602 -51
- data/sorbet/rbi/gems/parallel@1.22.1.rbi +163 -0
- data/sorbet/rbi/gems/parser@3.1.2.1.rbi +5988 -0
- data/sorbet/rbi/gems/pry@0.14.1.rbi +6969 -0
- data/sorbet/rbi/gems/public_suffix@5.0.0.rbi +779 -0
- data/sorbet/rbi/gems/racc@1.6.0.rbi +92 -0
- data/sorbet/rbi/gems/rails-dom-testing@2.0.3.rbi +8 -0
- data/sorbet/rbi/gems/rails-html-sanitizer@1.4.3.rbi +493 -0
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +227 -0
- data/sorbet/rbi/gems/rake@13.0.6.rbi +1865 -0
- data/sorbet/rbi/gems/rbi@0.0.14.rbi +2337 -0
- data/sorbet/rbi/gems/rchardet@1.8.0.rbi +587 -0
- data/sorbet/rbi/gems/regexp_parser@2.5.0.rbi +1851 -0
- data/sorbet/rbi/gems/rexml@3.2.5.rbi +3852 -0
- data/sorbet/rbi/gems/rspec-core@3.11.0.rbi +7725 -0
- data/sorbet/rbi/gems/rspec-expectations@3.11.0.rbi +6201 -0
- data/sorbet/rbi/gems/rspec-mocks@3.11.1.rbi +3625 -0
- data/sorbet/rbi/gems/rspec-support@3.11.0.rbi +1176 -0
- data/sorbet/rbi/gems/rspec@3.11.0.rbi +40 -0
- data/sorbet/rbi/gems/rubocop-ast@1.21.0.rbi +4193 -0
- data/sorbet/rbi/gems/rubocop-sorbet@0.6.8.rbi +677 -0
- data/sorbet/rbi/gems/rubocop@1.36.0.rbi +37914 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +732 -0
- data/sorbet/rbi/gems/ruby2_keywords@0.0.5.rbi +8 -0
- data/sorbet/rbi/gems/sawyer@0.9.2.rbi +513 -0
- data/sorbet/rbi/gems/smart_properties@1.17.0.rbi +326 -0
- data/sorbet/rbi/gems/spoom@1.1.11.rbi +1600 -0
- data/sorbet/rbi/gems/tapioca@0.8.0.rbi +1959 -0
- data/sorbet/rbi/gems/terminal-table@3.0.2.rbi +438 -0
- data/sorbet/rbi/gems/thor@1.2.1.rbi +2921 -0
- data/sorbet/rbi/gems/tzinfo@2.0.5.rbi +4879 -0
- data/sorbet/rbi/gems/unicode-display_width@2.3.0.rbi +27 -0
- data/sorbet/rbi/gems/unparser@0.6.5.rbi +2789 -0
- data/sorbet/rbi/gems/webrick@1.7.0.rbi +1802 -0
- data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +288 -0
- data/sorbet/rbi/gems/yard@0.9.27.rbi +12668 -0
- data/sorbet/rbi/todo.rbi +122 -0
- metadata +84 -7
- data/sorbet/rbi/gems/danger@8.5.0.rbi +0 -122
@@ -0,0 +1,1643 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This is an autogenerated file for types exported from the `i18n` gem.
|
5
|
+
# Please instead update this file by running `bin/tapioca gem i18n`.
|
6
|
+
|
7
|
+
module GetText; end
|
8
|
+
|
9
|
+
class GetText::PoParser < ::Racc::Parser
|
10
|
+
def _(x); end
|
11
|
+
def _reduce_10(val, _values, result); end
|
12
|
+
def _reduce_12(val, _values, result); end
|
13
|
+
def _reduce_13(val, _values, result); end
|
14
|
+
def _reduce_14(val, _values, result); end
|
15
|
+
def _reduce_15(val, _values, result); end
|
16
|
+
def _reduce_5(val, _values, result); end
|
17
|
+
def _reduce_8(val, _values, result); end
|
18
|
+
def _reduce_9(val, _values, result); end
|
19
|
+
def _reduce_none(val, _values, result); end
|
20
|
+
def next_token; end
|
21
|
+
def on_comment(comment); end
|
22
|
+
def on_message(msgid, msgstr); end
|
23
|
+
def parse(str, data, ignore_fuzzy = T.unsafe(nil)); end
|
24
|
+
def unescape(orig); end
|
25
|
+
end
|
26
|
+
|
27
|
+
GetText::PoParser::Racc_arg = T.let(T.unsafe(nil), Array)
|
28
|
+
GetText::PoParser::Racc_debug_parser = T.let(T.unsafe(nil), TrueClass)
|
29
|
+
GetText::PoParser::Racc_token_to_s_table = T.let(T.unsafe(nil), Array)
|
30
|
+
|
31
|
+
# heavily based on Masao Mutoh's gettext String interpolation extension
|
32
|
+
# http://github.com/mutoh/gettext/blob/f6566738b981fe0952548c421042ad1e0cdfb31e/lib/gettext/core_ext/string.rb
|
33
|
+
module I18n
|
34
|
+
extend ::I18n::Base
|
35
|
+
|
36
|
+
class << self
|
37
|
+
def cache_key_digest; end
|
38
|
+
def cache_key_digest=(key_digest); end
|
39
|
+
def cache_namespace; end
|
40
|
+
def cache_namespace=(namespace); end
|
41
|
+
def cache_store; end
|
42
|
+
def cache_store=(store); end
|
43
|
+
|
44
|
+
# Returns the current fallbacks implementation. Defaults to +I18n::Locale::Fallbacks+.
|
45
|
+
def fallbacks; end
|
46
|
+
|
47
|
+
# Sets the current fallbacks implementation. Use this to set a different fallbacks implementation.
|
48
|
+
def fallbacks=(fallbacks); end
|
49
|
+
|
50
|
+
# Return String or raises MissingInterpolationArgument exception.
|
51
|
+
# Missing argument's logic is handled by I18n.config.missing_interpolation_argument_handler.
|
52
|
+
#
|
53
|
+
# @raise [ReservedInterpolationKey]
|
54
|
+
def interpolate(string, values); end
|
55
|
+
|
56
|
+
def interpolate_hash(string, values); end
|
57
|
+
def new_double_nested_cache; end
|
58
|
+
|
59
|
+
# @return [Boolean]
|
60
|
+
def perform_caching?; end
|
61
|
+
|
62
|
+
# Marks a key as reserved. Reserved keys are used internally,
|
63
|
+
# and can't also be used for interpolation. If you are using any
|
64
|
+
# extra keys as I18n options, you should call I18n.reserve_key
|
65
|
+
# before any I18n.translate (etc) calls are made.
|
66
|
+
def reserve_key(key); end
|
67
|
+
|
68
|
+
def reserved_keys_pattern; end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class I18n::ArgumentError < ::ArgumentError; end
|
73
|
+
module I18n::Backend; end
|
74
|
+
|
75
|
+
module I18n::Backend::Base
|
76
|
+
include ::I18n::Backend::Transliterator
|
77
|
+
|
78
|
+
# Returns an array of locales for which translations are available
|
79
|
+
# ignoring the reserved translation meta data key :i18n.
|
80
|
+
#
|
81
|
+
# @raise [NotImplementedError]
|
82
|
+
def available_locales; end
|
83
|
+
|
84
|
+
def eager_load!; end
|
85
|
+
|
86
|
+
# @return [Boolean]
|
87
|
+
def exists?(locale, key, options = T.unsafe(nil)); end
|
88
|
+
|
89
|
+
# Accepts a list of paths to translation files. Loads translations from
|
90
|
+
# plain Ruby (*.rb), YAML files (*.yml), or JSON files (*.json). See #load_rb, #load_yml, and #load_json
|
91
|
+
# for details.
|
92
|
+
def load_translations(*filenames); end
|
93
|
+
|
94
|
+
# Acts the same as +strftime+, but uses a localized version of the
|
95
|
+
# format string. Takes a key from the date/time formats translations as
|
96
|
+
# a format argument (<em>e.g.</em>, <tt>:short</tt> in <tt>:'date.formats'</tt>).
|
97
|
+
#
|
98
|
+
# @raise [ArgumentError]
|
99
|
+
def localize(locale, object, format = T.unsafe(nil), options = T.unsafe(nil)); end
|
100
|
+
|
101
|
+
def reload!; end
|
102
|
+
|
103
|
+
# This method receives a locale, a data hash and options for storing translations.
|
104
|
+
# Should be implemented
|
105
|
+
#
|
106
|
+
# @raise [NotImplementedError]
|
107
|
+
def store_translations(locale, data, options = T.unsafe(nil)); end
|
108
|
+
|
109
|
+
# @raise [I18n::ArgumentError]
|
110
|
+
def translate(locale, key, options = T.unsafe(nil)); end
|
111
|
+
|
112
|
+
protected
|
113
|
+
|
114
|
+
# Deep interpolation
|
115
|
+
#
|
116
|
+
# deep_interpolate { people: { ann: "Ann is %{ann}", john: "John is %{john}" } },
|
117
|
+
# ann: 'good', john: 'big'
|
118
|
+
# #=> { people: { ann: "Ann is good", john: "John is big" } }
|
119
|
+
def deep_interpolate(locale, data, values = T.unsafe(nil)); end
|
120
|
+
|
121
|
+
# Evaluates defaults.
|
122
|
+
# If given subject is an Array, it walks the array and returns the
|
123
|
+
# first translation that can be resolved. Otherwise it tries to resolve
|
124
|
+
# the translation directly.
|
125
|
+
def default(locale, object, subject, options = T.unsafe(nil)); end
|
126
|
+
|
127
|
+
# @return [Boolean]
|
128
|
+
def eager_loaded?; end
|
129
|
+
|
130
|
+
# Interpolates values into a given subject.
|
131
|
+
#
|
132
|
+
# if the given subject is a string then:
|
133
|
+
# method interpolates "file %{file} opened by %%{user}", :file => 'test.txt', :user => 'Mr. X'
|
134
|
+
# # => "file test.txt opened by %{user}"
|
135
|
+
#
|
136
|
+
# if the given subject is an array then:
|
137
|
+
# each element of the array is recursively interpolated (until it finds a string)
|
138
|
+
# method interpolates ["yes, %{user}", ["maybe no, %{user}, "no, %{user}"]], :user => "bartuz"
|
139
|
+
# # => "["yes, bartuz",["maybe no, bartuz", "no, bartuz"]]"
|
140
|
+
def interpolate(locale, subject, values = T.unsafe(nil)); end
|
141
|
+
|
142
|
+
# Loads a single translations file by delegating to #load_rb or
|
143
|
+
# #load_yml depending on the file extension and directly merges the
|
144
|
+
# data to the existing translations. Raises I18n::UnknownFileType
|
145
|
+
# for all other file extensions.
|
146
|
+
#
|
147
|
+
# @raise [UnknownFileType]
|
148
|
+
def load_file(filename); end
|
149
|
+
|
150
|
+
# Loads a JSON translations file. The data must have locales as
|
151
|
+
# toplevel keys.
|
152
|
+
def load_json(filename); end
|
153
|
+
|
154
|
+
# Loads a plain Ruby translations file. eval'ing the file must yield
|
155
|
+
# a Hash containing translation data with locales as toplevel keys.
|
156
|
+
def load_rb(filename); end
|
157
|
+
|
158
|
+
# Loads a YAML translations file. The data must have locales as
|
159
|
+
# toplevel keys.
|
160
|
+
def load_yaml(filename); end
|
161
|
+
|
162
|
+
# Loads a YAML translations file. The data must have locales as
|
163
|
+
# toplevel keys.
|
164
|
+
def load_yml(filename); end
|
165
|
+
|
166
|
+
# The method which actually looks up for the translation in the store.
|
167
|
+
#
|
168
|
+
# @raise [NotImplementedError]
|
169
|
+
def lookup(locale, key, scope = T.unsafe(nil), options = T.unsafe(nil)); end
|
170
|
+
|
171
|
+
def pluralization_key(entry, count); end
|
172
|
+
|
173
|
+
# Picks a translation from a pluralized mnemonic subkey according to English
|
174
|
+
# pluralization rules :
|
175
|
+
# - It will pick the :one subkey if count is equal to 1.
|
176
|
+
# - It will pick the :other subkey otherwise.
|
177
|
+
# - It will pick the :zero subkey in the special case where count is
|
178
|
+
# equal to 0 and there is a :zero subkey present. This behaviour is
|
179
|
+
# not standard with regards to the CLDR pluralization rules.
|
180
|
+
# Other backends can implement more flexible or complex pluralization rules.
|
181
|
+
#
|
182
|
+
# @raise [InvalidPluralizationData]
|
183
|
+
def pluralize(locale, entry, count); end
|
184
|
+
|
185
|
+
# Resolves a translation.
|
186
|
+
# If the given subject is a Symbol, it will be translated with the
|
187
|
+
# given options. If it is a Proc then it will be evaluated. All other
|
188
|
+
# subjects will be returned directly.
|
189
|
+
def resolve(locale, object, subject, options = T.unsafe(nil)); end
|
190
|
+
|
191
|
+
# Resolves a translation.
|
192
|
+
# If the given subject is a Symbol, it will be translated with the
|
193
|
+
# given options. If it is a Proc then it will be evaluated. All other
|
194
|
+
# subjects will be returned directly.
|
195
|
+
def resolve_entry(locale, object, subject, options = T.unsafe(nil)); end
|
196
|
+
|
197
|
+
# @return [Boolean]
|
198
|
+
def subtrees?; end
|
199
|
+
|
200
|
+
def translate_localization_format(locale, object, format, options); end
|
201
|
+
end
|
202
|
+
|
203
|
+
# TODO Should the cache be cleared if new translations are stored?
|
204
|
+
module I18n::Backend::Cache
|
205
|
+
def translate(locale, key, options = T.unsafe(nil)); end
|
206
|
+
|
207
|
+
protected
|
208
|
+
|
209
|
+
def _fetch(cache_key, &block); end
|
210
|
+
def cache_key(locale, key, options); end
|
211
|
+
def fetch(cache_key, &block); end
|
212
|
+
|
213
|
+
private
|
214
|
+
|
215
|
+
def digest_item(key); end
|
216
|
+
end
|
217
|
+
|
218
|
+
# Overwrites the Base load_file method to cache loaded file contents.
|
219
|
+
module I18n::Backend::CacheFile
|
220
|
+
# Optionally provide path_roots array to normalize filename paths,
|
221
|
+
# to make the cached i18n data portable across environments.
|
222
|
+
def path_roots; end
|
223
|
+
|
224
|
+
# Optionally provide path_roots array to normalize filename paths,
|
225
|
+
# to make the cached i18n data portable across environments.
|
226
|
+
def path_roots=(_arg0); end
|
227
|
+
|
228
|
+
protected
|
229
|
+
|
230
|
+
# Track loaded translation files in the `i18n.load_file` scope,
|
231
|
+
# and skip loading the file if its contents are still up-to-date.
|
232
|
+
def load_file(filename); end
|
233
|
+
|
234
|
+
# Translate absolute filename to relative path for i18n key.
|
235
|
+
def normalized_path(file); end
|
236
|
+
end
|
237
|
+
|
238
|
+
module I18n::Backend::Cascade
|
239
|
+
def lookup(locale, key, scope = T.unsafe(nil), options = T.unsafe(nil)); end
|
240
|
+
end
|
241
|
+
|
242
|
+
# Backend that chains multiple other backends and checks each of them when
|
243
|
+
# a translation needs to be looked up. This is useful when you want to use
|
244
|
+
# standard translations with a Simple backend but store custom application
|
245
|
+
# translations in a database or other backends.
|
246
|
+
#
|
247
|
+
# To use the Chain backend instantiate it and set it to the I18n module.
|
248
|
+
# You can add chained backends through the initializer or backends
|
249
|
+
# accessor:
|
250
|
+
#
|
251
|
+
# # preserves the existing Simple backend set to I18n.backend
|
252
|
+
# I18n.backend = I18n::Backend::Chain.new(I18n::Backend::ActiveRecord.new, I18n.backend)
|
253
|
+
#
|
254
|
+
# The implementation assumes that all backends added to the Chain implement
|
255
|
+
# a lookup method with the same API as Simple backend does.
|
256
|
+
class I18n::Backend::Chain
|
257
|
+
include ::I18n::Backend::Transliterator
|
258
|
+
include ::I18n::Backend::Base
|
259
|
+
include ::I18n::Backend::Chain::Implementation
|
260
|
+
end
|
261
|
+
|
262
|
+
module I18n::Backend::Chain::Implementation
|
263
|
+
include ::I18n::Backend::Transliterator
|
264
|
+
include ::I18n::Backend::Base
|
265
|
+
|
266
|
+
def initialize(*backends); end
|
267
|
+
|
268
|
+
def available_locales; end
|
269
|
+
|
270
|
+
# Returns the value of attribute backends.
|
271
|
+
def backends; end
|
272
|
+
|
273
|
+
# Sets the attribute backends
|
274
|
+
#
|
275
|
+
# @param value the value to set the attribute backends to.
|
276
|
+
def backends=(_arg0); end
|
277
|
+
|
278
|
+
def eager_load!; end
|
279
|
+
|
280
|
+
# @return [Boolean]
|
281
|
+
def exists?(locale, key, options = T.unsafe(nil)); end
|
282
|
+
|
283
|
+
# @return [Boolean]
|
284
|
+
def initialized?; end
|
285
|
+
|
286
|
+
def localize(locale, object, format = T.unsafe(nil), options = T.unsafe(nil)); end
|
287
|
+
def reload!; end
|
288
|
+
def store_translations(locale, data, options = T.unsafe(nil)); end
|
289
|
+
def translate(locale, key, default_options = T.unsafe(nil)); end
|
290
|
+
|
291
|
+
protected
|
292
|
+
|
293
|
+
def init_translations; end
|
294
|
+
|
295
|
+
# @return [Boolean]
|
296
|
+
def namespace_lookup?(result, options); end
|
297
|
+
|
298
|
+
def translations; end
|
299
|
+
|
300
|
+
private
|
301
|
+
|
302
|
+
# This is approximately what gets used in ActiveSupport.
|
303
|
+
# However since we are not guaranteed to run in an ActiveSupport context
|
304
|
+
# it is wise to have our own copy. We underscore it
|
305
|
+
# to not pollute the namespace of the including class.
|
306
|
+
def _deep_merge(hash, other_hash); end
|
307
|
+
end
|
308
|
+
|
309
|
+
module I18n::Backend::Fallbacks
|
310
|
+
# @return [Boolean]
|
311
|
+
def exists?(locale, key, options = T.unsafe(nil)); end
|
312
|
+
|
313
|
+
def extract_non_symbol_default!(options); end
|
314
|
+
def resolve_entry(locale, object, subject, options = T.unsafe(nil)); end
|
315
|
+
|
316
|
+
# Overwrites the Base backend translate method so that it will try each
|
317
|
+
# locale given by I18n.fallbacks for the given locale. E.g. for the
|
318
|
+
# locale :"de-DE" it might try the locales :"de-DE", :de and :en
|
319
|
+
# (depends on the fallbacks implementation) until it finds a result with
|
320
|
+
# the given options. If it does not find any result for any of the
|
321
|
+
# locales it will then throw MissingTranslation as usual.
|
322
|
+
#
|
323
|
+
# The default option takes precedence over fallback locales only when
|
324
|
+
# it's a Symbol. When the default contains a String, Proc or Hash
|
325
|
+
# it is evaluated last after all the fallback locales have been tried.
|
326
|
+
def translate(locale, key, options = T.unsafe(nil)); end
|
327
|
+
|
328
|
+
private
|
329
|
+
|
330
|
+
# Overwrite on_fallback to add specified logic when the fallback succeeds.
|
331
|
+
def on_fallback(_original_locale, _fallback_locale, _key, _options); end
|
332
|
+
end
|
333
|
+
|
334
|
+
# This module contains several helpers to assist flattening translations.
|
335
|
+
# You may want to flatten translations for:
|
336
|
+
#
|
337
|
+
# 1) speed up lookups, as in the Memoize backend;
|
338
|
+
# 2) In case you want to store translations in a data store, as in ActiveRecord backend;
|
339
|
+
#
|
340
|
+
# You can check both backends above for some examples.
|
341
|
+
# This module also keeps all links in a hash so they can be properly resolved when flattened.
|
342
|
+
module I18n::Backend::Flatten
|
343
|
+
# Flatten keys for nested Hashes by chaining up keys:
|
344
|
+
#
|
345
|
+
# >> { "a" => { "b" => { "c" => "d", "e" => "f" }, "g" => "h" }, "i" => "j"}.wind
|
346
|
+
# => { "a.b.c" => "d", "a.b.e" => "f", "a.g" => "h", "i" => "j" }
|
347
|
+
def flatten_keys(hash, escape, prev_key = T.unsafe(nil), &block); end
|
348
|
+
|
349
|
+
# Receives a hash of translations (where the key is a locale and
|
350
|
+
# the value is another hash) and return a hash with all
|
351
|
+
# translations flattened.
|
352
|
+
#
|
353
|
+
# Nested hashes are included in the flattened hash just if subtree
|
354
|
+
# is true and Symbols are automatically stored as links.
|
355
|
+
def flatten_translations(locale, data, escape, subtree); end
|
356
|
+
|
357
|
+
# Store flattened links.
|
358
|
+
def links; end
|
359
|
+
|
360
|
+
# Shortcut to I18n::Backend::Flatten.normalize_flat_keys
|
361
|
+
# and then resolve_links.
|
362
|
+
def normalize_flat_keys(locale, key, scope, separator); end
|
363
|
+
|
364
|
+
protected
|
365
|
+
|
366
|
+
def escape_default_separator(key); end
|
367
|
+
def find_link(locale, key); end
|
368
|
+
def resolve_link(locale, key); end
|
369
|
+
def store_link(locale, key, link); end
|
370
|
+
|
371
|
+
class << self
|
372
|
+
# Receives a string and escape the default separator.
|
373
|
+
def escape_default_separator(key); end
|
374
|
+
|
375
|
+
# normalize_keys the flatten way. This method is significantly faster
|
376
|
+
# and creates way less objects than the one at I18n.normalize_keys.
|
377
|
+
# It also handles escaping the translation keys.
|
378
|
+
def normalize_flat_keys(locale, key, scope, separator); end
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
I18n::Backend::Flatten::FLATTEN_SEPARATOR = T.let(T.unsafe(nil), String)
|
383
|
+
I18n::Backend::Flatten::SEPARATOR_ESCAPE_CHAR = T.let(T.unsafe(nil), String)
|
384
|
+
|
385
|
+
# Experimental support for using Gettext po files to store translations.
|
386
|
+
#
|
387
|
+
# To use this you can simply include the module to the Simple backend - or
|
388
|
+
# whatever other backend you are using.
|
389
|
+
#
|
390
|
+
# I18n::Backend::Simple.include(I18n::Backend::Gettext)
|
391
|
+
#
|
392
|
+
# Now you should be able to include your Gettext translation (*.po) files to
|
393
|
+
# the +I18n.load_path+ so they're loaded to the backend and you can use them as
|
394
|
+
# usual:
|
395
|
+
#
|
396
|
+
# I18n.load_path += Dir["path/to/locales/*.po"]
|
397
|
+
#
|
398
|
+
# Following the Gettext convention this implementation expects that your
|
399
|
+
# translation files are named by their locales. E.g. the file en.po would
|
400
|
+
# contain the translations for the English locale.
|
401
|
+
#
|
402
|
+
# To translate text <b>you must use</b> one of the translate methods provided by
|
403
|
+
# I18n::Gettext::Helpers.
|
404
|
+
#
|
405
|
+
# include I18n::Gettext::Helpers
|
406
|
+
# puts _("some string")
|
407
|
+
#
|
408
|
+
# Without it strings containing periods (".") will not be translated.
|
409
|
+
module I18n::Backend::Gettext
|
410
|
+
protected
|
411
|
+
|
412
|
+
def load_po(filename); end
|
413
|
+
def normalize(locale, data); end
|
414
|
+
def normalize_pluralization(locale, key, value); end
|
415
|
+
def parse(filename); end
|
416
|
+
end
|
417
|
+
|
418
|
+
class I18n::Backend::Gettext::PoData < ::Hash
|
419
|
+
def set_comment(msgid_or_sym, comment); end
|
420
|
+
end
|
421
|
+
|
422
|
+
module I18n::Backend::InterpolationCompiler
|
423
|
+
def interpolate(locale, string, values); end
|
424
|
+
def store_translations(locale, data, options = T.unsafe(nil)); end
|
425
|
+
|
426
|
+
protected
|
427
|
+
|
428
|
+
def compile_all_strings_in(data); end
|
429
|
+
end
|
430
|
+
|
431
|
+
module I18n::Backend::InterpolationCompiler::Compiler
|
432
|
+
extend ::I18n::Backend::InterpolationCompiler::Compiler
|
433
|
+
|
434
|
+
def compile_if_an_interpolation(string); end
|
435
|
+
|
436
|
+
# @return [Boolean]
|
437
|
+
def interpolated_str?(str); end
|
438
|
+
|
439
|
+
protected
|
440
|
+
|
441
|
+
def compile_interpolation_token(key); end
|
442
|
+
def compiled_interpolation_body(str); end
|
443
|
+
def direct_key(key); end
|
444
|
+
def escape_key_sym(key); end
|
445
|
+
def escape_plain_str(str); end
|
446
|
+
def handle_interpolation_token(interpolation, matchdata); end
|
447
|
+
def interpolate_key(key); end
|
448
|
+
def interpolate_or_raise_missing(key); end
|
449
|
+
def missing_key(key); end
|
450
|
+
def nil_key(key); end
|
451
|
+
def reserved_key(key); end
|
452
|
+
|
453
|
+
# tokenize("foo %{bar} baz %%{buz}") # => ["foo ", "%{bar}", " baz ", "%%{buz}"]
|
454
|
+
def tokenize(str); end
|
455
|
+
end
|
456
|
+
|
457
|
+
I18n::Backend::InterpolationCompiler::Compiler::INTERPOLATION_SYNTAX_PATTERN = T.let(T.unsafe(nil), Regexp)
|
458
|
+
I18n::Backend::InterpolationCompiler::Compiler::TOKENIZER = T.let(T.unsafe(nil), Regexp)
|
459
|
+
|
460
|
+
# This is a basic backend for key value stores. It receives on
|
461
|
+
# initialization the store, which should respond to three methods:
|
462
|
+
#
|
463
|
+
# * store#[](key) - Used to get a value
|
464
|
+
# * store#[]=(key, value) - Used to set a value
|
465
|
+
# * store#keys - Used to get all keys
|
466
|
+
#
|
467
|
+
# Since these stores only supports string, all values are converted
|
468
|
+
# to JSON before being stored, allowing it to also store booleans,
|
469
|
+
# hashes and arrays. However, this store does not support Procs.
|
470
|
+
#
|
471
|
+
# As the ActiveRecord backend, Symbols are just supported when loading
|
472
|
+
# translations from the filesystem or through explicit store translations.
|
473
|
+
#
|
474
|
+
# Also, avoid calling I18n.available_locales since it's a somehow
|
475
|
+
# expensive operation in most stores.
|
476
|
+
#
|
477
|
+
# == Example
|
478
|
+
#
|
479
|
+
# To setup I18n to use TokyoCabinet in memory is quite straightforward:
|
480
|
+
#
|
481
|
+
# require 'rufus/tokyo/cabinet' # gem install rufus-tokyo
|
482
|
+
# I18n.backend = I18n::Backend::KeyValue.new(Rufus::Tokyo::Cabinet.new('*'))
|
483
|
+
#
|
484
|
+
# == Performance
|
485
|
+
#
|
486
|
+
# You may make this backend even faster by including the Memoize module.
|
487
|
+
# However, notice that you should properly clear the cache if you change
|
488
|
+
# values directly in the key-store.
|
489
|
+
#
|
490
|
+
# == Subtrees
|
491
|
+
#
|
492
|
+
# In most backends, you are allowed to retrieve part of a translation tree:
|
493
|
+
#
|
494
|
+
# I18n.backend.store_translations :en, :foo => { :bar => :baz }
|
495
|
+
# I18n.t "foo" #=> { :bar => :baz }
|
496
|
+
#
|
497
|
+
# This backend supports this feature by default, but it slows down the storage
|
498
|
+
# of new data considerably and makes hard to delete entries. That said, you are
|
499
|
+
# allowed to disable the storage of subtrees on initialization:
|
500
|
+
#
|
501
|
+
# I18n::Backend::KeyValue.new(@store, false)
|
502
|
+
#
|
503
|
+
# This is useful if you are using a KeyValue backend chained to a Simple backend.
|
504
|
+
class I18n::Backend::KeyValue
|
505
|
+
include ::I18n::Backend::Flatten
|
506
|
+
include ::I18n::Backend::Transliterator
|
507
|
+
include ::I18n::Backend::Base
|
508
|
+
include ::I18n::Backend::KeyValue::Implementation
|
509
|
+
end
|
510
|
+
|
511
|
+
module I18n::Backend::KeyValue::Implementation
|
512
|
+
include ::I18n::Backend::Flatten
|
513
|
+
include ::I18n::Backend::Transliterator
|
514
|
+
include ::I18n::Backend::Base
|
515
|
+
|
516
|
+
def initialize(store, subtrees = T.unsafe(nil)); end
|
517
|
+
|
518
|
+
def available_locales; end
|
519
|
+
|
520
|
+
# @return [Boolean]
|
521
|
+
def initialized?; end
|
522
|
+
|
523
|
+
# Returns the value of attribute store.
|
524
|
+
def store; end
|
525
|
+
|
526
|
+
# Sets the attribute store
|
527
|
+
#
|
528
|
+
# @param value the value to set the attribute store to.
|
529
|
+
def store=(_arg0); end
|
530
|
+
|
531
|
+
def store_translations(locale, data, options = T.unsafe(nil)); end
|
532
|
+
|
533
|
+
protected
|
534
|
+
|
535
|
+
def init_translations; end
|
536
|
+
def lookup(locale, key, scope = T.unsafe(nil), options = T.unsafe(nil)); end
|
537
|
+
def pluralize(locale, entry, count); end
|
538
|
+
|
539
|
+
# @return [Boolean]
|
540
|
+
def subtrees?; end
|
541
|
+
|
542
|
+
# Queries the translations from the key-value store and converts
|
543
|
+
# them into a hash such as the one returned from loading the
|
544
|
+
# haml files
|
545
|
+
def translations; end
|
546
|
+
end
|
547
|
+
|
548
|
+
class I18n::Backend::KeyValue::SubtreeProxy
|
549
|
+
# @return [SubtreeProxy] a new instance of SubtreeProxy
|
550
|
+
def initialize(master_key, store); end
|
551
|
+
|
552
|
+
def [](key); end
|
553
|
+
|
554
|
+
# @return [Boolean]
|
555
|
+
def has_key?(key); end
|
556
|
+
|
557
|
+
def inspect; end
|
558
|
+
|
559
|
+
# @return [Boolean]
|
560
|
+
def instance_of?(klass); end
|
561
|
+
|
562
|
+
# @return [Boolean]
|
563
|
+
def is_a?(klass); end
|
564
|
+
|
565
|
+
# @return [Boolean]
|
566
|
+
def kind_of?(klass); end
|
567
|
+
|
568
|
+
# @return [Boolean]
|
569
|
+
def nil?; end
|
570
|
+
end
|
571
|
+
|
572
|
+
class I18n::Backend::LazyLoadable < ::I18n::Backend::Simple
|
573
|
+
# @return [LazyLoadable] a new instance of LazyLoadable
|
574
|
+
def initialize(lazy_load: T.unsafe(nil)); end
|
575
|
+
|
576
|
+
# Parse the load path and extract all locales.
|
577
|
+
def available_locales; end
|
578
|
+
|
579
|
+
# Eager loading is not supported in the lazy context.
|
580
|
+
def eager_load!; end
|
581
|
+
|
582
|
+
# Returns whether the current locale is initialized.
|
583
|
+
#
|
584
|
+
# @return [Boolean]
|
585
|
+
def initialized?; end
|
586
|
+
|
587
|
+
def lookup(locale, key, scope = T.unsafe(nil), options = T.unsafe(nil)); end
|
588
|
+
|
589
|
+
# Clean up translations and uninitialize all locales.
|
590
|
+
def reload!; end
|
591
|
+
|
592
|
+
protected
|
593
|
+
|
594
|
+
# Load translations from files that belong to the current locale.
|
595
|
+
#
|
596
|
+
# @raise [InvalidFilenames]
|
597
|
+
def init_translations; end
|
598
|
+
|
599
|
+
def initialized_locales; end
|
600
|
+
|
601
|
+
private
|
602
|
+
|
603
|
+
# Checks if a filename is named in correspondence to the translations it loaded.
|
604
|
+
# The locale extracted from the path must be the single locale loaded in the translations.
|
605
|
+
#
|
606
|
+
# @raise [FilenameIncorrect]
|
607
|
+
def assert_file_named_correctly!(file, translations); end
|
608
|
+
|
609
|
+
# Select all files from I18n load path that belong to current locale.
|
610
|
+
# These files must start with the locale identifier (ie. "en", "pt-BR"),
|
611
|
+
# followed by an "_" demarcation to separate proceeding text.
|
612
|
+
def filenames_for_current_locale; end
|
613
|
+
|
614
|
+
# @return [Boolean]
|
615
|
+
def lazy_load?; end
|
616
|
+
|
617
|
+
# Loads each file supplied and asserts that the file only loads
|
618
|
+
# translations as expected by the name. The method returns a list of
|
619
|
+
# errors corresponding to offending files.
|
620
|
+
def load_translations_and_collect_file_errors(files); end
|
621
|
+
end
|
622
|
+
|
623
|
+
class I18n::Backend::LazyLoadable::FilenameIncorrect < ::StandardError
|
624
|
+
# @return [FilenameIncorrect] a new instance of FilenameIncorrect
|
625
|
+
def initialize(file, expected_locale, unexpected_locales); end
|
626
|
+
end
|
627
|
+
|
628
|
+
# Backend that lazy loads translations based on the current locale. This
|
629
|
+
# implementation avoids loading all translations up front. Instead, it only
|
630
|
+
# loads the translations that belong to the current locale. This offers a
|
631
|
+
# performance incentive in local development and test environments for
|
632
|
+
# applications with many translations for many different locales. It's
|
633
|
+
# particularly useful when the application only refers to a single locales'
|
634
|
+
# translations at a time (ex. A Rails workload). The implementation
|
635
|
+
# identifies which translation files from the load path belong to the
|
636
|
+
# current locale by pattern matching against their path name.
|
637
|
+
#
|
638
|
+
# Specifically, a translation file is considered to belong to a locale if:
|
639
|
+
# a) the filename is in the I18n load path
|
640
|
+
# b) the filename ends in a supported extension (ie. .yml, .json, .po, .rb)
|
641
|
+
# c) the filename starts with the locale identifier
|
642
|
+
# d) the locale identifier and optional proceeding text is separated by an underscore, ie. "_".
|
643
|
+
#
|
644
|
+
# Examples:
|
645
|
+
# Valid files that will be selected by this backend:
|
646
|
+
#
|
647
|
+
# "files/locales/en_translation.yml" (Selected for locale "en")
|
648
|
+
# "files/locales/fr.po" (Selected for locale "fr")
|
649
|
+
#
|
650
|
+
# Invalid files that won't be selected by this backend:
|
651
|
+
#
|
652
|
+
# "files/locales/translation-file"
|
653
|
+
# "files/locales/en-translation.unsupported"
|
654
|
+
# "files/locales/french/translation.yml"
|
655
|
+
# "files/locales/fr/translation.yml"
|
656
|
+
#
|
657
|
+
# The implementation uses this assumption to defer the loading of
|
658
|
+
# translation files until the current locale actually requires them.
|
659
|
+
#
|
660
|
+
# The backend has two working modes: lazy_load and eager_load.
|
661
|
+
#
|
662
|
+
# Note: This backend should only be enabled in test environments!
|
663
|
+
# When the mode is set to false, the backend behaves exactly like the
|
664
|
+
# Simple backend, with an additional check that the paths being loaded
|
665
|
+
# abide by the format. If paths can't be matched to the format, an error is raised.
|
666
|
+
#
|
667
|
+
# You can configure lazy loaded backends through the initializer or backends
|
668
|
+
# accessor:
|
669
|
+
#
|
670
|
+
# # In test environments
|
671
|
+
#
|
672
|
+
# I18n.backend = I18n::Backend::LazyLoadable.new(lazy_load: true)
|
673
|
+
#
|
674
|
+
# # In other environments, such as production and CI
|
675
|
+
#
|
676
|
+
# I18n.backend = I18n::Backend::LazyLoadable.new(lazy_load: false) # default
|
677
|
+
class I18n::Backend::LocaleExtractor
|
678
|
+
class << self
|
679
|
+
def locale_from_path(path); end
|
680
|
+
end
|
681
|
+
end
|
682
|
+
|
683
|
+
module I18n::Backend::Memoize
|
684
|
+
def available_locales; end
|
685
|
+
def eager_load!; end
|
686
|
+
def reload!; end
|
687
|
+
def store_translations(locale, data, options = T.unsafe(nil)); end
|
688
|
+
|
689
|
+
protected
|
690
|
+
|
691
|
+
def lookup(locale, key, scope = T.unsafe(nil), options = T.unsafe(nil)); end
|
692
|
+
def memoized_lookup; end
|
693
|
+
def reset_memoizations!(locale = T.unsafe(nil)); end
|
694
|
+
end
|
695
|
+
|
696
|
+
module I18n::Backend::Metadata
|
697
|
+
def interpolate(locale, entry, values = T.unsafe(nil)); end
|
698
|
+
def pluralize(locale, entry, count); end
|
699
|
+
def translate(locale, key, options = T.unsafe(nil)); end
|
700
|
+
|
701
|
+
protected
|
702
|
+
|
703
|
+
def with_metadata(metadata, &block); end
|
704
|
+
|
705
|
+
class << self
|
706
|
+
# @private
|
707
|
+
def included(base); end
|
708
|
+
end
|
709
|
+
end
|
710
|
+
|
711
|
+
module I18n::Backend::Pluralization
|
712
|
+
# Overwrites the Base backend translate method so that it will check the
|
713
|
+
# translation meta data space (:i18n) for a locale specific pluralization
|
714
|
+
# rule and use it to pluralize the given entry. I.e. the library expects
|
715
|
+
# pluralization rules to be stored at I18n.t(:'i18n.plural.rule')
|
716
|
+
#
|
717
|
+
# Pluralization rules are expected to respond to #call(count) and
|
718
|
+
# return a pluralization key. Valid keys depend on the translation data
|
719
|
+
# hash (entry) but it is generally recommended to follow CLDR's style,
|
720
|
+
# i.e., return one of the keys :zero, :one, :few, :many, :other.
|
721
|
+
#
|
722
|
+
# The :zero key is always picked directly when count equals 0 AND the
|
723
|
+
# translation data has the key :zero. This way translators are free to
|
724
|
+
# either pick a special :zero translation even for languages where the
|
725
|
+
# pluralizer does not return a :zero key.
|
726
|
+
def pluralize(locale, entry, count); end
|
727
|
+
|
728
|
+
protected
|
729
|
+
|
730
|
+
def pluralizer(locale); end
|
731
|
+
def pluralizers; end
|
732
|
+
end
|
733
|
+
|
734
|
+
# A simple backend that reads translations from YAML files and stores them in
|
735
|
+
# an in-memory hash. Relies on the Base backend.
|
736
|
+
#
|
737
|
+
# The implementation is provided by a Implementation module allowing to easily
|
738
|
+
# extend Simple backend's behavior by including modules. E.g.:
|
739
|
+
#
|
740
|
+
# module I18n::Backend::Pluralization
|
741
|
+
# def pluralize(*args)
|
742
|
+
# # extended pluralization logic
|
743
|
+
# super
|
744
|
+
# end
|
745
|
+
# end
|
746
|
+
#
|
747
|
+
# I18n::Backend::Simple.include(I18n::Backend::Pluralization)
|
748
|
+
class I18n::Backend::Simple
|
749
|
+
include ::I18n::Backend::Transliterator
|
750
|
+
include ::I18n::Backend::Base
|
751
|
+
include ::I18n::Backend::Simple::Implementation
|
752
|
+
end
|
753
|
+
|
754
|
+
module I18n::Backend::Simple::Implementation
|
755
|
+
include ::I18n::Backend::Transliterator
|
756
|
+
include ::I18n::Backend::Base
|
757
|
+
|
758
|
+
# Get available locales from the translations hash
|
759
|
+
def available_locales; end
|
760
|
+
|
761
|
+
def eager_load!; end
|
762
|
+
|
763
|
+
# @return [Boolean]
|
764
|
+
def initialized?; end
|
765
|
+
|
766
|
+
# Clean up translations hash and set initialized to false on reload!
|
767
|
+
def reload!; end
|
768
|
+
|
769
|
+
# Stores translations for the given locale in memory.
|
770
|
+
# This uses a deep merge for the translations hash, so existing
|
771
|
+
# translations will be overwritten by new ones only at the deepest
|
772
|
+
# level of the hash.
|
773
|
+
def store_translations(locale, data, options = T.unsafe(nil)); end
|
774
|
+
|
775
|
+
def translations(do_init: T.unsafe(nil)); end
|
776
|
+
|
777
|
+
protected
|
778
|
+
|
779
|
+
def init_translations; end
|
780
|
+
|
781
|
+
# Looks up a translation from the translations hash. Returns nil if
|
782
|
+
# either key is nil, or locale, scope or key do not exist as a key in the
|
783
|
+
# nested translations hash. Splits keys or scopes containing dots
|
784
|
+
# into multiple keys, i.e. <tt>currency.format</tt> is regarded the same as
|
785
|
+
# <tt>%w(currency format)</tt>.
|
786
|
+
def lookup(locale, key, scope = T.unsafe(nil), options = T.unsafe(nil)); end
|
787
|
+
end
|
788
|
+
|
789
|
+
module I18n::Backend::Transliterator
|
790
|
+
# Given a locale and a UTF-8 string, return the locale's ASCII
|
791
|
+
# approximation for the string.
|
792
|
+
def transliterate(locale, string, replacement = T.unsafe(nil)); end
|
793
|
+
|
794
|
+
class << self
|
795
|
+
# Get a transliterator instance.
|
796
|
+
def get(rule = T.unsafe(nil)); end
|
797
|
+
end
|
798
|
+
end
|
799
|
+
|
800
|
+
I18n::Backend::Transliterator::DEFAULT_REPLACEMENT_CHAR = T.let(T.unsafe(nil), String)
|
801
|
+
|
802
|
+
# A transliterator which accepts a Hash of characters as its translation
|
803
|
+
# rule.
|
804
|
+
class I18n::Backend::Transliterator::HashTransliterator
|
805
|
+
# @return [HashTransliterator] a new instance of HashTransliterator
|
806
|
+
def initialize(rule = T.unsafe(nil)); end
|
807
|
+
|
808
|
+
def transliterate(string, replacement = T.unsafe(nil)); end
|
809
|
+
|
810
|
+
private
|
811
|
+
|
812
|
+
# Add transliteration rules to the approximations hash.
|
813
|
+
def add(hash); end
|
814
|
+
|
815
|
+
def add_default_approximations; end
|
816
|
+
def approximations; end
|
817
|
+
end
|
818
|
+
|
819
|
+
I18n::Backend::Transliterator::HashTransliterator::DEFAULT_APPROXIMATIONS = T.let(T.unsafe(nil), Hash)
|
820
|
+
|
821
|
+
# A transliterator which accepts a Proc as its transliteration rule.
|
822
|
+
class I18n::Backend::Transliterator::ProcTransliterator
|
823
|
+
# @return [ProcTransliterator] a new instance of ProcTransliterator
|
824
|
+
def initialize(rule); end
|
825
|
+
|
826
|
+
def transliterate(string, replacement = T.unsafe(nil)); end
|
827
|
+
end
|
828
|
+
|
829
|
+
module I18n::Base
|
830
|
+
def available_locales; end
|
831
|
+
def available_locales=(value); end
|
832
|
+
|
833
|
+
# @return [Boolean]
|
834
|
+
def available_locales_initialized?; end
|
835
|
+
|
836
|
+
def backend; end
|
837
|
+
def backend=(value); end
|
838
|
+
|
839
|
+
# Gets I18n configuration object.
|
840
|
+
def config; end
|
841
|
+
|
842
|
+
# Sets I18n configuration object.
|
843
|
+
def config=(value); end
|
844
|
+
|
845
|
+
def default_locale; end
|
846
|
+
def default_locale=(value); end
|
847
|
+
def default_separator; end
|
848
|
+
def default_separator=(value); end
|
849
|
+
|
850
|
+
# Tells the backend to load translations now. Used in situations like the
|
851
|
+
# Rails production environment. Backends can implement whatever strategy
|
852
|
+
# is useful.
|
853
|
+
def eager_load!; end
|
854
|
+
|
855
|
+
def enforce_available_locales; end
|
856
|
+
|
857
|
+
# Raises an InvalidLocale exception when the passed locale is not available.
|
858
|
+
def enforce_available_locales!(locale); end
|
859
|
+
|
860
|
+
def enforce_available_locales=(value); end
|
861
|
+
def exception_handler; end
|
862
|
+
def exception_handler=(value); end
|
863
|
+
|
864
|
+
# Returns true if a translation exists for a given key, otherwise returns false.
|
865
|
+
#
|
866
|
+
# @raise [Disabled]
|
867
|
+
# @return [Boolean]
|
868
|
+
def exists?(key, _locale = T.unsafe(nil), locale: T.unsafe(nil), **options); end
|
869
|
+
|
870
|
+
# Localizes certain objects, such as dates and numbers to local formatting.
|
871
|
+
#
|
872
|
+
# @raise [Disabled]
|
873
|
+
def l(object, locale: T.unsafe(nil), format: T.unsafe(nil), **options); end
|
874
|
+
|
875
|
+
def load_path; end
|
876
|
+
def load_path=(value); end
|
877
|
+
def locale; end
|
878
|
+
def locale=(value); end
|
879
|
+
|
880
|
+
# Returns true when the passed locale, which can be either a String or a
|
881
|
+
# Symbol, is in the list of available locales. Returns false otherwise.
|
882
|
+
#
|
883
|
+
# @return [Boolean]
|
884
|
+
def locale_available?(locale); end
|
885
|
+
|
886
|
+
# Localizes certain objects, such as dates and numbers to local formatting.
|
887
|
+
#
|
888
|
+
# @raise [Disabled]
|
889
|
+
def localize(object, locale: T.unsafe(nil), format: T.unsafe(nil), **options); end
|
890
|
+
|
891
|
+
# Merges the given locale, key and scope into a single array of keys.
|
892
|
+
# Splits keys that contain dots into multiple keys. Makes sure all
|
893
|
+
# keys are Symbols.
|
894
|
+
def normalize_keys(locale, key, scope, separator = T.unsafe(nil)); end
|
895
|
+
|
896
|
+
# Tells the backend to reload translations. Used in situations like the
|
897
|
+
# Rails development environment. Backends can implement whatever strategy
|
898
|
+
# is useful.
|
899
|
+
def reload!; end
|
900
|
+
|
901
|
+
# Translates, pluralizes and interpolates a given key using a given locale,
|
902
|
+
# scope, and default, as well as interpolation values.
|
903
|
+
#
|
904
|
+
# *LOOKUP*
|
905
|
+
#
|
906
|
+
# Translation data is organized as a nested hash using the upper-level keys
|
907
|
+
# as namespaces. <em>E.g.</em>, ActionView ships with the translation:
|
908
|
+
# <tt>:date => {:formats => {:short => "%b %d"}}</tt>.
|
909
|
+
#
|
910
|
+
# Translations can be looked up at any level of this hash using the key argument
|
911
|
+
# and the scope option. <em>E.g.</em>, in this example <tt>I18n.t :date</tt>
|
912
|
+
# returns the whole translations hash <tt>{:formats => {:short => "%b %d"}}</tt>.
|
913
|
+
#
|
914
|
+
# Key can be either a single key or a dot-separated key (both Strings and Symbols
|
915
|
+
# work). <em>E.g.</em>, the short format can be looked up using both:
|
916
|
+
# I18n.t 'date.formats.short'
|
917
|
+
# I18n.t :'date.formats.short'
|
918
|
+
#
|
919
|
+
# Scope can be either a single key, a dot-separated key or an array of keys
|
920
|
+
# or dot-separated keys. Keys and scopes can be combined freely. So these
|
921
|
+
# examples will all look up the same short date format:
|
922
|
+
# I18n.t 'date.formats.short'
|
923
|
+
# I18n.t 'formats.short', :scope => 'date'
|
924
|
+
# I18n.t 'short', :scope => 'date.formats'
|
925
|
+
# I18n.t 'short', :scope => %w(date formats)
|
926
|
+
#
|
927
|
+
# *INTERPOLATION*
|
928
|
+
#
|
929
|
+
# Translations can contain interpolation variables which will be replaced by
|
930
|
+
# values passed to #translate as part of the options hash, with the keys matching
|
931
|
+
# the interpolation variable names.
|
932
|
+
#
|
933
|
+
# <em>E.g.</em>, with a translation <tt>:foo => "foo %{bar}"</tt> the option
|
934
|
+
# value for the key +bar+ will be interpolated into the translation:
|
935
|
+
# I18n.t :foo, :bar => 'baz' # => 'foo baz'
|
936
|
+
#
|
937
|
+
# *PLURALIZATION*
|
938
|
+
#
|
939
|
+
# Translation data can contain pluralized translations. Pluralized translations
|
940
|
+
# are arrays of singular/plural versions of translations like <tt>['Foo', 'Foos']</tt>.
|
941
|
+
#
|
942
|
+
# Note that <tt>I18n::Backend::Simple</tt> only supports an algorithm for English
|
943
|
+
# pluralization rules. Other algorithms can be supported by custom backends.
|
944
|
+
#
|
945
|
+
# This returns the singular version of a pluralized translation:
|
946
|
+
# I18n.t :foo, :count => 1 # => 'Foo'
|
947
|
+
#
|
948
|
+
# These both return the plural version of a pluralized translation:
|
949
|
+
# I18n.t :foo, :count => 0 # => 'Foos'
|
950
|
+
# I18n.t :foo, :count => 2 # => 'Foos'
|
951
|
+
#
|
952
|
+
# The <tt>:count</tt> option can be used both for pluralization and interpolation.
|
953
|
+
# <em>E.g.</em>, with the translation
|
954
|
+
# <tt>:foo => ['%{count} foo', '%{count} foos']</tt>, count will
|
955
|
+
# be interpolated to the pluralized translation:
|
956
|
+
# I18n.t :foo, :count => 1 # => '1 foo'
|
957
|
+
#
|
958
|
+
# *DEFAULTS*
|
959
|
+
#
|
960
|
+
# This returns the translation for <tt>:foo</tt> or <tt>default</tt> if no translation was found:
|
961
|
+
# I18n.t :foo, :default => 'default'
|
962
|
+
#
|
963
|
+
# This returns the translation for <tt>:foo</tt> or the translation for <tt>:bar</tt> if no
|
964
|
+
# translation for <tt>:foo</tt> was found:
|
965
|
+
# I18n.t :foo, :default => :bar
|
966
|
+
#
|
967
|
+
# Returns the translation for <tt>:foo</tt> or the translation for <tt>:bar</tt>
|
968
|
+
# or <tt>default</tt> if no translations for <tt>:foo</tt> and <tt>:bar</tt> were found.
|
969
|
+
# I18n.t :foo, :default => [:bar, 'default']
|
970
|
+
#
|
971
|
+
# *BULK LOOKUP*
|
972
|
+
#
|
973
|
+
# This returns an array with the translations for <tt>:foo</tt> and <tt>:bar</tt>.
|
974
|
+
# I18n.t [:foo, :bar]
|
975
|
+
#
|
976
|
+
# Can be used with dot-separated nested keys:
|
977
|
+
# I18n.t [:'baz.foo', :'baz.bar']
|
978
|
+
#
|
979
|
+
# Which is the same as using a scope option:
|
980
|
+
# I18n.t [:foo, :bar], :scope => :baz
|
981
|
+
#
|
982
|
+
# *LAMBDAS*
|
983
|
+
#
|
984
|
+
# Both translations and defaults can be given as Ruby lambdas. Lambdas will be
|
985
|
+
# called and passed the key and options.
|
986
|
+
#
|
987
|
+
# E.g. assuming the key <tt>:salutation</tt> resolves to:
|
988
|
+
# lambda { |key, options| options[:gender] == 'm' ? "Mr. #{options[:name]}" : "Mrs. #{options[:name]}" }
|
989
|
+
#
|
990
|
+
# Then <tt>I18n.t(:salutation, :gender => 'w', :name => 'Smith') will result in "Mrs. Smith".
|
991
|
+
#
|
992
|
+
# Note that the string returned by lambda will go through string interpolation too,
|
993
|
+
# so the following lambda would give the same result:
|
994
|
+
# lambda { |key, options| options[:gender] == 'm' ? "Mr. %{name}" : "Mrs. %{name}" }
|
995
|
+
#
|
996
|
+
# It is recommended to use/implement lambdas in an "idempotent" way. E.g. when
|
997
|
+
# a cache layer is put in front of I18n.translate it will generate a cache key
|
998
|
+
# from the argument values passed to #translate. Therefore your lambdas should
|
999
|
+
# always return the same translations/values per unique combination of argument
|
1000
|
+
# values.
|
1001
|
+
#
|
1002
|
+
# *Ruby 2.7+ keyword arguments warning*
|
1003
|
+
#
|
1004
|
+
# This method uses keyword arguments.
|
1005
|
+
# There is a breaking change in ruby that produces warning with ruby 2.7 and won't work as expected with ruby 3.0
|
1006
|
+
# The "hash" parameter must be passed as keyword argument.
|
1007
|
+
#
|
1008
|
+
# Good:
|
1009
|
+
# I18n.t(:salutation, :gender => 'w', :name => 'Smith')
|
1010
|
+
# I18n.t(:salutation, **{ :gender => 'w', :name => 'Smith' })
|
1011
|
+
# I18n.t(:salutation, **any_hash)
|
1012
|
+
#
|
1013
|
+
# Bad:
|
1014
|
+
# I18n.t(:salutation, { :gender => 'w', :name => 'Smith' })
|
1015
|
+
# I18n.t(:salutation, any_hash)
|
1016
|
+
#
|
1017
|
+
# @raise [Disabled]
|
1018
|
+
def t(key = T.unsafe(nil), throw: T.unsafe(nil), raise: T.unsafe(nil), locale: T.unsafe(nil), **options); end
|
1019
|
+
|
1020
|
+
# Wrapper for <tt>translate</tt> that adds <tt>:raise => true</tt>. With
|
1021
|
+
# this option, if no translation is found, it will raise <tt>I18n::MissingTranslationData</tt>
|
1022
|
+
def t!(key, **options); end
|
1023
|
+
|
1024
|
+
# Translates, pluralizes and interpolates a given key using a given locale,
|
1025
|
+
# scope, and default, as well as interpolation values.
|
1026
|
+
#
|
1027
|
+
# *LOOKUP*
|
1028
|
+
#
|
1029
|
+
# Translation data is organized as a nested hash using the upper-level keys
|
1030
|
+
# as namespaces. <em>E.g.</em>, ActionView ships with the translation:
|
1031
|
+
# <tt>:date => {:formats => {:short => "%b %d"}}</tt>.
|
1032
|
+
#
|
1033
|
+
# Translations can be looked up at any level of this hash using the key argument
|
1034
|
+
# and the scope option. <em>E.g.</em>, in this example <tt>I18n.t :date</tt>
|
1035
|
+
# returns the whole translations hash <tt>{:formats => {:short => "%b %d"}}</tt>.
|
1036
|
+
#
|
1037
|
+
# Key can be either a single key or a dot-separated key (both Strings and Symbols
|
1038
|
+
# work). <em>E.g.</em>, the short format can be looked up using both:
|
1039
|
+
# I18n.t 'date.formats.short'
|
1040
|
+
# I18n.t :'date.formats.short'
|
1041
|
+
#
|
1042
|
+
# Scope can be either a single key, a dot-separated key or an array of keys
|
1043
|
+
# or dot-separated keys. Keys and scopes can be combined freely. So these
|
1044
|
+
# examples will all look up the same short date format:
|
1045
|
+
# I18n.t 'date.formats.short'
|
1046
|
+
# I18n.t 'formats.short', :scope => 'date'
|
1047
|
+
# I18n.t 'short', :scope => 'date.formats'
|
1048
|
+
# I18n.t 'short', :scope => %w(date formats)
|
1049
|
+
#
|
1050
|
+
# *INTERPOLATION*
|
1051
|
+
#
|
1052
|
+
# Translations can contain interpolation variables which will be replaced by
|
1053
|
+
# values passed to #translate as part of the options hash, with the keys matching
|
1054
|
+
# the interpolation variable names.
|
1055
|
+
#
|
1056
|
+
# <em>E.g.</em>, with a translation <tt>:foo => "foo %{bar}"</tt> the option
|
1057
|
+
# value for the key +bar+ will be interpolated into the translation:
|
1058
|
+
# I18n.t :foo, :bar => 'baz' # => 'foo baz'
|
1059
|
+
#
|
1060
|
+
# *PLURALIZATION*
|
1061
|
+
#
|
1062
|
+
# Translation data can contain pluralized translations. Pluralized translations
|
1063
|
+
# are arrays of singular/plural versions of translations like <tt>['Foo', 'Foos']</tt>.
|
1064
|
+
#
|
1065
|
+
# Note that <tt>I18n::Backend::Simple</tt> only supports an algorithm for English
|
1066
|
+
# pluralization rules. Other algorithms can be supported by custom backends.
|
1067
|
+
#
|
1068
|
+
# This returns the singular version of a pluralized translation:
|
1069
|
+
# I18n.t :foo, :count => 1 # => 'Foo'
|
1070
|
+
#
|
1071
|
+
# These both return the plural version of a pluralized translation:
|
1072
|
+
# I18n.t :foo, :count => 0 # => 'Foos'
|
1073
|
+
# I18n.t :foo, :count => 2 # => 'Foos'
|
1074
|
+
#
|
1075
|
+
# The <tt>:count</tt> option can be used both for pluralization and interpolation.
|
1076
|
+
# <em>E.g.</em>, with the translation
|
1077
|
+
# <tt>:foo => ['%{count} foo', '%{count} foos']</tt>, count will
|
1078
|
+
# be interpolated to the pluralized translation:
|
1079
|
+
# I18n.t :foo, :count => 1 # => '1 foo'
|
1080
|
+
#
|
1081
|
+
# *DEFAULTS*
|
1082
|
+
#
|
1083
|
+
# This returns the translation for <tt>:foo</tt> or <tt>default</tt> if no translation was found:
|
1084
|
+
# I18n.t :foo, :default => 'default'
|
1085
|
+
#
|
1086
|
+
# This returns the translation for <tt>:foo</tt> or the translation for <tt>:bar</tt> if no
|
1087
|
+
# translation for <tt>:foo</tt> was found:
|
1088
|
+
# I18n.t :foo, :default => :bar
|
1089
|
+
#
|
1090
|
+
# Returns the translation for <tt>:foo</tt> or the translation for <tt>:bar</tt>
|
1091
|
+
# or <tt>default</tt> if no translations for <tt>:foo</tt> and <tt>:bar</tt> were found.
|
1092
|
+
# I18n.t :foo, :default => [:bar, 'default']
|
1093
|
+
#
|
1094
|
+
# *BULK LOOKUP*
|
1095
|
+
#
|
1096
|
+
# This returns an array with the translations for <tt>:foo</tt> and <tt>:bar</tt>.
|
1097
|
+
# I18n.t [:foo, :bar]
|
1098
|
+
#
|
1099
|
+
# Can be used with dot-separated nested keys:
|
1100
|
+
# I18n.t [:'baz.foo', :'baz.bar']
|
1101
|
+
#
|
1102
|
+
# Which is the same as using a scope option:
|
1103
|
+
# I18n.t [:foo, :bar], :scope => :baz
|
1104
|
+
#
|
1105
|
+
# *LAMBDAS*
|
1106
|
+
#
|
1107
|
+
# Both translations and defaults can be given as Ruby lambdas. Lambdas will be
|
1108
|
+
# called and passed the key and options.
|
1109
|
+
#
|
1110
|
+
# E.g. assuming the key <tt>:salutation</tt> resolves to:
|
1111
|
+
# lambda { |key, options| options[:gender] == 'm' ? "Mr. #{options[:name]}" : "Mrs. #{options[:name]}" }
|
1112
|
+
#
|
1113
|
+
# Then <tt>I18n.t(:salutation, :gender => 'w', :name => 'Smith') will result in "Mrs. Smith".
|
1114
|
+
#
|
1115
|
+
# Note that the string returned by lambda will go through string interpolation too,
|
1116
|
+
# so the following lambda would give the same result:
|
1117
|
+
# lambda { |key, options| options[:gender] == 'm' ? "Mr. %{name}" : "Mrs. %{name}" }
|
1118
|
+
#
|
1119
|
+
# It is recommended to use/implement lambdas in an "idempotent" way. E.g. when
|
1120
|
+
# a cache layer is put in front of I18n.translate it will generate a cache key
|
1121
|
+
# from the argument values passed to #translate. Therefore your lambdas should
|
1122
|
+
# always return the same translations/values per unique combination of argument
|
1123
|
+
# values.
|
1124
|
+
#
|
1125
|
+
# *Ruby 2.7+ keyword arguments warning*
|
1126
|
+
#
|
1127
|
+
# This method uses keyword arguments.
|
1128
|
+
# There is a breaking change in ruby that produces warning with ruby 2.7 and won't work as expected with ruby 3.0
|
1129
|
+
# The "hash" parameter must be passed as keyword argument.
|
1130
|
+
#
|
1131
|
+
# Good:
|
1132
|
+
# I18n.t(:salutation, :gender => 'w', :name => 'Smith')
|
1133
|
+
# I18n.t(:salutation, **{ :gender => 'w', :name => 'Smith' })
|
1134
|
+
# I18n.t(:salutation, **any_hash)
|
1135
|
+
#
|
1136
|
+
# Bad:
|
1137
|
+
# I18n.t(:salutation, { :gender => 'w', :name => 'Smith' })
|
1138
|
+
# I18n.t(:salutation, any_hash)
|
1139
|
+
#
|
1140
|
+
# @raise [Disabled]
|
1141
|
+
def translate(key = T.unsafe(nil), throw: T.unsafe(nil), raise: T.unsafe(nil), locale: T.unsafe(nil), **options); end
|
1142
|
+
|
1143
|
+
# Wrapper for <tt>translate</tt> that adds <tt>:raise => true</tt>. With
|
1144
|
+
# this option, if no translation is found, it will raise <tt>I18n::MissingTranslationData</tt>
|
1145
|
+
def translate!(key, **options); end
|
1146
|
+
|
1147
|
+
# Transliterates UTF-8 characters to ASCII. By default this method will
|
1148
|
+
# transliterate only Latin strings to an ASCII approximation:
|
1149
|
+
#
|
1150
|
+
# I18n.transliterate("Ærøskøbing")
|
1151
|
+
# # => "AEroskobing"
|
1152
|
+
#
|
1153
|
+
# I18n.transliterate("日本語")
|
1154
|
+
# # => "???"
|
1155
|
+
#
|
1156
|
+
# It's also possible to add support for per-locale transliterations. I18n
|
1157
|
+
# expects transliteration rules to be stored at
|
1158
|
+
# <tt>i18n.transliterate.rule</tt>.
|
1159
|
+
#
|
1160
|
+
# Transliteration rules can either be a Hash or a Proc. Procs must accept a
|
1161
|
+
# single string argument. Hash rules inherit the default transliteration
|
1162
|
+
# rules, while Procs do not.
|
1163
|
+
#
|
1164
|
+
# *Examples*
|
1165
|
+
#
|
1166
|
+
# Setting a Hash in <locale>.yml:
|
1167
|
+
#
|
1168
|
+
# i18n:
|
1169
|
+
# transliterate:
|
1170
|
+
# rule:
|
1171
|
+
# ü: "ue"
|
1172
|
+
# ö: "oe"
|
1173
|
+
#
|
1174
|
+
# Setting a Hash using Ruby:
|
1175
|
+
#
|
1176
|
+
# store_translations(:de, i18n: {
|
1177
|
+
# transliterate: {
|
1178
|
+
# rule: {
|
1179
|
+
# 'ü' => 'ue',
|
1180
|
+
# 'ö' => 'oe'
|
1181
|
+
# }
|
1182
|
+
# }
|
1183
|
+
# })
|
1184
|
+
#
|
1185
|
+
# Setting a Proc:
|
1186
|
+
#
|
1187
|
+
# translit = lambda {|string| MyTransliterator.transliterate(string) }
|
1188
|
+
# store_translations(:xx, :i18n => {:transliterate => {:rule => translit})
|
1189
|
+
#
|
1190
|
+
# Transliterating strings:
|
1191
|
+
#
|
1192
|
+
# I18n.locale = :en
|
1193
|
+
# I18n.transliterate("Jürgen") # => "Jurgen"
|
1194
|
+
# I18n.locale = :de
|
1195
|
+
# I18n.transliterate("Jürgen") # => "Juergen"
|
1196
|
+
# I18n.transliterate("Jürgen", :locale => :en) # => "Jurgen"
|
1197
|
+
# I18n.transliterate("Jürgen", :locale => :de) # => "Juergen"
|
1198
|
+
def transliterate(key, throw: T.unsafe(nil), raise: T.unsafe(nil), locale: T.unsafe(nil), replacement: T.unsafe(nil), **options); end
|
1199
|
+
|
1200
|
+
# Executes block with given I18n.locale set.
|
1201
|
+
def with_locale(tmp_locale = T.unsafe(nil)); end
|
1202
|
+
|
1203
|
+
private
|
1204
|
+
|
1205
|
+
# Any exceptions thrown in translate will be sent to the @@exception_handler
|
1206
|
+
# which can be a Symbol, a Proc or any other Object unless they're forced to
|
1207
|
+
# be raised or thrown (MissingTranslation).
|
1208
|
+
#
|
1209
|
+
# If exception_handler is a Symbol then it will simply be sent to I18n as
|
1210
|
+
# a method call. A Proc will simply be called. In any other case the
|
1211
|
+
# method #call will be called on the exception_handler object.
|
1212
|
+
#
|
1213
|
+
# Examples:
|
1214
|
+
#
|
1215
|
+
# I18n.exception_handler = :custom_exception_handler # this is the default
|
1216
|
+
# I18n.custom_exception_handler(exception, locale, key, options) # will be called like this
|
1217
|
+
#
|
1218
|
+
# I18n.exception_handler = lambda { |*args| ... } # a lambda
|
1219
|
+
# I18n.exception_handler.call(exception, locale, key, options) # will be called like this
|
1220
|
+
#
|
1221
|
+
# I18n.exception_handler = I18nExceptionHandler.new # an object
|
1222
|
+
# I18n.exception_handler.call(exception, locale, key, options) # will be called like this
|
1223
|
+
def handle_exception(handling, exception, locale, key, options); end
|
1224
|
+
|
1225
|
+
def normalize_key(key, separator); end
|
1226
|
+
def translate_key(key, throw, raise, locale, backend, options); end
|
1227
|
+
end
|
1228
|
+
|
1229
|
+
class I18n::Config
|
1230
|
+
# Returns an array of locales for which translations are available.
|
1231
|
+
# Unless you explicitly set these through I18n.available_locales=
|
1232
|
+
# the call will be delegated to the backend.
|
1233
|
+
def available_locales; end
|
1234
|
+
|
1235
|
+
# Sets the available locales.
|
1236
|
+
def available_locales=(locales); end
|
1237
|
+
|
1238
|
+
# Returns true if the available_locales have been initialized
|
1239
|
+
#
|
1240
|
+
# @return [Boolean]
|
1241
|
+
def available_locales_initialized?; end
|
1242
|
+
|
1243
|
+
# Caches the available locales list as both strings and symbols in a Set, so
|
1244
|
+
# that we can have faster lookups to do the available locales enforce check.
|
1245
|
+
def available_locales_set; end
|
1246
|
+
|
1247
|
+
# Returns the current backend. Defaults to +Backend::Simple+.
|
1248
|
+
def backend; end
|
1249
|
+
|
1250
|
+
# Sets the current backend. Used to set a custom backend.
|
1251
|
+
def backend=(backend); end
|
1252
|
+
|
1253
|
+
# Clears the available locales set so it can be recomputed again after I18n
|
1254
|
+
# gets reloaded.
|
1255
|
+
def clear_available_locales_set; end
|
1256
|
+
|
1257
|
+
# Returns the current default locale. Defaults to :'en'
|
1258
|
+
def default_locale; end
|
1259
|
+
|
1260
|
+
# Sets the current default locale. Used to set a custom default locale.
|
1261
|
+
def default_locale=(locale); end
|
1262
|
+
|
1263
|
+
# Returns the current default scope separator. Defaults to '.'
|
1264
|
+
def default_separator; end
|
1265
|
+
|
1266
|
+
# Sets the current default scope separator.
|
1267
|
+
def default_separator=(separator); end
|
1268
|
+
|
1269
|
+
def enforce_available_locales; end
|
1270
|
+
def enforce_available_locales=(enforce_available_locales); end
|
1271
|
+
|
1272
|
+
# Returns the current exception handler. Defaults to an instance of
|
1273
|
+
# I18n::ExceptionHandler.
|
1274
|
+
def exception_handler; end
|
1275
|
+
|
1276
|
+
# Sets the exception handler.
|
1277
|
+
def exception_handler=(exception_handler); end
|
1278
|
+
|
1279
|
+
# Returns the current interpolation patterns. Defaults to
|
1280
|
+
# I18n::DEFAULT_INTERPOLATION_PATTERNS.
|
1281
|
+
def interpolation_patterns; end
|
1282
|
+
|
1283
|
+
# Sets the current interpolation patterns. Used to set a interpolation
|
1284
|
+
# patterns.
|
1285
|
+
#
|
1286
|
+
# E.g. using {{}} as a placeholder like "{{hello}}, world!":
|
1287
|
+
#
|
1288
|
+
# I18n.config.interpolation_patterns << /\{\{(\w+)\}\}/
|
1289
|
+
def interpolation_patterns=(interpolation_patterns); end
|
1290
|
+
|
1291
|
+
# Allow clients to register paths providing translation data sources. The
|
1292
|
+
# backend defines acceptable sources.
|
1293
|
+
#
|
1294
|
+
# E.g. the provided SimpleBackend accepts a list of paths to translation
|
1295
|
+
# files which are either named *.rb and contain plain Ruby Hashes or are
|
1296
|
+
# named *.yml and contain YAML data. So for the SimpleBackend clients may
|
1297
|
+
# register translation files like this:
|
1298
|
+
# I18n.load_path << 'path/to/locale/en.yml'
|
1299
|
+
def load_path; end
|
1300
|
+
|
1301
|
+
# Sets the load path instance. Custom implementations are expected to
|
1302
|
+
# behave like a Ruby Array.
|
1303
|
+
def load_path=(load_path); end
|
1304
|
+
|
1305
|
+
# The only configuration value that is not global and scoped to thread is :locale.
|
1306
|
+
# It defaults to the default_locale.
|
1307
|
+
def locale; end
|
1308
|
+
|
1309
|
+
# Sets the current locale pseudo-globally, i.e. in the Thread.current hash.
|
1310
|
+
def locale=(locale); end
|
1311
|
+
|
1312
|
+
# Returns the current handler for situations when interpolation argument
|
1313
|
+
# is missing. MissingInterpolationArgument will be raised by default.
|
1314
|
+
def missing_interpolation_argument_handler; end
|
1315
|
+
|
1316
|
+
# Sets the missing interpolation argument handler. It can be any
|
1317
|
+
# object that responds to #call. The arguments that will be passed to #call
|
1318
|
+
# are the same as for MissingInterpolationArgument initializer. Use +Proc.new+
|
1319
|
+
# if you don't care about arity.
|
1320
|
+
#
|
1321
|
+
# == Example:
|
1322
|
+
# You can suppress raising an exception and return string instead:
|
1323
|
+
#
|
1324
|
+
# I18n.config.missing_interpolation_argument_handler = Proc.new do |key|
|
1325
|
+
# "#{key} is missing"
|
1326
|
+
# end
|
1327
|
+
def missing_interpolation_argument_handler=(exception_handler); end
|
1328
|
+
end
|
1329
|
+
|
1330
|
+
I18n::DEFAULT_INTERPOLATION_PATTERNS = T.let(T.unsafe(nil), Array)
|
1331
|
+
|
1332
|
+
class I18n::Disabled < ::I18n::ArgumentError
|
1333
|
+
# @return [Disabled] a new instance of Disabled
|
1334
|
+
def initialize(method); end
|
1335
|
+
end
|
1336
|
+
|
1337
|
+
I18n::EMPTY_HASH = T.let(T.unsafe(nil), Hash)
|
1338
|
+
|
1339
|
+
class I18n::ExceptionHandler
|
1340
|
+
def call(exception, _locale, _key, _options); end
|
1341
|
+
end
|
1342
|
+
|
1343
|
+
module I18n::Gettext
|
1344
|
+
class << self
|
1345
|
+
def extract_scope(msgid, separator); end
|
1346
|
+
|
1347
|
+
# returns an array of plural keys for the given locale or the whole hash
|
1348
|
+
# of locale mappings to plural keys so that we can convert from gettext's
|
1349
|
+
# integer-index based style
|
1350
|
+
# TODO move this information to the pluralization module
|
1351
|
+
def plural_keys(*args); end
|
1352
|
+
end
|
1353
|
+
end
|
1354
|
+
|
1355
|
+
I18n::Gettext::CONTEXT_SEPARATOR = T.let(T.unsafe(nil), String)
|
1356
|
+
|
1357
|
+
# Implements classical Gettext style accessors. To use this include the
|
1358
|
+
# module to the global namespace or wherever you want to use it.
|
1359
|
+
#
|
1360
|
+
# include I18n::Gettext::Helpers
|
1361
|
+
module I18n::Gettext::Helpers
|
1362
|
+
# Makes dynamic translation messages readable for the gettext parser.
|
1363
|
+
# <tt>_(fruit)</tt> cannot be understood by the gettext parser. To help the parser find all your translations,
|
1364
|
+
# you can add <tt>fruit = N_("Apple")</tt> which does not translate, but tells the parser: "Apple" needs translation.
|
1365
|
+
# * msgid: the message id.
|
1366
|
+
# * Returns: msgid.
|
1367
|
+
def N_(msgsid); end
|
1368
|
+
|
1369
|
+
def _(msgid, options = T.unsafe(nil)); end
|
1370
|
+
def gettext(msgid, options = T.unsafe(nil)); end
|
1371
|
+
def n_(msgid, msgid_plural, n = T.unsafe(nil)); end
|
1372
|
+
def ngettext(msgid, msgid_plural, n = T.unsafe(nil)); end
|
1373
|
+
|
1374
|
+
# Method signatures:
|
1375
|
+
# npgettext('Fruits', 'apple', 'apples', 2)
|
1376
|
+
# npgettext('Fruits', ['apple', 'apples'], 2)
|
1377
|
+
def np_(msgctxt, msgid, msgid_plural, n = T.unsafe(nil)); end
|
1378
|
+
|
1379
|
+
# Method signatures:
|
1380
|
+
# npgettext('Fruits', 'apple', 'apples', 2)
|
1381
|
+
# npgettext('Fruits', ['apple', 'apples'], 2)
|
1382
|
+
def npgettext(msgctxt, msgid, msgid_plural, n = T.unsafe(nil)); end
|
1383
|
+
|
1384
|
+
# Method signatures:
|
1385
|
+
# nsgettext('Fruits|apple', 'apples', 2)
|
1386
|
+
# nsgettext(['Fruits|apple', 'apples'], 2)
|
1387
|
+
def ns_(msgid, msgid_plural, n = T.unsafe(nil), separator = T.unsafe(nil)); end
|
1388
|
+
|
1389
|
+
# Method signatures:
|
1390
|
+
# nsgettext('Fruits|apple', 'apples', 2)
|
1391
|
+
# nsgettext(['Fruits|apple', 'apples'], 2)
|
1392
|
+
def nsgettext(msgid, msgid_plural, n = T.unsafe(nil), separator = T.unsafe(nil)); end
|
1393
|
+
|
1394
|
+
def p_(msgctxt, msgid); end
|
1395
|
+
def pgettext(msgctxt, msgid); end
|
1396
|
+
def s_(msgid, separator = T.unsafe(nil)); end
|
1397
|
+
def sgettext(msgid, separator = T.unsafe(nil)); end
|
1398
|
+
end
|
1399
|
+
|
1400
|
+
I18n::Gettext::PLURAL_SEPARATOR = T.let(T.unsafe(nil), String)
|
1401
|
+
I18n::INTERPOLATION_PATTERN = T.let(T.unsafe(nil), Regexp)
|
1402
|
+
|
1403
|
+
class I18n::InvalidFilenames < ::I18n::ArgumentError
|
1404
|
+
# @return [InvalidFilenames] a new instance of InvalidFilenames
|
1405
|
+
def initialize(file_errors); end
|
1406
|
+
end
|
1407
|
+
|
1408
|
+
I18n::InvalidFilenames::NUMBER_OF_ERRORS_SHOWN = T.let(T.unsafe(nil), Integer)
|
1409
|
+
|
1410
|
+
class I18n::InvalidLocale < ::I18n::ArgumentError
|
1411
|
+
# @return [InvalidLocale] a new instance of InvalidLocale
|
1412
|
+
def initialize(locale); end
|
1413
|
+
|
1414
|
+
# Returns the value of attribute locale.
|
1415
|
+
def locale; end
|
1416
|
+
end
|
1417
|
+
|
1418
|
+
class I18n::InvalidLocaleData < ::I18n::ArgumentError
|
1419
|
+
# @return [InvalidLocaleData] a new instance of InvalidLocaleData
|
1420
|
+
def initialize(filename, exception_message); end
|
1421
|
+
|
1422
|
+
# Returns the value of attribute filename.
|
1423
|
+
def filename; end
|
1424
|
+
end
|
1425
|
+
|
1426
|
+
class I18n::InvalidPluralizationData < ::I18n::ArgumentError
|
1427
|
+
# @return [InvalidPluralizationData] a new instance of InvalidPluralizationData
|
1428
|
+
def initialize(entry, count, key); end
|
1429
|
+
|
1430
|
+
# Returns the value of attribute count.
|
1431
|
+
def count; end
|
1432
|
+
|
1433
|
+
# Returns the value of attribute entry.
|
1434
|
+
def entry; end
|
1435
|
+
|
1436
|
+
# Returns the value of attribute key.
|
1437
|
+
def key; end
|
1438
|
+
end
|
1439
|
+
|
1440
|
+
I18n::JSON = ActiveSupport::JSON
|
1441
|
+
module I18n::Locale; end
|
1442
|
+
|
1443
|
+
class I18n::Locale::Fallbacks < ::Hash
|
1444
|
+
# @return [Fallbacks] a new instance of Fallbacks
|
1445
|
+
def initialize(*mappings); end
|
1446
|
+
|
1447
|
+
# @raise [InvalidLocale]
|
1448
|
+
def [](locale); end
|
1449
|
+
|
1450
|
+
# Returns the value of attribute defaults.
|
1451
|
+
def defaults; end
|
1452
|
+
|
1453
|
+
def defaults=(defaults); end
|
1454
|
+
def map(*args, &block); end
|
1455
|
+
|
1456
|
+
protected
|
1457
|
+
|
1458
|
+
def compute(tags, include_defaults = T.unsafe(nil), exclude = T.unsafe(nil)); end
|
1459
|
+
end
|
1460
|
+
|
1461
|
+
module I18n::Locale::Tag
|
1462
|
+
class << self
|
1463
|
+
# Returns the current locale tag implementation. Defaults to +I18n::Locale::Tag::Simple+.
|
1464
|
+
def implementation; end
|
1465
|
+
|
1466
|
+
# Sets the current locale tag implementation. Use this to set a different locale tag implementation.
|
1467
|
+
def implementation=(implementation); end
|
1468
|
+
|
1469
|
+
# Factory method for locale tags. Delegates to the current locale tag implementation.
|
1470
|
+
def tag(tag); end
|
1471
|
+
end
|
1472
|
+
end
|
1473
|
+
|
1474
|
+
module I18n::Locale::Tag::Parents
|
1475
|
+
def parent; end
|
1476
|
+
def parents; end
|
1477
|
+
def self_and_parents; end
|
1478
|
+
end
|
1479
|
+
|
1480
|
+
I18n::Locale::Tag::RFC4646_FORMATS = T.let(T.unsafe(nil), Hash)
|
1481
|
+
I18n::Locale::Tag::RFC4646_SUBTAGS = T.let(T.unsafe(nil), Array)
|
1482
|
+
|
1483
|
+
class I18n::Locale::Tag::Rfc4646 < ::Struct
|
1484
|
+
include ::I18n::Locale::Tag::Parents
|
1485
|
+
|
1486
|
+
def language; end
|
1487
|
+
def region; end
|
1488
|
+
def script; end
|
1489
|
+
def to_a; end
|
1490
|
+
def to_s; end
|
1491
|
+
def to_sym; end
|
1492
|
+
def variant; end
|
1493
|
+
|
1494
|
+
class << self
|
1495
|
+
def parser; end
|
1496
|
+
def parser=(parser); end
|
1497
|
+
|
1498
|
+
# Parses the given tag and returns a Tag instance if it is valid.
|
1499
|
+
# Returns false if the given tag is not valid according to RFC 4646.
|
1500
|
+
def tag(tag); end
|
1501
|
+
end
|
1502
|
+
end
|
1503
|
+
|
1504
|
+
module I18n::Locale::Tag::Rfc4646::Parser
|
1505
|
+
class << self
|
1506
|
+
def match(tag); end
|
1507
|
+
end
|
1508
|
+
end
|
1509
|
+
|
1510
|
+
I18n::Locale::Tag::Rfc4646::Parser::PATTERN = T.let(T.unsafe(nil), Regexp)
|
1511
|
+
|
1512
|
+
class I18n::Locale::Tag::Simple
|
1513
|
+
include ::I18n::Locale::Tag::Parents
|
1514
|
+
|
1515
|
+
# @return [Simple] a new instance of Simple
|
1516
|
+
def initialize(*tag); end
|
1517
|
+
|
1518
|
+
def subtags; end
|
1519
|
+
|
1520
|
+
# Returns the value of attribute tag.
|
1521
|
+
def tag; end
|
1522
|
+
|
1523
|
+
def to_a; end
|
1524
|
+
def to_s; end
|
1525
|
+
def to_sym; end
|
1526
|
+
|
1527
|
+
class << self
|
1528
|
+
def tag(tag); end
|
1529
|
+
end
|
1530
|
+
end
|
1531
|
+
|
1532
|
+
class I18n::Middleware
|
1533
|
+
# @return [Middleware] a new instance of Middleware
|
1534
|
+
def initialize(app); end
|
1535
|
+
|
1536
|
+
def call(env); end
|
1537
|
+
end
|
1538
|
+
|
1539
|
+
class I18n::MissingInterpolationArgument < ::I18n::ArgumentError
|
1540
|
+
# @return [MissingInterpolationArgument] a new instance of MissingInterpolationArgument
|
1541
|
+
def initialize(key, values, string); end
|
1542
|
+
|
1543
|
+
# Returns the value of attribute key.
|
1544
|
+
def key; end
|
1545
|
+
|
1546
|
+
# Returns the value of attribute string.
|
1547
|
+
def string; end
|
1548
|
+
|
1549
|
+
# Returns the value of attribute values.
|
1550
|
+
def values; end
|
1551
|
+
end
|
1552
|
+
|
1553
|
+
class I18n::MissingTranslation < ::I18n::ArgumentError
|
1554
|
+
include ::I18n::MissingTranslation::Base
|
1555
|
+
end
|
1556
|
+
|
1557
|
+
module I18n::MissingTranslation::Base
|
1558
|
+
def initialize(locale, key, options = T.unsafe(nil)); end
|
1559
|
+
|
1560
|
+
# Returns the value of attribute key.
|
1561
|
+
def key; end
|
1562
|
+
|
1563
|
+
def keys; end
|
1564
|
+
|
1565
|
+
# Returns the value of attribute locale.
|
1566
|
+
def locale; end
|
1567
|
+
|
1568
|
+
def message; end
|
1569
|
+
|
1570
|
+
# Returns the value of attribute options.
|
1571
|
+
def options; end
|
1572
|
+
|
1573
|
+
def to_exception; end
|
1574
|
+
def to_s; end
|
1575
|
+
end
|
1576
|
+
|
1577
|
+
I18n::MissingTranslation::Base::PERMITTED_KEYS = T.let(T.unsafe(nil), Array)
|
1578
|
+
|
1579
|
+
class I18n::MissingTranslationData < ::I18n::ArgumentError
|
1580
|
+
include ::I18n::MissingTranslation::Base
|
1581
|
+
end
|
1582
|
+
|
1583
|
+
I18n::RESERVED_KEYS = T.let(T.unsafe(nil), Array)
|
1584
|
+
|
1585
|
+
class I18n::ReservedInterpolationKey < ::I18n::ArgumentError
|
1586
|
+
# @return [ReservedInterpolationKey] a new instance of ReservedInterpolationKey
|
1587
|
+
def initialize(key, string); end
|
1588
|
+
|
1589
|
+
# Returns the value of attribute key.
|
1590
|
+
def key; end
|
1591
|
+
|
1592
|
+
# Returns the value of attribute string.
|
1593
|
+
def string; end
|
1594
|
+
end
|
1595
|
+
|
1596
|
+
module I18n::Tests; end
|
1597
|
+
|
1598
|
+
module I18n::Tests::Localization
|
1599
|
+
class << self
|
1600
|
+
# @private
|
1601
|
+
def included(base); end
|
1602
|
+
end
|
1603
|
+
end
|
1604
|
+
|
1605
|
+
class I18n::UnknownFileType < ::I18n::ArgumentError
|
1606
|
+
# @return [UnknownFileType] a new instance of UnknownFileType
|
1607
|
+
def initialize(type, filename); end
|
1608
|
+
|
1609
|
+
# Returns the value of attribute filename.
|
1610
|
+
def filename; end
|
1611
|
+
|
1612
|
+
# Returns the value of attribute type.
|
1613
|
+
def type; end
|
1614
|
+
end
|
1615
|
+
|
1616
|
+
class I18n::UnsupportedMethod < ::I18n::ArgumentError
|
1617
|
+
# @return [UnsupportedMethod] a new instance of UnsupportedMethod
|
1618
|
+
def initialize(method, backend_klass, msg); end
|
1619
|
+
|
1620
|
+
# Returns the value of attribute backend_klass.
|
1621
|
+
def backend_klass; end
|
1622
|
+
|
1623
|
+
# Returns the value of attribute method.
|
1624
|
+
def method; end
|
1625
|
+
|
1626
|
+
# Returns the value of attribute msg.
|
1627
|
+
def msg; end
|
1628
|
+
end
|
1629
|
+
|
1630
|
+
module I18n::Utils
|
1631
|
+
class << self
|
1632
|
+
def deep_merge(hash, other_hash, &block); end
|
1633
|
+
def deep_merge!(hash, other_hash, &block); end
|
1634
|
+
def deep_symbolize_keys(hash); end
|
1635
|
+
def except(hash, *keys); end
|
1636
|
+
|
1637
|
+
private
|
1638
|
+
|
1639
|
+
def deep_symbolize_keys_in_object(value); end
|
1640
|
+
end
|
1641
|
+
end
|
1642
|
+
|
1643
|
+
I18n::VERSION = T.let(T.unsafe(nil), String)
|