lesli_babel 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/lesli_babel/application.js +1 -1
- data/app/controllers/lesli_babel/clones_controller.rb +1 -1
- data/app/controllers/lesli_babel/relevants_controller.rb +1 -1
- data/app/models/lesli_babel/clone.rb +1 -1
- data/lib/lesli_babel/version.rb +2 -2
- metadata +1 -13
- data/app/assets/javascripts/lesli_babel/application.js.LICENSE.txt +0 -282
- data/app/models/lesli_babel/string/activity.rb +0 -5
- data/app/models/lesli_babel/string/discussion.rb +0 -68
- data/app/services/lesli_babel/old/translations_android_service.rb +0 -82
- data/app/services/lesli_babel/old/translations_clone_service.rb +0 -161
- data/app/services/lesli_babel/old/translations_flutter_service.rb +0 -102
- data/app/services/lesli_babel/old/translations_ios_service.rb +0 -119
- data/app/services/lesli_babel/old/translations_js_service.rb +0 -114
- data/app/services/lesli_babel/old/translations_middleman_service.rb +0 -77
- data/app/services/lesli_babel/old/translations_rails_service.rb +0 -119
- data/app/services/lesli_babel/old/translations_service.rb +0 -97
- data/app/services/lesli_babel/old/translations_synchronization_service.rb +0 -215
@@ -16,7 +16,7 @@ For more information read the license file including with this software.
|
|
16
16
|
// ·
|
17
17
|
|
18
18
|
=end
|
19
|
-
require_dependency "
|
19
|
+
require_dependency "lesli_babel/application_controller"
|
20
20
|
|
21
21
|
module LesliBabel
|
22
22
|
class ClonesController < ApplicationController
|
@@ -15,7 +15,7 @@ For more information read the license file including with this software.
|
|
15
15
|
// ·
|
16
16
|
|
17
17
|
=end
|
18
|
-
require_dependency "
|
18
|
+
require_dependency "lesli_babel/application_controller"
|
19
19
|
|
20
20
|
module LesliBabel
|
21
21
|
class RelevantsController < ApplicationController
|
data/lib/lesli_babel/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lesli_babel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Lesli Development Team
|
@@ -49,7 +49,6 @@ files:
|
|
49
49
|
- app/assets/config/lesli_babel_manifest.js
|
50
50
|
- app/assets/images/lesli_babel/babel-logo.svg
|
51
51
|
- app/assets/javascripts/lesli_babel/application.js
|
52
|
-
- app/assets/javascripts/lesli_babel/application.js.LICENSE.txt
|
53
52
|
- app/assets/stylesheets/lesli_babel/application.css
|
54
53
|
- app/controllers/lesli_babel/application_controller.rb
|
55
54
|
- app/controllers/lesli_babel/buckets_controller.rb
|
@@ -68,20 +67,9 @@ files:
|
|
68
67
|
- app/models/lesli_babel/module.rb
|
69
68
|
- app/models/lesli_babel/relevant.rb
|
70
69
|
- app/models/lesli_babel/string.rb
|
71
|
-
- app/models/lesli_babel/string/activity.rb
|
72
|
-
- app/models/lesli_babel/string/discussion.rb
|
73
70
|
- app/models/lesli_babel/translation.rb
|
74
71
|
- app/services/lesli_babel/deploy_rails_service.rb
|
75
72
|
- app/services/lesli_babel/module_service.rb
|
76
|
-
- app/services/lesli_babel/old/translations_android_service.rb
|
77
|
-
- app/services/lesli_babel/old/translations_clone_service.rb
|
78
|
-
- app/services/lesli_babel/old/translations_flutter_service.rb
|
79
|
-
- app/services/lesli_babel/old/translations_ios_service.rb
|
80
|
-
- app/services/lesli_babel/old/translations_js_service.rb
|
81
|
-
- app/services/lesli_babel/old/translations_middleman_service.rb
|
82
|
-
- app/services/lesli_babel/old/translations_rails_service.rb
|
83
|
-
- app/services/lesli_babel/old/translations_service.rb
|
84
|
-
- app/services/lesli_babel/old/translations_synchronization_service.rb
|
85
73
|
- app/services/lesli_babel/string_service.rb
|
86
74
|
- app/views/lesli_babel/buckets/_form.html.erb
|
87
75
|
- app/views/lesli_babel/buckets/edit.html.erb
|
@@ -1,282 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
|
3
|
-
Lesli
|
4
|
-
|
5
|
-
Copyright (c) 2023, Lesli Technologies, S. A.
|
6
|
-
|
7
|
-
This program is free software: you can redistribute it and/or modify
|
8
|
-
it under the terms of the GNU General Public License as published by
|
9
|
-
the Free Software Foundation, either version 3 of the License, or
|
10
|
-
(at your option) any later version.
|
11
|
-
|
12
|
-
This program is distributed in the hope that it will be useful,
|
13
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
GNU General Public License for more details.
|
16
|
-
|
17
|
-
You should have received a copy of the GNU General Public License
|
18
|
-
along with this program. If not, see http://www.gnu.org/licenses/.
|
19
|
-
|
20
|
-
Lesli · Ruby on Rails SaaS Development Framework.
|
21
|
-
|
22
|
-
Made with ♥ by https://www.lesli.tech
|
23
|
-
Building a better future, one line of code at a time.
|
24
|
-
|
25
|
-
@contact hello@lesli.tech
|
26
|
-
@website https://www.lesli.tech
|
27
|
-
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
28
|
-
|
29
|
-
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
30
|
-
// ·
|
31
|
-
*/
|
32
|
-
|
33
|
-
/*
|
34
|
-
|
35
|
-
Lesli
|
36
|
-
|
37
|
-
Copyright (c) 2023, Lesli Technologies, S. A.
|
38
|
-
|
39
|
-
This program is free software: you can redistribute it and/or modify
|
40
|
-
it under the terms of the GNU General Public License as published by
|
41
|
-
the Free Software Foundation, either version 3 of the License, or
|
42
|
-
(at your option) any later version.
|
43
|
-
|
44
|
-
This program is distributed in the hope that it will be useful,
|
45
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
46
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
47
|
-
GNU General Public License for more details.
|
48
|
-
|
49
|
-
You should have received a copy of the GNU General Public License
|
50
|
-
along with this program. If not, see http://www.gnu.org/licenses/.
|
51
|
-
|
52
|
-
Lesli · Your Smart Business Assistant.
|
53
|
-
|
54
|
-
Made with ♥ by https://www.lesli.tech
|
55
|
-
Building a better future, one line of code at a time.
|
56
|
-
|
57
|
-
@contact hello@lesli.tech
|
58
|
-
@website https://lesli.tech
|
59
|
-
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
60
|
-
|
61
|
-
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
62
|
-
// ·
|
63
|
-
|
64
|
-
*/
|
65
|
-
|
66
|
-
/*
|
67
|
-
|
68
|
-
Lesli
|
69
|
-
|
70
|
-
Copyright (c) 2023, Lesli Technologies, S. A.
|
71
|
-
|
72
|
-
This program is free software: you can redistribute it and/or modify
|
73
|
-
it under the terms of the GNU General Public License as published by
|
74
|
-
the Free Software Foundation, either version 3 of the License, or
|
75
|
-
(at your option) any later version.
|
76
|
-
|
77
|
-
This program is distributed in the hope that it will be useful,
|
78
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
79
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
80
|
-
GNU General Public License for more details.
|
81
|
-
|
82
|
-
You should have received a copy of the GNU General Public License
|
83
|
-
along with this program. If not, see http://www.gnu.org/licenses/.
|
84
|
-
|
85
|
-
Lesli · Your Smart Business Assistant.
|
86
|
-
|
87
|
-
Made with ♥ by https://www.lesli.tech
|
88
|
-
Building a better future, one line of code at a time.
|
89
|
-
|
90
|
-
@contact hello@lesli.tech
|
91
|
-
@website https://lesli.tech
|
92
|
-
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
93
|
-
|
94
|
-
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
95
|
-
// ·
|
96
|
-
*/
|
97
|
-
|
98
|
-
/*
|
99
|
-
Lesli
|
100
|
-
|
101
|
-
Copyright (c) 2023, Lesli Technologies, S. A.
|
102
|
-
|
103
|
-
This program is free software: you can redistribute it and/or modify
|
104
|
-
it under the terms of the GNU General Public License as published by
|
105
|
-
the Free Software Foundation, either version 3 of the License, or
|
106
|
-
(at your option) any later version.
|
107
|
-
|
108
|
-
This program is distributed in the hope that it will be useful,
|
109
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
110
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
111
|
-
GNU General Public License for more details.
|
112
|
-
|
113
|
-
You should have received a copy of the GNU General Public License
|
114
|
-
along with this program. If not, see http://www.gnu.org/licenses/.
|
115
|
-
|
116
|
-
Lesli · Ruby on Rails SaaS Development Framework.
|
117
|
-
|
118
|
-
Made with ♥ by https://www.lesli.tech
|
119
|
-
Building a better future, one line of code at a time.
|
120
|
-
|
121
|
-
@contact hello@lesli.tech
|
122
|
-
@website https://www.lesli.dev
|
123
|
-
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
124
|
-
|
125
|
-
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
126
|
-
// ·
|
127
|
-
*/
|
128
|
-
|
129
|
-
/*
|
130
|
-
Lesli
|
131
|
-
|
132
|
-
Copyright (c) 2023, Lesli Technologies, S. A.
|
133
|
-
|
134
|
-
This program is free software: you can redistribute it and/or modify
|
135
|
-
it under the terms of the GNU General Public License as published by
|
136
|
-
the Free Software Foundation, either version 3 of the License, or
|
137
|
-
(at your option) any later version.
|
138
|
-
|
139
|
-
This program is distributed in the hope that it will be useful,
|
140
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
141
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
142
|
-
GNU General Public License for more details.
|
143
|
-
|
144
|
-
You should have received a copy of the GNU General Public License
|
145
|
-
along with this program. If not, see http://www.gnu.org/licenses/.
|
146
|
-
|
147
|
-
Lesli · Ruby on Rails SaaS development platform.
|
148
|
-
|
149
|
-
Made with ♥ by https://www.lesli.tech
|
150
|
-
Building a better future, one line of code at a time.
|
151
|
-
|
152
|
-
@contact hello@lesli.tech
|
153
|
-
@website https://www.lesli.tech
|
154
|
-
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
155
|
-
|
156
|
-
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
157
|
-
// ·
|
158
|
-
*/
|
159
|
-
|
160
|
-
/*
|
161
|
-
Lesli
|
162
|
-
|
163
|
-
Copyright (c) 2020, Lesli Technologies, S. A.
|
164
|
-
|
165
|
-
This program is free software: you can redistribute it and/or modify
|
166
|
-
it under the terms of the GNU General Public License as published by
|
167
|
-
the Free Software Foundation, either version 3 of the License, or
|
168
|
-
(at your option) any later version.
|
169
|
-
|
170
|
-
This program is distributed in the hope that it will be useful,
|
171
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
172
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
173
|
-
GNU General Public License for more details.
|
174
|
-
|
175
|
-
You should have received a copy of the GNU General Public License
|
176
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
177
|
-
|
178
|
-
Lesli JS - JavaScript utilities for JavaScript applications
|
179
|
-
|
180
|
-
Powered by LesliTech
|
181
|
-
Building a better future, one line of code at a time.
|
182
|
-
|
183
|
-
@contact <hello@lesli.tech>
|
184
|
-
@website <https://lesli.tech>
|
185
|
-
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
186
|
-
|
187
|
-
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
188
|
-
// ·
|
189
|
-
*/
|
190
|
-
|
191
|
-
/*
|
192
|
-
Lesli
|
193
|
-
|
194
|
-
Copyright (c) 2021, Lesli Technologies, S. A.
|
195
|
-
|
196
|
-
This program is free software: you can redistribute it and/or modify
|
197
|
-
it under the terms of the GNU General Public License as published by
|
198
|
-
the Free Software Foundation, either version 3 of the License, or
|
199
|
-
(at your option) any later version.
|
200
|
-
|
201
|
-
This program is distributed in the hope that it will be useful,
|
202
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
203
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
204
|
-
GNU General Public License for more details.
|
205
|
-
|
206
|
-
You should have received a copy of the GNU General Public License
|
207
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
208
|
-
|
209
|
-
Lesli JS - JavaScript utilities for JavaScript applications
|
210
|
-
|
211
|
-
Powered by LesliTech
|
212
|
-
Building a better future, one line of code at a time.
|
213
|
-
|
214
|
-
@contact <hello@lesli.tech>
|
215
|
-
@website <https://lesli.tech>
|
216
|
-
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
217
|
-
|
218
|
-
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
219
|
-
// ·
|
220
|
-
*/
|
221
|
-
|
222
|
-
/*
|
223
|
-
Lesli
|
224
|
-
|
225
|
-
Copyright (c) 2023, Lesli Technologies, S. A.
|
226
|
-
|
227
|
-
This program is free software: you can redistribute it and/or modify
|
228
|
-
it under the terms of the GNU General Public License as published by
|
229
|
-
the Free Software Foundation, either version 3 of the License, or
|
230
|
-
(at your option) any later version.
|
231
|
-
|
232
|
-
This program is distributed in the hope that it will be useful,
|
233
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
234
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
235
|
-
GNU General Public License for more details.
|
236
|
-
|
237
|
-
You should have received a copy of the GNU General Public License
|
238
|
-
along with this program. If not, see http://www.gnu.org/licenses/.
|
239
|
-
|
240
|
-
Lesli · Ruby on Rails SaaS Development Framework.
|
241
|
-
|
242
|
-
Made with ♥ by https://www.lesli.tech
|
243
|
-
Building a better future, one line of code at a time.
|
244
|
-
|
245
|
-
@contact hello@lesli.tech
|
246
|
-
@website https://www.lesli.dev
|
247
|
-
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
248
|
-
|
249
|
-
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
250
|
-
// ·
|
251
|
-
*/
|
252
|
-
|
253
|
-
/*
|
254
|
-
Lesli
|
255
|
-
|
256
|
-
Copyright (c) 2023, Lesli Technologies, S. A.
|
257
|
-
|
258
|
-
This program is free software: you can redistribute it and/or modify
|
259
|
-
it under the terms of the GNU General Public License as published by
|
260
|
-
the Free Software Foundation, either version 3 of the License, or
|
261
|
-
(at your option) any later version.
|
262
|
-
|
263
|
-
This program is distributed in the hope that it will be useful,
|
264
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
265
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
266
|
-
GNU General Public License for more details.
|
267
|
-
|
268
|
-
You should have received a copy of the GNU General Public License
|
269
|
-
along with this program. If not, see http://www.gnu.org/licenses/.
|
270
|
-
|
271
|
-
Lesli · Ruby on Rails SaaS Development Framework.
|
272
|
-
|
273
|
-
Made with ♥ by https://www.lesli.tech
|
274
|
-
Building a better future, one line of code at a time.
|
275
|
-
|
276
|
-
@contact hello@lesli.tech
|
277
|
-
@website https://www.lesli.tech
|
278
|
-
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
279
|
-
|
280
|
-
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
281
|
-
// ·
|
282
|
-
*/
|
@@ -1,68 +0,0 @@
|
|
1
|
-
module LesliBabel
|
2
|
-
class String::Discussion < CloudObject::Discussion
|
3
|
-
belongs_to :cloud_object, class_name: "String", foreign_key: "cloud_babel_strings_id"
|
4
|
-
belongs_to :parent, class_name: "Discussion", optional: true
|
5
|
-
has_many :children, class_name: "Discussion", foreign_key: "parent_id"
|
6
|
-
|
7
|
-
def self.list(current_user, cloud_id)
|
8
|
-
|
9
|
-
discussions = self.joins(
|
10
|
-
"inner join cloud_babel_strings CO on cloud_babel_string_discussions.cloud_babel_strings_id = CO.id"
|
11
|
-
).joins(
|
12
|
-
"inner join users U on cloud_babel_string_discussions.users_id = U.id"
|
13
|
-
).joins(
|
14
|
-
"inner join user_details UD on UD.users_id = U.id"
|
15
|
-
).select(
|
16
|
-
"cloud_babel_string_discussions.id",
|
17
|
-
"cloud_babel_string_discussions.users_id",
|
18
|
-
"cloud_babel_string_discussions.content",
|
19
|
-
"cloud_babel_string_discussions.created_at",
|
20
|
-
"cloud_babel_string_discussions.cloud_babel_string_discussions_id",
|
21
|
-
"U.email",
|
22
|
-
"CONCAT(UD.first_name, ' ', UD.last_name) as user_name"
|
23
|
-
)
|
24
|
-
.where("CO.id = #{cloud_id}")
|
25
|
-
.where("CO.reference_module_bucket LIKE ?", "#{Rails.configuration.lesli_settings["instance"]}%")
|
26
|
-
.order(id: :asc)
|
27
|
-
.map { |discussion|
|
28
|
-
discussion_attributes = discussion.attributes
|
29
|
-
discussion_attributes["created_at_raw"] = discussion_attributes["created_at"]
|
30
|
-
discussion_attributes["editable"] = discussion.is_editable_by?(current_user)
|
31
|
-
discussion_attributes["created_at"] = LC::Date.to_string_datetime(discussion_attributes["created_at"])
|
32
|
-
discussion_attributes
|
33
|
-
}
|
34
|
-
|
35
|
-
data = {}
|
36
|
-
root_discussions = []
|
37
|
-
|
38
|
-
# Add all responses to that discussion
|
39
|
-
discussions.each do |discussion|
|
40
|
-
discussion_data = {
|
41
|
-
data: discussion,
|
42
|
-
responses: []
|
43
|
-
}
|
44
|
-
data[discussion["id"]] = discussion_data
|
45
|
-
|
46
|
-
if discussion["cloud_babel_string_discussions_id"].present?
|
47
|
-
parent_discussion = data[discussion["cloud_babel_string_discussions_id"]]
|
48
|
-
if parent_discussion[:data]["cloud_babel_string_discussions_id"].present?
|
49
|
-
discussion["response_to"] = parent_discussion[:data]["email"]
|
50
|
-
end
|
51
|
-
parent_discussion[:responses].push(discussion["id"])
|
52
|
-
else
|
53
|
-
root_discussions.push(discussion_data)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# Nest the responses to root discussions. A root discussion is any comment that is not a response to another comment
|
58
|
-
root_discussions.each do |discussion|
|
59
|
-
responses = []
|
60
|
-
self.nest_responses(data, discussion, responses)
|
61
|
-
discussion[:responses] = responses
|
62
|
-
end
|
63
|
-
|
64
|
-
# revert the root discussions so the most recent comments appear in the top
|
65
|
-
root_discussions.reverse
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
module LesliBabel
|
2
|
-
class TranslationsAndroidService
|
3
|
-
|
4
|
-
def self.build(engine_id = nil)
|
5
|
-
|
6
|
-
translation_folder_path = Rails.root.join("public", "tmp", "locales")
|
7
|
-
|
8
|
-
# get all rails engines
|
9
|
-
engines = Module.where(:id => engine_id).map do |engine|
|
10
|
-
engine[:id]
|
11
|
-
end
|
12
|
-
|
13
|
-
# get strings filtered by module (only rails translations)
|
14
|
-
strings = TranslationsService.strings_for_apps(engines)
|
15
|
-
|
16
|
-
translations = {}
|
17
|
-
|
18
|
-
available_locales = Rails.application.config.lesli_settings["configuration"]["locales"]
|
19
|
-
|
20
|
-
strings.each do |string|
|
21
|
-
|
22
|
-
module_name = string[:engine_name].downcase.sub("cloud", "")
|
23
|
-
engine_name = string[:engine_name]
|
24
|
-
bucket_name = string[:bucket_name]
|
25
|
-
module_type = string[:platform]
|
26
|
-
|
27
|
-
available_locales.each do |lang|
|
28
|
-
|
29
|
-
file_path = translation_folder_path.join(
|
30
|
-
engine_name, "values-#{lang}", "#{ bucket_name.gsub("/","_") }.xml"
|
31
|
-
)
|
32
|
-
|
33
|
-
file_id = file_path.to_s
|
34
|
-
|
35
|
-
unless translations.has_key? file_id
|
36
|
-
translations[file_id] = []
|
37
|
-
end
|
38
|
-
|
39
|
-
# send debug message for missing translations
|
40
|
-
string[lang] = ":" + string.path + ":" if string[lang].blank?
|
41
|
-
|
42
|
-
translations[file_id].push({
|
43
|
-
label: string.label,
|
44
|
-
translation: string[lang]
|
45
|
-
})
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
translation_files = []
|
52
|
-
|
53
|
-
translations.each do |translation|
|
54
|
-
|
55
|
-
file_path = translation[0]
|
56
|
-
strings = translation[1]
|
57
|
-
|
58
|
-
translation_files.push(file_path)
|
59
|
-
|
60
|
-
# creates folder and subfolders
|
61
|
-
FileUtils.makedirs(File.dirname(file_path))
|
62
|
-
|
63
|
-
# creates translation file for every available language
|
64
|
-
translation_file = File.new(file_path, "w+")
|
65
|
-
|
66
|
-
translation_file.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
67
|
-
translation_file.write("<resources>\n")
|
68
|
-
strings.each do |string|
|
69
|
-
translation_file.write("<string name=\"#{string[:label]}\">#{string[:translation]}</string>\n")
|
70
|
-
end
|
71
|
-
translation_file.write("</resources>")
|
72
|
-
|
73
|
-
translation_file.close
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
LC::Response.service true, translation_files
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
end
|
@@ -1,161 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
|
3
|
-
Copyright (c) 2020, all rights reserved.
|
4
|
-
|
5
|
-
All the information provided by this platform is protected by international laws related to
|
6
|
-
industrial property, intellectual property, copyright and relative international laws.
|
7
|
-
All intellectual or industrial property rights of the code, texts, trade mark, design,
|
8
|
-
pictures and any other information belongs to the owner of this platform.
|
9
|
-
|
10
|
-
Without the written permission of the owner, any replication, modification,
|
11
|
-
transmission, publication is strictly forbidden.
|
12
|
-
|
13
|
-
For more information read the license file including with this software.
|
14
|
-
|
15
|
-
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
16
|
-
// ·
|
17
|
-
|
18
|
-
=end
|
19
|
-
|
20
|
-
module LesliBabel
|
21
|
-
class TranslationsCloneService
|
22
|
-
|
23
|
-
|
24
|
-
# IMPORTANT: This is a modified copy of the SynchronizationService
|
25
|
-
# please be careful modifying this file
|
26
|
-
def self.remote_clone instance_code=nil
|
27
|
-
|
28
|
-
instance_name = instance_code.camelize
|
29
|
-
instance_code = instance_code.gsub("_","-")
|
30
|
-
|
31
|
-
|
32
|
-
# synchronization server url
|
33
|
-
host = "http://localhost:8080"
|
34
|
-
host = "https://server.raven.dev.gt"
|
35
|
-
|
36
|
-
|
37
|
-
return LC::Response.service(false, "no valid instance code provided") if instance_code.blank?
|
38
|
-
|
39
|
-
|
40
|
-
api_endpoint = "#{host}/api/bucket/babel-#{instance_code}/documents"
|
41
|
-
|
42
|
-
|
43
|
-
# get last sync data
|
44
|
-
response = Faraday.get(api_endpoint+"?last=1")
|
45
|
-
response = FastJsonparser.parse(response.body)
|
46
|
-
response = response[:data][:documents][0]
|
47
|
-
|
48
|
-
|
49
|
-
# if first time sync
|
50
|
-
return LC::Response.service(false, "no strings found") if response.blank?
|
51
|
-
|
52
|
-
|
53
|
-
# add new modules
|
54
|
-
response[:modules].each do |babel_module|
|
55
|
-
next if babel_module[:name].blank?
|
56
|
-
|
57
|
-
# we do not want to clone strings from builder engines
|
58
|
-
next if babel_module[:name] == instance_name
|
59
|
-
|
60
|
-
platform = babel_module[:platform]
|
61
|
-
platform = "rails_engine" if babel_module[:name].start_with?("Cloud")
|
62
|
-
platform = "rails_core" if babel_module[:name] == "Core"
|
63
|
-
|
64
|
-
local_module = CloudBabel::Module
|
65
|
-
.create_with({
|
66
|
-
created_at: babel_module[:created_at],
|
67
|
-
platform: babel_module[:platform]
|
68
|
-
}).find_or_create_by({ name: babel_module[:name] })
|
69
|
-
|
70
|
-
local_module.platform = platform
|
71
|
-
local_module.updated_at = DateTime.now
|
72
|
-
local_module.save
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
# working with buckets
|
77
|
-
babel_reference_modules = {}
|
78
|
-
|
79
|
-
response[:buckets].each do |babel_bucket|
|
80
|
-
|
81
|
-
next if babel_bucket[:name].blank?
|
82
|
-
|
83
|
-
# we do not want to clone strings from builder engines
|
84
|
-
next if babel_bucket[:reference_module] == instance_name
|
85
|
-
|
86
|
-
# reference to modules that buckets belongs to
|
87
|
-
# this reference as string is necessary because the id of the module can change
|
88
|
-
# between synchronizations, thats why we search for the id of the module every time
|
89
|
-
if babel_reference_modules[babel_bucket[:reference_module]].blank?
|
90
|
-
babel_reference_modules[babel_bucket[:reference_module]] =
|
91
|
-
CloudBabel::Module.find_by(name: babel_bucket[:reference_module])
|
92
|
-
end
|
93
|
-
|
94
|
-
# add new bucket
|
95
|
-
CloudBabel::Bucket
|
96
|
-
.create_with({
|
97
|
-
created_at: babel_bucket[:created_at],
|
98
|
-
module: babel_reference_modules[babel_bucket[:reference_module]]
|
99
|
-
}).find_or_create_by({
|
100
|
-
name: babel_bucket[:name],
|
101
|
-
reference_module: babel_bucket[:reference_module]
|
102
|
-
})
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
# · working with strings
|
107
|
-
babel_reference_buckets = {}
|
108
|
-
|
109
|
-
response[:strings].each do |remote_string|
|
110
|
-
# reference to modules that buckets belongs to
|
111
|
-
# this reference as string is necessary because the id of the module or bucket can change
|
112
|
-
# between synchronizations, thats why we search for the id of the module every time
|
113
|
-
if babel_reference_buckets[remote_string[:reference_bucket]].blank?
|
114
|
-
remote_string[:reference_bucket] ||= remote_string[:reference_module_bucket]
|
115
|
-
babel_reference_buckets[remote_string[:reference_bucket]] =
|
116
|
-
CloudBabel::Bucket.find_by(
|
117
|
-
name: remote_string[:reference_bucket].split("-")[1],
|
118
|
-
reference_module: remote_string[:reference_bucket].split("-")[0]
|
119
|
-
)
|
120
|
-
end
|
121
|
-
|
122
|
-
# Do not sync labes that do not have a valid module and bucket reference
|
123
|
-
next if babel_reference_buckets[remote_string[:reference_bucket]].blank?
|
124
|
-
|
125
|
-
# we do not want to clone strings from builder engines
|
126
|
-
next if babel_reference_buckets[remote_string[:reference_bucket]].reference_module == instance_name
|
127
|
-
|
128
|
-
remote_string_reference = "#{babel_reference_buckets[remote_string[:reference_bucket]].reference_module}-#{babel_reference_buckets[remote_string[:reference_bucket]].name}"
|
129
|
-
|
130
|
-
# add new string if it does not exist
|
131
|
-
local_string = CloudBabel::String.with_deleted.create_with({
|
132
|
-
context: remote_string[:context],
|
133
|
-
es: remote_string[:es],
|
134
|
-
en: remote_string[:en],
|
135
|
-
de: remote_string[:de],
|
136
|
-
status: remote_string[:status],
|
137
|
-
need_help: remote_string[:need_help],
|
138
|
-
need_translation: remote_string[:need_translation],
|
139
|
-
last_update_context: remote_string[:last_update_context],
|
140
|
-
last_update_es: remote_string[:last_update_es],
|
141
|
-
last_update_en: remote_string[:last_update_en],
|
142
|
-
last_update_de: remote_string[:last_update_de],
|
143
|
-
last_update_fr: remote_string[:last_update_fr],
|
144
|
-
last_update_status: remote_string[:last_update_status],
|
145
|
-
created_at: remote_string[:created_at],
|
146
|
-
updated_at: remote_string[:updated_at],
|
147
|
-
deleted_at: remote_string[:deleted_at],
|
148
|
-
bucket: babel_reference_buckets[remote_string[:reference_bucket]]
|
149
|
-
}).find_or_create_by({
|
150
|
-
label: remote_string[:label],
|
151
|
-
reference_module_bucket: remote_string_reference
|
152
|
-
})
|
153
|
-
|
154
|
-
end
|
155
|
-
|
156
|
-
LC::Response.service true
|
157
|
-
|
158
|
-
end
|
159
|
-
|
160
|
-
end
|
161
|
-
end
|