fastlane-plugin-simple_loco 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +121 -0
- data/lib/fastlane/plugin/simple_loco.rb +16 -0
- data/lib/fastlane/plugin/simple_loco/actions/simple_loco_action.rb +48 -0
- data/lib/fastlane/plugin/simple_loco/helper/simple_loco_helper.rb +396 -0
- data/lib/fastlane/plugin/simple_loco/version.rb +5 -0
- metadata +174 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2d0b03ff11d3b9284852f029335b41b29e1812f8f056603cd6a288191992f778
|
4
|
+
data.tar.gz: f30e75b6cb230097052838aec6990a1c547f3b38f09d2678d31f28d8a5d4a08d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3881301e1e63a7629d8a2895ad19e578eb1c80852e98cb2ab97af1c26753787e18f9570b9945b73d17714b26515a64ffbb92a5a8ed941d15b5a29083d8e63971
|
7
|
+
data.tar.gz: 0cb0a2d45a955f4bf897c7b040bb8d261cfb7557a6703aca506d6c7f1d039f675e0b68752a5a0bbab5de909ead6457bc809ea683acf4f216239e7accc69ab86f
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Yves Delcoigne <yves_delcoigne@hotmail.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# simple_loco plugin
|
2
|
+
|
3
|
+
[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-simple_loco)
|
4
|
+
|
5
|
+
## Getting Started
|
6
|
+
|
7
|
+
This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-simple_loco`, add it to your project by running:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
fastlane add_plugin simple_loco
|
11
|
+
```
|
12
|
+
|
13
|
+
## About simple_loco
|
14
|
+
|
15
|
+
A simple implementation for exporting translations from [Loco](https://localise.biz/).
|
16
|
+
|
17
|
+
This plugin is heavily inspired by https://github.com/JohnPaulConcierge/fastlane-plugin-loco, but some functionality has been removed and added. This plugin acts primarily as a wrapper implementation around the export single locale API call of Loco (see https://localise.biz/api/docs/export/exportlocale for full details).
|
18
|
+
|
19
|
+
There is advanced support for the following platforms:
|
20
|
+
- Android
|
21
|
+
- iOS
|
22
|
+
- Xamarin (with resx resource files)
|
23
|
+
- Flutter (with arb files)
|
24
|
+
|
25
|
+
For the platforms above, an extra adapter is available to create the correct folder and files needed to use the translations.
|
26
|
+
|
27
|
+
For other platforms, a default implementation is provided (translation files will be saved like \<provided folder\>/\<provided file name\>.\<locale\>.\<extension\>)
|
28
|
+
|
29
|
+
This plugin contains a single action `simple_loco`.
|
30
|
+
|
31
|
+
This action uses a configuration file to generate the correct API call.
|
32
|
+
|
33
|
+
The config file specifies the following properties:
|
34
|
+
- locales: List of locales to fetch
|
35
|
+
- directory: Directory to move translation files to
|
36
|
+
- platform: Platform for the translations: choice between:
|
37
|
+
- Android
|
38
|
+
- iOS
|
39
|
+
- Xamarin
|
40
|
+
- Flutter
|
41
|
+
- Custom
|
42
|
+
- key: Key of the Loco project
|
43
|
+
- Optional parameters:
|
44
|
+
- format
|
45
|
+
- filter
|
46
|
+
- index
|
47
|
+
- source
|
48
|
+
- namespace
|
49
|
+
- fallback
|
50
|
+
- order
|
51
|
+
- status
|
52
|
+
- printf
|
53
|
+
- charset
|
54
|
+
- breaks
|
55
|
+
- no_comments
|
56
|
+
- no_folding
|
57
|
+
|
58
|
+
For an explanation of the optional parameters, please see the official API reference: https://localise.biz/api/docs/export/exportlocale
|
59
|
+
|
60
|
+
Example of a JSON config file:
|
61
|
+
```
|
62
|
+
{
|
63
|
+
"locales" : [
|
64
|
+
"en",
|
65
|
+
"fr",
|
66
|
+
"nl",
|
67
|
+
"de"
|
68
|
+
],
|
69
|
+
"directory" : "src/main/res",
|
70
|
+
"platform" : "android",
|
71
|
+
"key" : "<Your key here>",
|
72
|
+
"fallback_locale" : "en",
|
73
|
+
"order": "id",
|
74
|
+
"filter": ["android"]
|
75
|
+
}
|
76
|
+
```
|
77
|
+
|
78
|
+
Or in YAML:
|
79
|
+
```
|
80
|
+
locales:
|
81
|
+
- en
|
82
|
+
- fr
|
83
|
+
- nl
|
84
|
+
- de
|
85
|
+
directory: src/main/res
|
86
|
+
platform: custom
|
87
|
+
key: <your key here>
|
88
|
+
fallback: en
|
89
|
+
order: id
|
90
|
+
custom_extension: .xml
|
91
|
+
custom_file_name: strings
|
92
|
+
```
|
93
|
+
|
94
|
+
## Run tests for this plugin
|
95
|
+
|
96
|
+
To run both the tests, and code style validation, run
|
97
|
+
|
98
|
+
```
|
99
|
+
rake
|
100
|
+
```
|
101
|
+
|
102
|
+
To automatically fix many of the styling issues, use
|
103
|
+
```
|
104
|
+
rubocop -a
|
105
|
+
```
|
106
|
+
|
107
|
+
## Issues and Feedback
|
108
|
+
|
109
|
+
For any other issues and feedback about this plugin, please submit it to this repository.
|
110
|
+
|
111
|
+
## Troubleshooting
|
112
|
+
|
113
|
+
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
|
114
|
+
|
115
|
+
## Using _fastlane_ Plugins
|
116
|
+
|
117
|
+
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
|
118
|
+
|
119
|
+
## About _fastlane_
|
120
|
+
|
121
|
+
_fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fastlane/plugin/simple_loco/version'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module SimpleLoco
|
5
|
+
# Return all .rb files inside the "actions" and "helper" directory
|
6
|
+
def self.all_classes
|
7
|
+
Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# By default we want to import all available actions and helpers
|
13
|
+
# A plugin can contain any number of actions and plugins
|
14
|
+
Fastlane::SimpleLoco.all_classes.each do |current|
|
15
|
+
require current
|
16
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/simple_loco_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
class SimpleLocoAction < Action
|
7
|
+
def self.run(params)
|
8
|
+
config = Helper::Config.read_conf(params[:conf_file_path])
|
9
|
+
|
10
|
+
UI.message('Exporting files')
|
11
|
+
|
12
|
+
config.export_locales
|
13
|
+
|
14
|
+
UI.success('Finished exporting files')
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.description
|
18
|
+
"A simple implementation for exporting translations from Loco."
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.authors
|
22
|
+
["Yves Delcoigne"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.return_value
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.details
|
29
|
+
"A wrapper implementation around the Localize export single-file API. See https://localise.biz/api/docs/export/exportlocale for all options. Common mobile platforms (Android, iOS, Xamarin, Flutter) have some extra logic to create the correct paths, and a custom implementation is provided for other platforms."
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.available_options
|
33
|
+
[
|
34
|
+
FastlaneCore::ConfigItem.new(key: :conf_file_path,
|
35
|
+
env_name: 'LOCO_CONF_FILE_PATH',
|
36
|
+
description: 'The config file path',
|
37
|
+
optional: true,
|
38
|
+
type: String,
|
39
|
+
default_value: 'fastlane/Loco.platform.json')
|
40
|
+
]
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.is_supported?(platform)
|
44
|
+
true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,396 @@
|
|
1
|
+
require 'fastlane_core/ui/ui'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
|
6
|
+
|
7
|
+
module Helper
|
8
|
+
PLATFORM_IOS = 'ios'
|
9
|
+
PLATFORM_ANDROID = 'android'
|
10
|
+
PLATFORM_FLUTTER = 'flutter'
|
11
|
+
PLATFORM_XAMARIN = 'xamarin'
|
12
|
+
PLATFORM_CUSTOM = 'custom'
|
13
|
+
|
14
|
+
class Config
|
15
|
+
def initialize(platform:,
|
16
|
+
directory:,
|
17
|
+
locales:,
|
18
|
+
key:,
|
19
|
+
format: "",
|
20
|
+
filter: [],
|
21
|
+
index: "",
|
22
|
+
source: "",
|
23
|
+
namespace: "",
|
24
|
+
fallback: "",
|
25
|
+
order: "",
|
26
|
+
status: "",
|
27
|
+
printf: "",
|
28
|
+
charset: "",
|
29
|
+
breaks: "",
|
30
|
+
no_comments: "",
|
31
|
+
no_folding: "",
|
32
|
+
custom_extension: "",
|
33
|
+
custom_file_name: "")
|
34
|
+
|
35
|
+
# Check for required fields
|
36
|
+
missing_fields = []
|
37
|
+
if platform.to_s.empty?
|
38
|
+
missing_fields.push 'platform'
|
39
|
+
end
|
40
|
+
if directory.to_s.empty?
|
41
|
+
missing_fields.push 'directory'
|
42
|
+
end
|
43
|
+
if key.to_s.empty?
|
44
|
+
missing_fields.push 'key'
|
45
|
+
end
|
46
|
+
if locales.to_s.empty?
|
47
|
+
missing_fields.push 'locales'
|
48
|
+
end
|
49
|
+
|
50
|
+
if !missing_fields.empty?
|
51
|
+
raise "Not all required fields are filled: #{missing_fields.join(", ")}"
|
52
|
+
end
|
53
|
+
|
54
|
+
@platform = platform
|
55
|
+
@directory = directory
|
56
|
+
@locales = locales
|
57
|
+
@key = key
|
58
|
+
@format = format
|
59
|
+
@filter = filter
|
60
|
+
@index = index
|
61
|
+
@source = source
|
62
|
+
@namespace = namespace
|
63
|
+
@fallback = fallback
|
64
|
+
@order = order
|
65
|
+
@status = status
|
66
|
+
@printf = printf
|
67
|
+
@charset = charset
|
68
|
+
@breaks = breaks
|
69
|
+
@no_comments = no_comments
|
70
|
+
@no_folding = no_folding
|
71
|
+
|
72
|
+
if platform == PLATFORM_ANDROID
|
73
|
+
@adapter = AndroidAdapter.new
|
74
|
+
elsif platform == PLATFORM_IOS
|
75
|
+
@adapter = CocoaAdapter.new
|
76
|
+
elsif platform == PLATFORM_FLUTTER
|
77
|
+
@adapter = FlutterAdapter.new
|
78
|
+
elsif platform == PLATFORM_XAMARIN
|
79
|
+
@adapter = XamarinAdapter.new
|
80
|
+
elsif platform == PLATFORM_CUSTOM
|
81
|
+
@adapter = CustomAdapter.new(
|
82
|
+
custom_extension: custom_extension,
|
83
|
+
custom_file_name: custom_file_name)
|
84
|
+
else
|
85
|
+
raise "Unsupported platform '#{platform}'"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
attr_reader :platform
|
90
|
+
attr_reader :directory
|
91
|
+
attr_reader :locales
|
92
|
+
attr_reader :key
|
93
|
+
attr_reader :format
|
94
|
+
attr_reader :filter
|
95
|
+
attr_reader :index
|
96
|
+
attr_reader :source
|
97
|
+
attr_reader :namespace
|
98
|
+
attr_reader :fallback
|
99
|
+
attr_reader :order
|
100
|
+
attr_reader :status
|
101
|
+
attr_reader :printf
|
102
|
+
attr_reader :charset
|
103
|
+
attr_reader :breaks
|
104
|
+
attr_reader :no_comments
|
105
|
+
attr_reader :no_folding
|
106
|
+
|
107
|
+
def export_locales
|
108
|
+
|
109
|
+
FileUtils.mkdir_p @directory unless File.directory? @directory
|
110
|
+
|
111
|
+
@locales.each_with_index do |locale, index|
|
112
|
+
|
113
|
+
@adapter.allowed_extensions.each do |extension|
|
114
|
+
|
115
|
+
# Download
|
116
|
+
|
117
|
+
result = export locale, extension
|
118
|
+
|
119
|
+
if result.nil?
|
120
|
+
raise "Could not export locale #{locale} with extension #{extension}"
|
121
|
+
end
|
122
|
+
|
123
|
+
# Write
|
124
|
+
|
125
|
+
result_directory = locale_directory locale, index.zero?
|
126
|
+
FileUtils.mkdir_p result_directory unless File.directory? result_directory
|
127
|
+
|
128
|
+
@adapter.write_locale(result_directory,
|
129
|
+
result,
|
130
|
+
locale,
|
131
|
+
extension,
|
132
|
+
index.zero?)
|
133
|
+
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
# Exports the locale for the corresponding extension
|
139
|
+
#
|
140
|
+
# @param [String] the locale
|
141
|
+
# @param [String] the extension, must include the `.`
|
142
|
+
def export(locale, extension)
|
143
|
+
|
144
|
+
optional_query_params = {}
|
145
|
+
if !@format.to_s.empty?
|
146
|
+
optional_query_params["format"] = @format
|
147
|
+
end
|
148
|
+
if @filter != nil && !filter.empty?
|
149
|
+
optional_query_params["filter"] = @filter.join(',')
|
150
|
+
end
|
151
|
+
if !@index.to_s.empty?
|
152
|
+
optional_query_params["index"] = @index
|
153
|
+
end
|
154
|
+
if !@source.to_s.empty?
|
155
|
+
optional_query_params["source"] = @source
|
156
|
+
end
|
157
|
+
if !@namespace.to_s.empty?
|
158
|
+
optional_query_params["namespace"] = @namespace
|
159
|
+
end
|
160
|
+
if !@fallback.to_s.empty?
|
161
|
+
optional_query_params["fallback"] = @fallback
|
162
|
+
end
|
163
|
+
if !@order.to_s.empty?
|
164
|
+
optional_query_params["order"] = @order
|
165
|
+
end
|
166
|
+
if !@status.to_s.empty?
|
167
|
+
optional_query_params["status"] = @status
|
168
|
+
end
|
169
|
+
if !@printf.to_s.empty?
|
170
|
+
optional_query_params["printf"] = @printf
|
171
|
+
end
|
172
|
+
if !@charset.to_s.empty?
|
173
|
+
optional_query_params["charset"] = @charset
|
174
|
+
end
|
175
|
+
if !@breaks.to_s.empty?
|
176
|
+
optional_query_params["breaks"] = @breaks
|
177
|
+
end
|
178
|
+
if !@no_comments.to_s.empty?
|
179
|
+
optional_query_params["no-comments"] = @no_comments
|
180
|
+
end
|
181
|
+
if !@no_folding.to_s.empty?
|
182
|
+
optional_query_params["no-folding"] = @no_folding
|
183
|
+
end
|
184
|
+
|
185
|
+
uri = URI::HTTPS.build(scheme: 'https',
|
186
|
+
host: 'localise.biz',
|
187
|
+
path: "/api/export/locale/#{locale}#{extension}",
|
188
|
+
query: URI.encode_www_form(optional_query_params)
|
189
|
+
)
|
190
|
+
|
191
|
+
res = Net::HTTP.start(uri.host, uri.port,
|
192
|
+
:use_ssl => uri.scheme == 'https') do |http|
|
193
|
+
req = Net::HTTP::Get.new(uri)
|
194
|
+
req['Authorization'] = "Loco #{@key}"
|
195
|
+
http.request req
|
196
|
+
end
|
197
|
+
|
198
|
+
if res.code == '200'
|
199
|
+
body = res.body
|
200
|
+
|
201
|
+
# Extracting charset because Net does not do it
|
202
|
+
content_type = res['Content-Type']
|
203
|
+
charset = /charset=([^ ;]*)/.match content_type
|
204
|
+
unless charset.nil?
|
205
|
+
body = body.force_encoding(charset.captures[0])
|
206
|
+
.encode('utf-8')
|
207
|
+
end
|
208
|
+
|
209
|
+
return body
|
210
|
+
end
|
211
|
+
|
212
|
+
warn 'URL failed: ' + uri.to_s
|
213
|
+
nil
|
214
|
+
end
|
215
|
+
|
216
|
+
def locale_directory(locale, is_default)
|
217
|
+
return File.join(@directory,
|
218
|
+
@adapter.directory(locale, is_default))
|
219
|
+
end
|
220
|
+
|
221
|
+
# Static method used to read a config file
|
222
|
+
def self.read_conf(path)
|
223
|
+
accepted_formats = [".json", ".yaml", ".yml"]
|
224
|
+
extension = File.extname(path)
|
225
|
+
|
226
|
+
if !accepted_formats.include?(extension)
|
227
|
+
raise "Unsupported config file format #{extension}, only JSON and YAML files are supported."
|
228
|
+
end
|
229
|
+
|
230
|
+
if extension == ".json"
|
231
|
+
json = JSON.parse(File.read(path))
|
232
|
+
return Config.new(json.each_with_object({}) { |(k, v), memo| memo[k.to_sym] = v; })
|
233
|
+
end
|
234
|
+
|
235
|
+
yaml = YAML.safe_load(File.read(path))
|
236
|
+
return Config.new(yaml.each_with_object({}) { |(k, v), memo| memo[k.to_sym] = v; })
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
class BaseAdapter
|
241
|
+
# ====================================
|
242
|
+
# Methods to override
|
243
|
+
|
244
|
+
# All the extensions allowed for that adapter
|
245
|
+
#
|
246
|
+
# This method is also used to determine what to load from the server
|
247
|
+
#
|
248
|
+
# Must be written with the '.' like '.xml'
|
249
|
+
#
|
250
|
+
# @return [Array] an array of all the allowed extensions
|
251
|
+
def allowed_extensions
|
252
|
+
return []
|
253
|
+
end
|
254
|
+
|
255
|
+
# Returns res directory for the mapped locale
|
256
|
+
#
|
257
|
+
# Base implementation does nothing
|
258
|
+
#
|
259
|
+
# @param [String] the mapped locale name
|
260
|
+
# @param [true] whether the locale is the default one
|
261
|
+
def directory(locale, is_default)
|
262
|
+
return ''
|
263
|
+
end
|
264
|
+
|
265
|
+
# Returns the default name
|
266
|
+
def default_file_name
|
267
|
+
return ''
|
268
|
+
end
|
269
|
+
|
270
|
+
# Writes the locale to a directory
|
271
|
+
def write_locale(directory,
|
272
|
+
result,
|
273
|
+
locale,
|
274
|
+
extension,
|
275
|
+
is_default)
|
276
|
+
path = File.join(directory, default_file_name + extension)
|
277
|
+
File.write path, result
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
class AndroidAdapter < BaseAdapter
|
282
|
+
def allowed_extensions
|
283
|
+
return ['.xml']
|
284
|
+
end
|
285
|
+
|
286
|
+
def directory(locale, is_default)
|
287
|
+
return is_default ? 'values' : "values-#{locale}"
|
288
|
+
end
|
289
|
+
|
290
|
+
def default_file_name
|
291
|
+
return 'strings'
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
class CocoaAdapter < BaseAdapter
|
296
|
+
def allowed_extensions
|
297
|
+
return ['.strings', '.stringsdict']
|
298
|
+
end
|
299
|
+
|
300
|
+
def directory(locale, is_default)
|
301
|
+
return "#{locale}.lproj"
|
302
|
+
end
|
303
|
+
|
304
|
+
def default_file_name
|
305
|
+
return 'Localizable'
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
class FlutterAdapter < BaseAdapter
|
310
|
+
def allowed_extensions
|
311
|
+
return ['.arb']
|
312
|
+
end
|
313
|
+
|
314
|
+
def default_file_name
|
315
|
+
return 'intl_messages_'
|
316
|
+
end
|
317
|
+
|
318
|
+
def write_locale(directory,
|
319
|
+
result,
|
320
|
+
locale,
|
321
|
+
extension,
|
322
|
+
is_default)
|
323
|
+
path = File.join(directory, default_file_name + locale + extension)
|
324
|
+
File.write path, result
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
class XamarinAdapter < BaseAdapter
|
329
|
+
def allowed_extensions
|
330
|
+
return ['.resx']
|
331
|
+
end
|
332
|
+
|
333
|
+
def default_file_name
|
334
|
+
return 'AppResources'
|
335
|
+
end
|
336
|
+
|
337
|
+
def write_locale(directory,
|
338
|
+
result,
|
339
|
+
locale,
|
340
|
+
extension,
|
341
|
+
is_default)
|
342
|
+
|
343
|
+
path = nil
|
344
|
+
if is_default
|
345
|
+
path = File.join(directory, default_file_name + extension)
|
346
|
+
else
|
347
|
+
path = File.join(directory, default_file_name + ".#{locale}" + extension)
|
348
|
+
end
|
349
|
+
|
350
|
+
File.write path, result
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
class CustomAdapter < BaseAdapter
|
355
|
+
def initialize(custom_extension:,
|
356
|
+
custom_file_name:)
|
357
|
+
@custom_extension = custom_extension
|
358
|
+
@custom_file_name = custom_file_name
|
359
|
+
end
|
360
|
+
|
361
|
+
attr_reader :custom_extension
|
362
|
+
attr_reader :custom_file_name
|
363
|
+
|
364
|
+
def allowed_extensions
|
365
|
+
return [@custom_extension]
|
366
|
+
end
|
367
|
+
|
368
|
+
def default_file_name
|
369
|
+
return @custom_file_name
|
370
|
+
end
|
371
|
+
|
372
|
+
def write_locale(directory,
|
373
|
+
result,
|
374
|
+
locale,
|
375
|
+
extension,
|
376
|
+
is_default)
|
377
|
+
|
378
|
+
path = nil
|
379
|
+
|
380
|
+
used_extension = extension
|
381
|
+
if !used_extension.start_with?('.')
|
382
|
+
used_extension = ".#{used_extension}"
|
383
|
+
end
|
384
|
+
|
385
|
+
if is_default
|
386
|
+
path = File.join(directory, default_file_name + used_extension)
|
387
|
+
else
|
388
|
+
path = File.join(directory, default_file_name + ".#{locale}" + used_extension)
|
389
|
+
end
|
390
|
+
|
391
|
+
File.write path, result
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
end
|
396
|
+
end
|
metadata
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fastlane-plugin-simple_loco
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yves Delcoigne
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-08-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec_junit_formatter
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
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
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.49.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.49.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-require_tools
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: fastlane
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 2.157.1
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 2.157.1
|
139
|
+
description:
|
140
|
+
email: yves_delcoigne@hotmail.com
|
141
|
+
executables: []
|
142
|
+
extensions: []
|
143
|
+
extra_rdoc_files: []
|
144
|
+
files:
|
145
|
+
- LICENSE
|
146
|
+
- README.md
|
147
|
+
- lib/fastlane/plugin/simple_loco.rb
|
148
|
+
- lib/fastlane/plugin/simple_loco/actions/simple_loco_action.rb
|
149
|
+
- lib/fastlane/plugin/simple_loco/helper/simple_loco_helper.rb
|
150
|
+
- lib/fastlane/plugin/simple_loco/version.rb
|
151
|
+
homepage: https://github.com/DelcoigneYves/fastlane-plugin-simple_loco
|
152
|
+
licenses:
|
153
|
+
- MIT
|
154
|
+
metadata: {}
|
155
|
+
post_install_message:
|
156
|
+
rdoc_options: []
|
157
|
+
require_paths:
|
158
|
+
- lib
|
159
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
requirements: []
|
170
|
+
rubygems_version: 3.0.3
|
171
|
+
signing_key:
|
172
|
+
specification_version: 4
|
173
|
+
summary: A simple implementation for exporting translations from Loco.
|
174
|
+
test_files: []
|