rosetta-rails 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +8 -0
- data/app/assets/builds/rosetta/application.css +1 -0
- data/app/assets/builds/rosetta/application.js +8290 -0
- data/app/assets/config/rosetta_manifest.js +2 -0
- data/app/assets/javascripts/rosetta/application.js +2 -0
- data/app/assets/javascripts/rosetta/controllers/application.js +9 -0
- data/app/assets/javascripts/rosetta/controllers/dialog_controller.js +40 -0
- data/app/assets/javascripts/rosetta/controllers/index.js +4 -0
- data/app/assets/stylesheets/rosetta/application.css +49 -0
- data/app/controllers/concerns/rosetta/locale_scoped.rb +16 -0
- data/app/controllers/rosetta/application_controller.rb +5 -0
- data/app/controllers/rosetta/locales/deploys_controller.rb +12 -0
- data/app/controllers/rosetta/locales/translations/missing_controller.rb +9 -0
- data/app/controllers/rosetta/locales/translations_controller.rb +17 -0
- data/app/controllers/rosetta/locales_controller.rb +31 -0
- data/app/controllers/rosetta/translations_controller.rb +35 -0
- data/app/helpers/rosetta/application_helper.rb +7 -0
- data/app/helpers/rosetta/dialog_helper.rb +11 -0
- data/app/helpers/rosetta/navigation_helper.rb +21 -0
- data/app/helpers/rosetta/translation_helper.rb +9 -0
- data/app/jobs/rosetta/application_job.rb +4 -0
- data/app/mailers/rosetta/application_mailer.rb +6 -0
- data/app/models/rosetta/application_record.rb +5 -0
- data/app/models/rosetta/locale.rb +31 -0
- data/app/models/rosetta/translation.rb +6 -0
- data/app/models/rosetta/translation_key.rb +7 -0
- data/app/views/layouts/rosetta/_dialog.html.erb +25 -0
- data/app/views/layouts/rosetta/_flashes.html.erb +7 -0
- data/app/views/layouts/rosetta/_navbar.html.erb +7 -0
- data/app/views/layouts/rosetta/application.html.erb +25 -0
- data/app/views/rosetta/locales/_form.html.erb +33 -0
- data/app/views/rosetta/locales/_locale.html.erb +19 -0
- data/app/views/rosetta/locales/index.html.erb +31 -0
- data/app/views/rosetta/locales/new.html.erb +4 -0
- data/app/views/rosetta/locales/translations/_navigation.html.erb +14 -0
- data/app/views/rosetta/locales/translations/_translation_key.html.erb +14 -0
- data/app/views/rosetta/locales/translations/index.html.erb +52 -0
- data/app/views/rosetta/translations/edit.html.erb +21 -0
- data/config/initializers/pagy.rb +220 -0
- data/config/routes.rb +18 -0
- data/db/migrate/20240830123523_create_rosetta_tables.rb +33 -0
- data/lib/rosetta/configuration.rb +17 -0
- data/lib/rosetta/engine.rb +12 -0
- data/lib/rosetta/locale_session.rb +16 -0
- data/lib/rosetta/store.rb +75 -0
- data/lib/rosetta/version.rb +3 -0
- data/lib/rosetta-rails.rb +48 -0
- data/lib/tasks/rosetta_tasks.rake +4 -0
- metadata +163 -0
@@ -0,0 +1,220 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Pagy initializer file (9.0.9)
|
4
|
+
# Customize only what you really need and notice that the core Pagy works also without any of the following lines.
|
5
|
+
# Should you just cherry pick part of this file, please maintain the require-order of the extras
|
6
|
+
|
7
|
+
|
8
|
+
# Pagy Variables
|
9
|
+
# See https://ddnexus.github.io/pagy/docs/api/pagy#variables
|
10
|
+
# You can set any pagy variable as a Pagy::DEFAULT. They can also be overridden per instance by just passing them to
|
11
|
+
# Pagy.new|Pagy::Countless.new|Pagy::Calendar::*.new or any of the #pagy* controller methods
|
12
|
+
# Here are the few that make more sense as DEFAULTs:
|
13
|
+
# Pagy::DEFAULT[:limit] = 20 # default
|
14
|
+
# Pagy::DEFAULT[:size] = 7 # default
|
15
|
+
# Pagy::DEFAULT[:ends] = true # default
|
16
|
+
# Pagy::DEFAULT[:page_param] = :page # default
|
17
|
+
# Pagy::DEFAULT[:count_args] = [] # example for non AR ORMs
|
18
|
+
# Pagy::DEFAULT[:max_pages] = 3000 # example
|
19
|
+
|
20
|
+
|
21
|
+
# Extras
|
22
|
+
# See https://ddnexus.github.io/pagy/categories/extra
|
23
|
+
|
24
|
+
|
25
|
+
# Legacy Compatibility Extras
|
26
|
+
|
27
|
+
# Size extra: Enable the Array type for the `:size` variable (e.g. `size: [1,4,4,1]`)
|
28
|
+
# See https://ddnexus.github.io/pagy/docs/extras/size
|
29
|
+
# require 'pagy/extras/size' # must be required before the other extras
|
30
|
+
|
31
|
+
|
32
|
+
# Backend Extras
|
33
|
+
|
34
|
+
# Arel extra: For better performance utilizing grouped ActiveRecord collections:
|
35
|
+
# See: https://ddnexus.github.io/pagy/docs/extras/arel
|
36
|
+
# require 'pagy/extras/arel'
|
37
|
+
|
38
|
+
# Array extra: Paginate arrays efficiently, avoiding expensive array-wrapping and without overriding
|
39
|
+
# See https://ddnexus.github.io/pagy/docs/extras/array
|
40
|
+
# require 'pagy/extras/array'
|
41
|
+
|
42
|
+
# Calendar extra: Add pagination filtering by calendar time unit (year, quarter, month, week, day)
|
43
|
+
# See https://ddnexus.github.io/pagy/docs/extras/calendar
|
44
|
+
# require 'pagy/extras/calendar'
|
45
|
+
# Default for each calendar unit class in IRB:
|
46
|
+
# >> Pagy::Calendar::Year::DEFAULT
|
47
|
+
# >> Pagy::Calendar::Quarter::DEFAULT
|
48
|
+
# >> Pagy::Calendar::Month::DEFAULT
|
49
|
+
# >> Pagy::Calendar::Week::DEFAULT
|
50
|
+
# >> Pagy::Calendar::Day::DEFAULT
|
51
|
+
#
|
52
|
+
# Uncomment the following lines, if you need calendar localization without using the I18n extra
|
53
|
+
# module LocalizePagyCalendar
|
54
|
+
# def localize(time, opts)
|
55
|
+
# ::I18n.l(time, **opts)
|
56
|
+
# end
|
57
|
+
# end
|
58
|
+
# Pagy::Calendar.prepend LocalizePagyCalendar
|
59
|
+
|
60
|
+
# Countless extra: Paginate without any count, saving one query per rendering
|
61
|
+
# See https://ddnexus.github.io/pagy/docs/extras/countless
|
62
|
+
# require 'pagy/extras/countless'
|
63
|
+
# Pagy::DEFAULT[:countless_minimal] = false # default (eager loading)
|
64
|
+
|
65
|
+
# Elasticsearch Rails extra: Paginate `ElasticsearchRails::Results` objects
|
66
|
+
# See https://ddnexus.github.io/pagy/docs/extras/elasticsearch_rails
|
67
|
+
# Default :pagy_search method: change only if you use also
|
68
|
+
# the searchkick or meilisearch extra that defines the same
|
69
|
+
# Pagy::DEFAULT[:elasticsearch_rails_pagy_search] = :pagy_search
|
70
|
+
# Default original :search method called internally to do the actual search
|
71
|
+
# Pagy::DEFAULT[:elasticsearch_rails_search] = :search
|
72
|
+
# require 'pagy/extras/elasticsearch_rails'
|
73
|
+
|
74
|
+
# Headers extra: http response headers (and other helpers) useful for API pagination
|
75
|
+
# See http://ddnexus.github.io/pagy/extras/headers
|
76
|
+
# require 'pagy/extras/headers'
|
77
|
+
# Pagy::DEFAULT[:headers] = { page: 'Current-Page',
|
78
|
+
# limit: 'Page-Items',
|
79
|
+
# count: 'Total-Count',
|
80
|
+
# pages: 'Total-Pages' } # default
|
81
|
+
|
82
|
+
# Keyset extra: Paginate with the Pagy keyset pagination technique
|
83
|
+
# See http://ddnexus.github.io/pagy/extras/keyset
|
84
|
+
# require 'pagy/extras/keyset'
|
85
|
+
|
86
|
+
# Meilisearch extra: Paginate `Meilisearch` result objects
|
87
|
+
# See https://ddnexus.github.io/pagy/docs/extras/meilisearch
|
88
|
+
# Default :pagy_search method: change only if you use also
|
89
|
+
# the elasticsearch_rails or searchkick extra that define the same method
|
90
|
+
# Pagy::DEFAULT[:meilisearch_pagy_search] = :pagy_search
|
91
|
+
# Default original :search method called internally to do the actual search
|
92
|
+
# Pagy::DEFAULT[:meilisearch_search] = :ms_search
|
93
|
+
# require 'pagy/extras/meilisearch'
|
94
|
+
|
95
|
+
# Metadata extra: Provides the pagination metadata to Javascript frameworks like Vue.js, react.js, etc.
|
96
|
+
# See https://ddnexus.github.io/pagy/docs/extras/metadata
|
97
|
+
# you must require the JS Tools internal extra (BEFORE the metadata extra) ONLY if you need also the :sequels
|
98
|
+
# require 'pagy/extras/js_tools'
|
99
|
+
# require 'pagy/extras/metadata'
|
100
|
+
# For performance reasons, you should explicitly set ONLY the metadata you use in the frontend
|
101
|
+
# Pagy::DEFAULT[:metadata] = %i[scaffold_url page prev next last] # example
|
102
|
+
|
103
|
+
# Searchkick extra: Paginate `Searchkick::Results` objects
|
104
|
+
# See https://ddnexus.github.io/pagy/docs/extras/searchkick
|
105
|
+
# Default :pagy_search method: change only if you use also
|
106
|
+
# the elasticsearch_rails or meilisearch extra that defines the same
|
107
|
+
# Pagy::DEFAULT[:searchkick_pagy_search] = :pagy_search
|
108
|
+
# Default original :search method called internally to do the actual search
|
109
|
+
# Pagy::DEFAULT[:searchkick_search] = :search
|
110
|
+
# require 'pagy/extras/searchkick'
|
111
|
+
# uncomment if you are going to use Searchkick.pagy_search
|
112
|
+
# Searchkick.extend Pagy::Searchkick
|
113
|
+
|
114
|
+
|
115
|
+
# Frontend Extras
|
116
|
+
|
117
|
+
# Bootstrap extra: Add nav, nav_js and combo_nav_js helpers and templates for Bootstrap pagination
|
118
|
+
# See https://ddnexus.github.io/pagy/docs/extras/bootstrap
|
119
|
+
# require 'pagy/extras/bootstrap'
|
120
|
+
|
121
|
+
# Bulma extra: Add nav, nav_js and combo_nav_js helpers and templates for Bulma pagination
|
122
|
+
# See https://ddnexus.github.io/pagy/docs/extras/bulma
|
123
|
+
# require 'pagy/extras/bulma'
|
124
|
+
|
125
|
+
# Pagy extra: Add the pagy styled versions of the javascript-powered navs
|
126
|
+
# and a few other components to the Pagy::Frontend module.
|
127
|
+
# See https://ddnexus.github.io/pagy/docs/extras/pagy
|
128
|
+
# require 'pagy/extras/pagy'
|
129
|
+
|
130
|
+
# Multi size var used by the *_nav_js helpers
|
131
|
+
# See https://ddnexus.github.io/pagy/docs/extras/pagy#steps
|
132
|
+
# Pagy::DEFAULT[:steps] = { 0 => 5, 540 => 7, 720 => 9 } # example
|
133
|
+
|
134
|
+
|
135
|
+
# Feature Extras
|
136
|
+
|
137
|
+
# Gearbox extra: Automatically change the limit per page depending on the page number
|
138
|
+
# See https://ddnexus.github.io/pagy/docs/extras/gearbox
|
139
|
+
# require 'pagy/extras/gearbox'
|
140
|
+
# set to false only if you want to make :gearbox_extra an opt-in variable
|
141
|
+
# Pagy::DEFAULT[:gearbox_extra] = false # default true
|
142
|
+
# Pagy::DEFAULT[:gearbox_limit] = [15, 30, 60, 100] # default
|
143
|
+
|
144
|
+
# Limit extra: Allow the client to request a custom limit per page with an optional selector UI
|
145
|
+
# See https://ddnexus.github.io/pagy/docs/extras/limit
|
146
|
+
# require 'pagy/extras/limit'
|
147
|
+
# set to false only if you want to make :limit_extra an opt-in variable
|
148
|
+
# Pagy::DEFAULT[:limit_extra] = false # default true
|
149
|
+
# Pagy::DEFAULT[:limit_param] = :limit # default
|
150
|
+
# Pagy::DEFAULT[:limit_max] = 100 # default
|
151
|
+
|
152
|
+
# Overflow extra: Allow for easy handling of overflowing pages
|
153
|
+
# See https://ddnexus.github.io/pagy/docs/extras/overflow
|
154
|
+
# require 'pagy/extras/overflow'
|
155
|
+
# Pagy::DEFAULT[:overflow] = :empty_page # default (other options: :last_page and :exception)
|
156
|
+
|
157
|
+
# Trim extra: Remove the page=1 param from links
|
158
|
+
# See https://ddnexus.github.io/pagy/docs/extras/trim
|
159
|
+
# require 'pagy/extras/trim'
|
160
|
+
# set to false only if you want to make :trim_extra an opt-in variable
|
161
|
+
# Pagy::DEFAULT[:trim_extra] = false # default true
|
162
|
+
|
163
|
+
# Standalone extra: Use pagy in non Rack environment/gem
|
164
|
+
# See https://ddnexus.github.io/pagy/docs/extras/standalone
|
165
|
+
# require 'pagy/extras/standalone'
|
166
|
+
# Pagy::DEFAULT[:url] = 'http://www.example.com/subdir' # optional default
|
167
|
+
|
168
|
+
# Jsonapi extra: Implements JSON:API specifications
|
169
|
+
# See https://ddnexus.github.io/pagy/docs/extras/jsonapi
|
170
|
+
# require 'pagy/extras/jsonapi' # must be required after the other extras
|
171
|
+
# set to false only if you want to make :jsonapi an opt-in variable
|
172
|
+
# Pagy::DEFAULT[:jsonapi] = false # default true
|
173
|
+
|
174
|
+
# Rails
|
175
|
+
# Enable the .js file required by the helpers that use javascript
|
176
|
+
# (pagy*_nav_js, pagy*_combo_nav_js, and pagy_limit_selector_js)
|
177
|
+
# See https://ddnexus.github.io/pagy/docs/api/javascript
|
178
|
+
|
179
|
+
# With the asset pipeline
|
180
|
+
# Sprockets need to look into the pagy javascripts dir, so add it to the assets paths
|
181
|
+
# Rails.application.config.assets.paths << Pagy.root.join('javascripts')
|
182
|
+
|
183
|
+
# I18n
|
184
|
+
|
185
|
+
# Pagy internal I18n: ~18x faster using ~10x less memory than the i18n gem
|
186
|
+
# See https://ddnexus.github.io/pagy/docs/api/i18n
|
187
|
+
# Notice: No need to configure anything in this section if your app uses only "en"
|
188
|
+
# or if you use the i18n extra below
|
189
|
+
#
|
190
|
+
# Examples:
|
191
|
+
# load the "de" built-in locale:
|
192
|
+
# Pagy::I18n.load(locale: 'de')
|
193
|
+
#
|
194
|
+
# load the "de" locale defined in the custom file at :filepath:
|
195
|
+
# Pagy::I18n.load(locale: 'de', filepath: 'path/to/pagy-de.yml')
|
196
|
+
#
|
197
|
+
# load the "de", "en" and "es" built-in locales:
|
198
|
+
# (the first passed :locale will be used also as the default_locale)
|
199
|
+
# Pagy::I18n.load({ locale: 'de' },
|
200
|
+
# { locale: 'en' },
|
201
|
+
# { locale: 'es' })
|
202
|
+
#
|
203
|
+
# load the "en" built-in locale, a custom "es" locale,
|
204
|
+
# and a totally custom locale complete with a custom :pluralize proc:
|
205
|
+
# (the first passed :locale will be used also as the default_locale)
|
206
|
+
# Pagy::I18n.load({ locale: 'en' },
|
207
|
+
# { locale: 'es', filepath: 'path/to/pagy-es.yml' },
|
208
|
+
# { locale: 'xyz', # not built-in
|
209
|
+
# filepath: 'path/to/pagy-xyz.yml',
|
210
|
+
# pluralize: lambda{ |count| ... } )
|
211
|
+
|
212
|
+
|
213
|
+
# I18n extra: uses the standard i18n gem which is ~18x slower using ~10x more memory
|
214
|
+
# than the default pagy internal i18n (see above)
|
215
|
+
# See https://ddnexus.github.io/pagy/docs/extras/i18n
|
216
|
+
# require 'pagy/extras/i18n'
|
217
|
+
|
218
|
+
|
219
|
+
# When you are done setting your own default freeze it, so it will not get changed accidentally
|
220
|
+
Pagy::DEFAULT.freeze
|
data/config/routes.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Rosetta::Engine.routes.draw do
|
2
|
+
root to: "locales#index"
|
3
|
+
|
4
|
+
resources :locales do
|
5
|
+
scope module: :locales do
|
6
|
+
resources :translations, only: :index
|
7
|
+
resources :deploys, only: :create
|
8
|
+
|
9
|
+
namespace :translations do
|
10
|
+
resources :missing, only: :index
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
resources :translation_keys do
|
16
|
+
resource :translation, only: %i[edit update]
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class CreateRosettaTables < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :rosetta_locales do |t|
|
4
|
+
t.string :name
|
5
|
+
t.string :code
|
6
|
+
t.boolean :published, default: false
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
|
10
|
+
t.index :code, unique: true
|
11
|
+
end
|
12
|
+
|
13
|
+
create_table :rosetta_translation_keys do |t|
|
14
|
+
t.text :value
|
15
|
+
|
16
|
+
t.timestamps
|
17
|
+
|
18
|
+
t.index :value, unique: true
|
19
|
+
end
|
20
|
+
|
21
|
+
create_table :rosetta_translations do |t|
|
22
|
+
t.text :value
|
23
|
+
t.references :locale, null: false
|
24
|
+
t.references :translation_key, null: false
|
25
|
+
|
26
|
+
t.timestamps
|
27
|
+
|
28
|
+
t.index [ :locale_id, :translation_key_id ], unique: true
|
29
|
+
t.foreign_key :rosetta_locales, column: :locale_id
|
30
|
+
t.foreign_key :rosetta_translation_keys, column: :translation_key_id
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Rosetta
|
2
|
+
class Configuration
|
3
|
+
attr_reader :default_locale
|
4
|
+
attr_accessor :parent_controller_class
|
5
|
+
|
6
|
+
DefaultLocale = Struct.new(:name, :code)
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
set_default_locale(name: "English", code: "en")
|
10
|
+
@parent_controller_class = "ActionController::Base"
|
11
|
+
end
|
12
|
+
|
13
|
+
def set_default_locale(name:, code:)
|
14
|
+
@default_locale = DefaultLocale.new(name, code)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Rosetta
|
2
|
+
class LocaleSession
|
3
|
+
def locale
|
4
|
+
@locale ||= Locale.default_locale
|
5
|
+
end
|
6
|
+
|
7
|
+
def locale=(value)
|
8
|
+
case value
|
9
|
+
when Locale
|
10
|
+
@locale = value
|
11
|
+
when String, Symbol
|
12
|
+
@locale = Locale.find_by(code: value) || Locale.default_locale
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Rosetta
|
2
|
+
class Store
|
3
|
+
class_attribute :locale_stores, default: Concurrent::Map.new
|
4
|
+
|
5
|
+
attr_reader :locale, :cache_expiration_timestamp
|
6
|
+
|
7
|
+
def self.for_locale(locale)
|
8
|
+
store = locale_stores[locale.code.to_sym] ||= new(locale)
|
9
|
+
store.touch!(locale.updated_at)
|
10
|
+
store
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(locale)
|
14
|
+
@locale = locale
|
15
|
+
@cache_expiration_timestamp = @locale.updated_at
|
16
|
+
@autodiscovery_queue = Queue.new
|
17
|
+
|
18
|
+
start_key_autodiscovery!
|
19
|
+
end
|
20
|
+
|
21
|
+
def lookup(key_value)
|
22
|
+
if translations.has_key?(key_value)
|
23
|
+
translations[key_value]
|
24
|
+
else
|
25
|
+
@autodiscovery_queue << key_value
|
26
|
+
# Set the key in the translations store to locate it
|
27
|
+
# once only.
|
28
|
+
translations[key_value] = nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def reload!
|
33
|
+
@translations = nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def touch!(timestamp)
|
37
|
+
return if @cache_expiration_timestamp == timestamp
|
38
|
+
|
39
|
+
@cache_expiration_timestamp = timestamp
|
40
|
+
reload!
|
41
|
+
end
|
42
|
+
|
43
|
+
def translations
|
44
|
+
@translations ||= load_translations
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def load_translations
|
50
|
+
loaded_translations = Rosetta.with_locale(@locale) do
|
51
|
+
TranslationKey
|
52
|
+
.includes(:translation_in_current_locale)
|
53
|
+
.map do |translation_key|
|
54
|
+
[ translation_key.value, translation_key.translation_in_current_locale&.value ]
|
55
|
+
end.to_h
|
56
|
+
end
|
57
|
+
|
58
|
+
Concurrent::Hash.new.merge(loaded_translations)
|
59
|
+
end
|
60
|
+
|
61
|
+
def start_key_autodiscovery!
|
62
|
+
Thread.new do
|
63
|
+
Thread.current.name = "Rosetta #{locale.code} store thread"
|
64
|
+
|
65
|
+
loop do
|
66
|
+
key_value = @autodiscovery_queue.pop
|
67
|
+
|
68
|
+
unless TranslationKey.exists?(value: key_value)
|
69
|
+
TranslationKey.create!(value: key_value)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "rosetta/version"
|
2
|
+
require "rosetta/engine"
|
3
|
+
|
4
|
+
require "rosetta/locale_session"
|
5
|
+
require "rosetta/store"
|
6
|
+
require "rosetta/configuration"
|
7
|
+
|
8
|
+
module Rosetta
|
9
|
+
module Base
|
10
|
+
def locale
|
11
|
+
locale_session.locale
|
12
|
+
end
|
13
|
+
|
14
|
+
def locale=(code)
|
15
|
+
locale_session.locale = code
|
16
|
+
end
|
17
|
+
|
18
|
+
def with_locale(locale, &block)
|
19
|
+
locale_was = Rosetta.locale
|
20
|
+
self.locale = locale
|
21
|
+
|
22
|
+
begin
|
23
|
+
yield
|
24
|
+
ensure
|
25
|
+
self.locale = locale_was
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def locale_session
|
30
|
+
Thread.current[:rosetta_locale_session] ||= LocaleSession.new
|
31
|
+
end
|
32
|
+
|
33
|
+
def translate(key, locale: Rosetta.locale)
|
34
|
+
store = Store.for_locale(locale)
|
35
|
+
store.lookup(key)
|
36
|
+
end
|
37
|
+
|
38
|
+
def config
|
39
|
+
@configuration ||= Configuration.new
|
40
|
+
end
|
41
|
+
|
42
|
+
def configure
|
43
|
+
config.tap { |config| yield(config) }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
extend Base
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rosetta-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vincent Rolea
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-09-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 6.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: turbo-rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: concurrent-ruby
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pagy
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '7.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '7.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: appraisal
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Unobstrusive Internationalization solution for Rails applications.
|
84
|
+
email:
|
85
|
+
- 3525369+virolea@users.noreply.github.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- MIT-LICENSE
|
91
|
+
- README.md
|
92
|
+
- Rakefile
|
93
|
+
- app/assets/builds/rosetta/application.css
|
94
|
+
- app/assets/builds/rosetta/application.js
|
95
|
+
- app/assets/config/rosetta_manifest.js
|
96
|
+
- app/assets/javascripts/rosetta/application.js
|
97
|
+
- app/assets/javascripts/rosetta/controllers/application.js
|
98
|
+
- app/assets/javascripts/rosetta/controllers/dialog_controller.js
|
99
|
+
- app/assets/javascripts/rosetta/controllers/index.js
|
100
|
+
- app/assets/stylesheets/rosetta/application.css
|
101
|
+
- app/controllers/concerns/rosetta/locale_scoped.rb
|
102
|
+
- app/controllers/rosetta/application_controller.rb
|
103
|
+
- app/controllers/rosetta/locales/deploys_controller.rb
|
104
|
+
- app/controllers/rosetta/locales/translations/missing_controller.rb
|
105
|
+
- app/controllers/rosetta/locales/translations_controller.rb
|
106
|
+
- app/controllers/rosetta/locales_controller.rb
|
107
|
+
- app/controllers/rosetta/translations_controller.rb
|
108
|
+
- app/helpers/rosetta/application_helper.rb
|
109
|
+
- app/helpers/rosetta/dialog_helper.rb
|
110
|
+
- app/helpers/rosetta/navigation_helper.rb
|
111
|
+
- app/helpers/rosetta/translation_helper.rb
|
112
|
+
- app/jobs/rosetta/application_job.rb
|
113
|
+
- app/mailers/rosetta/application_mailer.rb
|
114
|
+
- app/models/rosetta/application_record.rb
|
115
|
+
- app/models/rosetta/locale.rb
|
116
|
+
- app/models/rosetta/translation.rb
|
117
|
+
- app/models/rosetta/translation_key.rb
|
118
|
+
- app/views/layouts/rosetta/_dialog.html.erb
|
119
|
+
- app/views/layouts/rosetta/_flashes.html.erb
|
120
|
+
- app/views/layouts/rosetta/_navbar.html.erb
|
121
|
+
- app/views/layouts/rosetta/application.html.erb
|
122
|
+
- app/views/rosetta/locales/_form.html.erb
|
123
|
+
- app/views/rosetta/locales/_locale.html.erb
|
124
|
+
- app/views/rosetta/locales/index.html.erb
|
125
|
+
- app/views/rosetta/locales/new.html.erb
|
126
|
+
- app/views/rosetta/locales/translations/_navigation.html.erb
|
127
|
+
- app/views/rosetta/locales/translations/_translation_key.html.erb
|
128
|
+
- app/views/rosetta/locales/translations/index.html.erb
|
129
|
+
- app/views/rosetta/translations/edit.html.erb
|
130
|
+
- config/initializers/pagy.rb
|
131
|
+
- config/routes.rb
|
132
|
+
- db/migrate/20240830123523_create_rosetta_tables.rb
|
133
|
+
- lib/rosetta-rails.rb
|
134
|
+
- lib/rosetta/configuration.rb
|
135
|
+
- lib/rosetta/engine.rb
|
136
|
+
- lib/rosetta/locale_session.rb
|
137
|
+
- lib/rosetta/store.rb
|
138
|
+
- lib/rosetta/version.rb
|
139
|
+
- lib/tasks/rosetta_tasks.rake
|
140
|
+
homepage: https://github.com/virolea/rosetta
|
141
|
+
licenses:
|
142
|
+
- MIT
|
143
|
+
metadata: {}
|
144
|
+
post_install_message:
|
145
|
+
rdoc_options: []
|
146
|
+
require_paths:
|
147
|
+
- lib
|
148
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
requirements: []
|
159
|
+
rubygems_version: 3.5.3
|
160
|
+
signing_key:
|
161
|
+
specification_version: 4
|
162
|
+
summary: Unobstrusive Internationalization solution for Rails applications.
|
163
|
+
test_files: []
|