lesli_babel 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/lesli_babel/application.css +294 -23
- data/app/controllers/lesli_babel/application_controller.rb +14 -0
- data/app/controllers/lesli_babel/buckets_controller.rb +1 -7
- data/app/controllers/lesli_babel/labels_controller.rb +53 -35
- data/app/controllers/lesli_babel/translations_controller.rb +33 -43
- data/app/helpers/lesli_babel/labels_helper.rb +51 -2
- data/app/models/lesli_babel/application_record.rb +1 -1
- data/app/models/lesli_babel/label.rb +19 -2
- data/app/services/lesli_babel/label_service.rb +35 -6
- data/app/services/lesli_babel/translation_deploy_service.rb +144 -0
- data/app/services/lesli_babel/translation_export_service.rb +119 -0
- data/app/services/lesli_babel/translation_import_service.rb +184 -0
- data/app/services/lesli_babel/translation_service.rb +39 -151
- data/app/views/lesli_babel/dashboards/show.html.erb +62 -11
- data/app/views/lesli_babel/labels/_copy_path.html.erb +15 -0
- data/app/views/lesli_babel/labels/_delete_button.html.erb +14 -0
- data/app/views/lesli_babel/labels/_form.html.erb +56 -9
- data/app/views/lesli_babel/labels/_module_navigation.html.erb +15 -0
- data/app/views/lesli_babel/labels/index.html.erb +65 -36
- data/app/views/lesli_babel/labels/panel.html.erb +8 -0
- data/app/views/lesli_babel/labels/show.html.erb +10 -2
- data/app/views/lesli_babel/partials/_deploy_button.html.erb +21 -0
- data/config/locales/navigation.en.yml +5 -0
- data/config/locales/navigation.es.yml +5 -0
- data/config/locales/translations.en.yml +11 -1
- data/config/locales/translations.es.yml +11 -1
- data/config/locales/translations.fr.yml +2 -1
- data/config/locales/translations.it.yml +2 -1
- data/config/locales/translations.pt.yml +2 -1
- data/config/routes.rb +1 -2
- data/db/migrate/v1.0/0901100110_create_lesli_babel_modules.rb +6 -5
- data/db/migrate/v1.0/0901110110_create_lesli_babel_buckets.rb +7 -6
- data/db/migrate/v1.0/0901120110_create_lesli_babel_labels.rb +23 -22
- data/lib/lesli_babel/version.rb +2 -2
- data/lib/tasks/lesli_babel_tasks.rake +135 -83
- data/readme.md +4 -2
- metadata +12 -3
- data/app/views/lesli_babel/partials/_sidebar.html.erb +0 -45
|
@@ -30,9 +30,9 @@ Building a better future, one line of code at a time.
|
|
|
30
30
|
// ·
|
|
31
31
|
=end
|
|
32
32
|
|
|
33
|
-
# ·
|
|
34
|
-
require "
|
|
35
|
-
|
|
33
|
+
# ·
|
|
34
|
+
require "fileutils"
|
|
35
|
+
require "tmpdir"
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
namespace :lesli_babel do
|
|
@@ -50,16 +50,22 @@ namespace :lesli_babel do
|
|
|
50
50
|
desc "Create standard structure for translations according to the objects in the app"
|
|
51
51
|
task scan: [:environment] do
|
|
52
52
|
|
|
53
|
-
engines = Lesli::ResourceService.new.index(matrix: true)
|
|
53
|
+
engines = Lesli::ResourceService.new(nil).index(matrix: true)
|
|
54
54
|
|
|
55
55
|
engines.each do |engine, routes|
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
platform =
|
|
57
|
+
module_code = engine == "rails_app" ? "main_app" : engine
|
|
58
|
+
platform = case engine
|
|
59
|
+
when "rails_app"
|
|
60
|
+
"rails_app"
|
|
61
|
+
when "lesli"
|
|
62
|
+
"lesli_core"
|
|
63
|
+
else
|
|
64
|
+
"lesli_engine"
|
|
65
|
+
end
|
|
59
66
|
|
|
60
67
|
translation_module = LesliBabel::Module
|
|
61
|
-
|
|
62
|
-
.find_or_create_by!(:code => engine)
|
|
68
|
+
.find_or_create_by!(code: module_code, platform: platform)
|
|
63
69
|
|
|
64
70
|
routes.each do |controller, route|
|
|
65
71
|
|
|
@@ -82,97 +88,143 @@ namespace :lesli_babel do
|
|
|
82
88
|
end
|
|
83
89
|
|
|
84
90
|
|
|
85
|
-
desc "Export translations
|
|
86
|
-
task :export => :environment do |
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
"!*.time",
|
|
103
|
-
"!*.support",
|
|
104
|
-
"!*.i18n",
|
|
105
|
-
"!*.activerecord",
|
|
106
|
-
"!*.errors",
|
|
107
|
-
"!*.number.nth",
|
|
108
|
-
"*.lesli.shared.*",
|
|
109
|
-
"*.lesli.dashboards.*",
|
|
110
|
-
"*.lesli.application.*",
|
|
111
|
-
"*.#{engine_info[:code]}.*",
|
|
112
|
-
]
|
|
113
|
-
}
|
|
114
|
-
]
|
|
115
|
-
}
|
|
91
|
+
desc "Export translations without modifying installed engines"
|
|
92
|
+
task :export, [:output_dir] => :environment do |_task, args|
|
|
93
|
+
|
|
94
|
+
# Generate every document before writing to the output directory
|
|
95
|
+
documents = LesliSystem.engines.values
|
|
96
|
+
.sort_by { |engine| engine[:name].to_s }
|
|
97
|
+
.flat_map do |engine|
|
|
98
|
+
platform = case engine[:code]
|
|
99
|
+
when "root"
|
|
100
|
+
"rails_app"
|
|
101
|
+
when "lesli"
|
|
102
|
+
"lesli_core"
|
|
103
|
+
else
|
|
104
|
+
"lesli_engine"
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
export_engine = engine[:code] == "root" ? engine.merge(code: "main_app") : engine
|
|
116
108
|
|
|
117
|
-
|
|
109
|
+
Lesli.config.babel.fetch(:locales).keys.map(&:to_s).sort.map do |locale|
|
|
110
|
+
{
|
|
111
|
+
engine: engine,
|
|
112
|
+
document: LesliBabel::TranslationExportService.call(
|
|
113
|
+
engine: export_engine,
|
|
114
|
+
platform: platform,
|
|
115
|
+
locale: locale
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
end
|
|
118
119
|
end
|
|
120
|
+
|
|
121
|
+
output_dir = File.expand_path(args[:output_dir].presence || Dir.mktmpdir("lesli-babel-export"))
|
|
122
|
+
|
|
123
|
+
documents.each do |export|
|
|
124
|
+
engine = export.fetch(:engine)
|
|
125
|
+
document = export.fetch(:document)
|
|
126
|
+
engine_dir = File.join(output_dir, engine.fetch(:code))
|
|
127
|
+
file_name = File.basename(document.fetch(:file_path))
|
|
128
|
+
|
|
129
|
+
FileUtils.mkdir_p(engine_dir)
|
|
130
|
+
File.binwrite(File.join(engine_dir, file_name), document.fetch(:content))
|
|
131
|
+
|
|
132
|
+
Termline.success("Translations exported", engine: engine[:name], file: file_name)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
Termline.success("Translation export completed", directory: output_dir)
|
|
119
136
|
end
|
|
120
137
|
|
|
121
138
|
|
|
122
|
-
desc "
|
|
123
|
-
task :
|
|
139
|
+
desc "Deploy translations to installed engines"
|
|
140
|
+
task deploy: :environment do
|
|
141
|
+
|
|
142
|
+
result = LesliBabel::TranslationDeployService.call
|
|
143
|
+
|
|
144
|
+
if result[:errors].any?
|
|
145
|
+
Termline.danger("Translation deploy failed")
|
|
146
|
+
Termline.list(*result[:errors], color: :red, icon: :warning)
|
|
147
|
+
raise "Translation deploy failed"
|
|
148
|
+
end
|
|
124
149
|
|
|
125
|
-
|
|
126
|
-
engines = LesliSystem.engines
|
|
150
|
+
engines = LesliSystem.engines.values
|
|
127
151
|
|
|
152
|
+
result[:files].each do |file_path|
|
|
153
|
+
engine = engines.find do |engine_info|
|
|
154
|
+
file_path.start_with?("#{engine_info[:dir]}#{File::SEPARATOR}")
|
|
155
|
+
end
|
|
128
156
|
|
|
129
|
-
|
|
157
|
+
Termline.success(
|
|
158
|
+
"Translations deployed",
|
|
159
|
+
engine: engine&.dig(:name),
|
|
160
|
+
file: File.basename(file_path)
|
|
161
|
+
)
|
|
162
|
+
end
|
|
130
163
|
|
|
131
|
-
|
|
132
|
-
|
|
164
|
+
Termline.success("Translation deploy completed")
|
|
165
|
+
end
|
|
133
166
|
|
|
134
|
-
# platform name
|
|
135
|
-
platform = "lesli_engine"
|
|
136
167
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
# create the bucket if it does not exist
|
|
153
|
-
translation_bucket = LesliBabel::Bucket.find_or_create_by(
|
|
154
|
-
code: bucket,
|
|
155
|
-
module: translation_module,
|
|
156
|
-
reference_module: translation_module.code
|
|
157
|
-
)
|
|
168
|
+
desc "Import local translations into LesliBabel"
|
|
169
|
+
task :import, [:silent] => :environment do |_task, args|
|
|
170
|
+
|
|
171
|
+
silent = ActiveModel::Type::Boolean.new.cast(args[:silent])
|
|
172
|
+
|
|
173
|
+
# Discover every translation file and determine its platform
|
|
174
|
+
translation_files = LesliSystem.engines.values.flat_map do |engine_info|
|
|
175
|
+
platform = case engine_info[:code]
|
|
176
|
+
when "root"
|
|
177
|
+
"rails_app"
|
|
178
|
+
when "lesli"
|
|
179
|
+
"lesli_core"
|
|
180
|
+
else
|
|
181
|
+
"lesli_engine"
|
|
182
|
+
end
|
|
158
183
|
|
|
159
|
-
|
|
184
|
+
Dir[File.join(engine_info[:dir], "config", "locales", "translations.*.yml")].map do |file_path|
|
|
185
|
+
{
|
|
186
|
+
engine: engine_info[:name],
|
|
187
|
+
file: File.basename(file_path),
|
|
188
|
+
path: file_path,
|
|
189
|
+
platform: platform
|
|
190
|
+
}
|
|
191
|
+
end
|
|
192
|
+
end.sort_by { |translation_file| [translation_file[:engine], translation_file[:file]] }
|
|
193
|
+
|
|
194
|
+
errors = []
|
|
160
195
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
bucket_id: translation_bucket.id
|
|
167
|
-
)
|
|
196
|
+
translation_files.each do |translation_file|
|
|
197
|
+
result = LesliBabel::TranslationImportService.call(
|
|
198
|
+
file_path: translation_file[:path],
|
|
199
|
+
platform: translation_file[:platform]
|
|
200
|
+
)
|
|
168
201
|
|
|
169
|
-
|
|
170
|
-
|
|
202
|
+
errors.concat(
|
|
203
|
+
result[:errors].map do |error|
|
|
204
|
+
"#{translation_file[:engine]}/#{translation_file[:file]}: #{error}"
|
|
205
|
+
end
|
|
206
|
+
)
|
|
171
207
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
208
|
+
next if silent
|
|
209
|
+
|
|
210
|
+
file_details = {
|
|
211
|
+
engine: translation_file[:engine],
|
|
212
|
+
file: translation_file[:file]
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if result[:errors].empty?
|
|
216
|
+
Termline.success("Translations imported", **file_details)
|
|
217
|
+
else
|
|
218
|
+
Termline.warning("Translations imported with rejected entries", **file_details)
|
|
219
|
+
Termline.list(*result[:errors], color: :yellow, icon: :warning)
|
|
175
220
|
end
|
|
176
221
|
end
|
|
222
|
+
|
|
223
|
+
# Show this single message to know the status of the import task
|
|
224
|
+
if errors.any?
|
|
225
|
+
Termline.danger("LesliBabel: Translations imported with errors")
|
|
226
|
+
else
|
|
227
|
+
Termline.success("LesliBabel: Translations imported successfully")
|
|
228
|
+
end
|
|
177
229
|
end
|
|
178
230
|
end
|
data/readme.md
CHANGED
|
@@ -48,8 +48,8 @@ It organizes application text and helps teams maintain, synchronize, and deploy
|
|
|
48
48
|
- Translation modules and buckets
|
|
49
49
|
- Centralized label management
|
|
50
50
|
- Language-specific translation values
|
|
51
|
-
-
|
|
52
|
-
-
|
|
51
|
+
- Import from version-controlled YAML files
|
|
52
|
+
- Safe YAML export and deployment across Lesli applications
|
|
53
53
|
|
|
54
54
|
<br />
|
|
55
55
|
|
|
@@ -169,6 +169,8 @@ CI=true bundle exec rake app:test
|
|
|
169
169
|
|
|
170
170
|
- [Installation guide](./docs/about/installation.md)
|
|
171
171
|
- [Translation workflow](./docs/about/translations.md)
|
|
172
|
+
- [Dashboard metrics and web deploy](./docs/about/dashboard.md)
|
|
173
|
+
- [Official YAML structure](./docs/about/yaml-structure.md)
|
|
172
174
|
- [Frontend development](./docs/about/frontend.md)
|
|
173
175
|
- [Database](./docs/about/database.md)
|
|
174
176
|
- [Tasks](./docs/about/tasks.md)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lesli_babel
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- The Lesli Development Team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lesli
|
|
@@ -52,14 +52,23 @@ files:
|
|
|
52
52
|
- app/models/lesli_babel/module.rb
|
|
53
53
|
- app/services/lesli_babel/label_service.rb
|
|
54
54
|
- app/services/lesli_babel/module_service.rb
|
|
55
|
+
- app/services/lesli_babel/translation_deploy_service.rb
|
|
56
|
+
- app/services/lesli_babel/translation_export_service.rb
|
|
57
|
+
- app/services/lesli_babel/translation_import_service.rb
|
|
55
58
|
- app/services/lesli_babel/translation_service.rb
|
|
56
59
|
- app/views/lesli_babel/dashboards/show.html.erb
|
|
60
|
+
- app/views/lesli_babel/labels/_copy_path.html.erb
|
|
61
|
+
- app/views/lesli_babel/labels/_delete_button.html.erb
|
|
57
62
|
- app/views/lesli_babel/labels/_form.html.erb
|
|
63
|
+
- app/views/lesli_babel/labels/_module_navigation.html.erb
|
|
58
64
|
- app/views/lesli_babel/labels/index.html.erb
|
|
59
65
|
- app/views/lesli_babel/labels/new.html.erb
|
|
66
|
+
- app/views/lesli_babel/labels/panel.html.erb
|
|
60
67
|
- app/views/lesli_babel/labels/show.html.erb
|
|
68
|
+
- app/views/lesli_babel/partials/_deploy_button.html.erb
|
|
61
69
|
- app/views/lesli_babel/partials/_navigation.html.erb
|
|
62
|
-
-
|
|
70
|
+
- config/locales/navigation.en.yml
|
|
71
|
+
- config/locales/navigation.es.yml
|
|
63
72
|
- config/locales/translations.en.yml
|
|
64
73
|
- config/locales/translations.es.yml
|
|
65
74
|
- config/locales/translations.fr.yml
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
<%
|
|
2
|
-
=begin
|
|
3
|
-
|
|
4
|
-
Lesli
|
|
5
|
-
|
|
6
|
-
Copyright (c) 2023, Lesli Technologies, S. A.
|
|
7
|
-
|
|
8
|
-
This program is free software: you can redistribute it and/or modify
|
|
9
|
-
it under the terms of the GNU General Public License as published by
|
|
10
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
11
|
-
(at your option) any later version.
|
|
12
|
-
|
|
13
|
-
This program is distributed in the hope that it will be useful,
|
|
14
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
GNU General Public License for more details.
|
|
17
|
-
|
|
18
|
-
You should have received a copy of the GNU General Public License
|
|
19
|
-
along with this program. If not, see http://www.gnu.org/licenses/.
|
|
20
|
-
|
|
21
|
-
Lesli · Ruby on Rails SaaS development platform.
|
|
22
|
-
|
|
23
|
-
Made with ♥ by https://www.lesli.tech
|
|
24
|
-
Building a better future, one line of code at a time.
|
|
25
|
-
|
|
26
|
-
@contact hello@lesli.tech
|
|
27
|
-
@website https://www.lesli.tech
|
|
28
|
-
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
|
29
|
-
|
|
30
|
-
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
|
31
|
-
// ·
|
|
32
|
-
=end
|
|
33
|
-
%>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<li class="px-4 pb-2 pt-1">
|
|
37
|
-
<h2 class="text-xs font-semibold uppercase tracking-wider text-slate-500">Modules</h2>
|
|
38
|
-
</li>
|
|
39
|
-
<% LesliBabel::Module.all.order(:code).each do |engine| %>
|
|
40
|
-
<%= navigation_item(
|
|
41
|
-
lesli_babel.modules_path + "/" + engine.id.to_s,
|
|
42
|
-
engine.code.titleize,
|
|
43
|
-
"ri-folder-line"
|
|
44
|
-
) %>
|
|
45
|
-
<% end %>
|