ETLane 0.1.42 → 0.1.46
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/Lanes/CommonFastfile +4 -8
- data/Lanes/actions/README.md +47 -0
- data/Lanes/actions/add_keys_to_lokalise.rb +106 -0
- data/Lanes/actions/android/README.md +53 -0
- data/Lanes/actions/android/lokalise_download.rb +144 -0
- data/Lanes/actions/android/lokalise_upload.rb +98 -0
- data/Lanes/actions/lokalise.rb +180 -0
- data/Lanes/actions/lokalise_metadata.rb +624 -0
- data/Lanes/actions/lokalise_upload.rb +165 -0
- data/Lanes/actions/previews.rb +157 -0
- data/Scripts/Sources/Common/Api.swift +142 -0
- data/Scripts/Sources/Common/Array.swift +8 -0
- data/Scripts/Sources/Common/Error.swift +10 -0
- data/Scripts/Sources/Common/MD5.swift +34 -0
- data/Scripts/Sources/Resources/Api+Figma.swift +43 -0
- data/Scripts/Sources/Resources/Deploy.swift +133 -0
- data/Scripts/Sources/Resources/Device.swift +42 -0
- data/Scripts/Sources/Resources/DownloadBatch.swift +108 -0
- data/Scripts/Sources/Resources/FigmaPages.swift +58 -0
- data/Scripts/Sources/Resources/Images.swift +5 -0
- data/Scripts/Sources/Resources/PreviewDownloader.swift +80 -0
- data/Scripts/Sources/Resources/ResourcesParser.swift +25 -0
- data/Scripts/Sources/Resources/ScreenshotDownloader.swift +150 -0
- data/Scripts/Sources/Resources/main.swift +58 -0
- metadata +25 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5146fbf20c0df981bb51ee0f37f91bece981ed31ca24389d218633006e08faec
|
4
|
+
data.tar.gz: dac0822eb320f54a86083f64854e3c966ec452fbabb44ba29bede0af00069196
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '086753d189a8cac283d86923f8106bc97b71c4c9acd64c3fe09670aae36499d5faad527c7cb857ac539c5355b77b5533acd18a04604e25b107ab538c547c33f7'
|
7
|
+
data.tar.gz: a45ac892f8da6b842b5e7520274ed3fab49ee3fc93f73c24566b390824f62951b7f13a7c683cf273a0a6e9691dc2d6308aba39afc95ebb177ccc20cc64dcf757
|
data/Lanes/CommonFastfile
CHANGED
@@ -10,7 +10,6 @@ platform :ios do
|
|
10
10
|
|
11
11
|
build_folder = File.join(Dir.pwd, "..", "build")
|
12
12
|
last_commit_path = File.join(Dir.pwd, "last_commit")
|
13
|
-
scripts_dir = File.join(Dir.pwd, "../Pods/ETLane/Scripts")
|
14
13
|
|
15
14
|
desc "Push a new beta build to TestFlight"
|
16
15
|
lane :beta do |options|
|
@@ -44,6 +43,7 @@ platform :ios do
|
|
44
43
|
},
|
45
44
|
)
|
46
45
|
last_commit = File.read(last_commit_path)
|
46
|
+
last_commit = last_commit.strip! || last_commit if last_commit
|
47
47
|
changelog = changelog_from_git_commits(
|
48
48
|
quiet: true,
|
49
49
|
between: [last_commit, "HEAD"], # Optional, lets you specify a revision/tag range between which to collect commit info
|
@@ -58,7 +58,6 @@ platform :ios do
|
|
58
58
|
branch_name = "feature/#{build_number}"
|
59
59
|
sh("git", "checkout", "-B", branch_name)
|
60
60
|
increment_and_push()
|
61
|
-
ENV["FL_CHANGELOG"] = nil
|
62
61
|
|
63
62
|
beta_app_review_info = {}
|
64
63
|
if ENV["ET_BETA_APP_REVIEW_INFO"]
|
@@ -70,7 +69,7 @@ platform :ios do
|
|
70
69
|
upload_to_testflight(
|
71
70
|
username: username,
|
72
71
|
beta_app_review_info: beta_app_review_info,
|
73
|
-
changelog:
|
72
|
+
changelog: changelog,
|
74
73
|
groups: ["#{distribute_group_name}"]
|
75
74
|
)
|
76
75
|
tag = get_version_number(target: project_name) + "." + build_number
|
@@ -120,11 +119,8 @@ platform :ios do
|
|
120
119
|
if download_screenshots
|
121
120
|
FileUtils.rm_rf(screenshots_path)
|
122
121
|
end
|
123
|
-
|
124
|
-
|
125
|
-
try_repo_update_on_error: true,
|
126
|
-
use_bundle_exec: true,
|
127
|
-
)
|
122
|
+
lane_path = %x( bundle info ETLane --path )
|
123
|
+
scripts_dir = File.join(lane_path.strip, "Scripts")
|
128
124
|
|
129
125
|
Dir.chdir(scripts_dir) do
|
130
126
|
sh(
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Lokalise Fastlane Actions
|
2
|
+
|
3
|
+
Collection of actions for integrating Lokalise into your iOS project using Fastlane. Learn more in our [blog post.](https://blog.lokalise.com/automating-itunes-connect-deployment-with-fastlane-and-lokalise/)
|
4
|
+
|
5
|
+
For Android actions please check [here](https://github.com/lokalise/lokalise-fastlane-actions/tree/master/android)
|
6
|
+
|
7
|
+
## Note
|
8
|
+
|
9
|
+
These are Fastlane actions, not plugins. Add them to `fastlane/actions` folder in the root of your project.
|
10
|
+
|
11
|
+
## lokalise
|
12
|
+
|
13
|
+
This action downloads .strings and .stringsdict files to destination folder.
|
14
|
+
|
15
|
+
Parameters:
|
16
|
+
|
17
|
+
- `api_token`. Your API token. Can be set up using enviromental parameter `LOKALISE_API_TOKEN`
|
18
|
+
- `project_identifier`. Your Project ID. Can be set up using enviromental parameter `LOKALISE_PROJECT_ID`
|
19
|
+
- `destination`. Localization files destination.
|
20
|
+
- `clean_destination`. Cleans destination folder if set to `true` *(`false` by default)*.
|
21
|
+
- `languages`. Languages to download *(must be passed as array of strings, leave empty to download all)*.
|
22
|
+
- `include_comments`. Include comments in exported files.
|
23
|
+
- `use_original`. Use original filenames/formats.
|
24
|
+
|
25
|
+
## lokalise_metadata
|
26
|
+
|
27
|
+
This action imports metadata from files generated by Deliver action and uploads iTunes Connect metadata using information from Lokalise.
|
28
|
+
|
29
|
+
- `api_token`. Your API token. Can be set up using enviromental parameter `LOKALISE_API_TOKEN`
|
30
|
+
- `project_identifier`. Your Project ID. Can be set up using enviromental parameter `LOKALISE_PROJECT_ID`
|
31
|
+
- `action`. Action to perform *(can be `update_lokalise_itunes`, `update_itunes`, `update_lokalise_googleplay` or `update_googleplay`)*.
|
32
|
+
- `add_languages`. Add missing languages to lokalise *(`false` by default)*.
|
33
|
+
- `override_translation`. Override translations in lokalise.
|
34
|
+
- `release_number`. Application release number. Required with `update_googleplay` action.
|
35
|
+
- `validate_only`. Only validate the metadata. Used with `update_googleplay` action *(`false` by default)*.
|
36
|
+
|
37
|
+
## add_keys_to_lokalise
|
38
|
+
|
39
|
+
This actions allow you upload keys to Lokalise.
|
40
|
+
|
41
|
+
Parameters:
|
42
|
+
|
43
|
+
- `api_token`. Your API token. Can be set up using enviromental parameter `LOKALISE_API_TOKEN`
|
44
|
+
- `project_identifier`. Your Project ID. Can be set up using enviromental parameter `LOKALISE_PROJECT_ID`
|
45
|
+
- `platform_mask`. Platform mask to asign to keys *(1 is iOS, 2 is Android, 4 is Web and 16 is Other)*.
|
46
|
+
- `keys`. Keys to add *(must be passed as array of strings)*.
|
47
|
+
|
@@ -0,0 +1,106 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Actions
|
3
|
+
|
4
|
+
class AddKeysToLokaliseAction < Action
|
5
|
+
def self.run(params)
|
6
|
+
require 'net/http'
|
7
|
+
|
8
|
+
token = params[:api_token]
|
9
|
+
project_identifier = params[:project_identifier]
|
10
|
+
keys = params[:keys]
|
11
|
+
platform_mask = params[:platform_mask]
|
12
|
+
|
13
|
+
keysObjects = []
|
14
|
+
|
15
|
+
keys.each do |key|
|
16
|
+
keysObjects << {
|
17
|
+
key: key,
|
18
|
+
platform_mask: platform_mask
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
request_data = {
|
23
|
+
api_token: token,
|
24
|
+
id: project_identifier,
|
25
|
+
data: keysObjects.to_json
|
26
|
+
}
|
27
|
+
|
28
|
+
uri = URI("https://api.lokalise.com/api/string/set")
|
29
|
+
request = Net::HTTP::Post.new(uri)
|
30
|
+
request.set_form_data(request_data)
|
31
|
+
|
32
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
33
|
+
http.use_ssl = true
|
34
|
+
response = http.request(request)
|
35
|
+
|
36
|
+
jsonResponse = JSON.parse(response.body)
|
37
|
+
raise "Bad response 🉐\n#{response.body}".red unless jsonResponse.kind_of? Hash
|
38
|
+
if jsonResponse["response"]["status"] == "success" then
|
39
|
+
inserted = jsonResponse["result"]["inserted"]
|
40
|
+
updated = jsonResponse["result"]["updated"]
|
41
|
+
Helper.log.info "Keys uploaded. #{inserted} inserted and #{updated} updated 🚀".green
|
42
|
+
elsif jsonResponse["response"]["status"] == "error"
|
43
|
+
code = jsonResponse["response"]["code"]
|
44
|
+
message = jsonResponse["response"]["message"]
|
45
|
+
raise "Response error code #{code} (#{message}) 📟".red
|
46
|
+
else
|
47
|
+
raise "Bad response 🉐\n#{jsonResponse}".red
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
#####################################################
|
52
|
+
# @!group Documentation
|
53
|
+
#####################################################
|
54
|
+
|
55
|
+
def self.description
|
56
|
+
"Add keys to lokalise"
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.available_options
|
60
|
+
[
|
61
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
62
|
+
env_name: "LOKALISE_API_TOKEN",
|
63
|
+
description: "API Token for Lokalise",
|
64
|
+
is_string: true,
|
65
|
+
verify_block: proc do |value|
|
66
|
+
raise "No API token for Lokalise given, pass using `api_token: 'token'`".red unless (value and not value.empty?)
|
67
|
+
end),
|
68
|
+
FastlaneCore::ConfigItem.new(key: :project_identifier,
|
69
|
+
env_name: "LOKALISE_PROJECT_ID",
|
70
|
+
description: "Lokalise Project Identifier",
|
71
|
+
is_string: true,
|
72
|
+
verify_block: proc do |value|
|
73
|
+
raise "No Project Identifier for Lokalise given, pass using `project_identifier: 'identifier'`".red unless (value and not value.empty?)
|
74
|
+
end),
|
75
|
+
FastlaneCore::ConfigItem.new(key: :platform_mask,
|
76
|
+
description: "Platform mask where 1 is iOS, 2 is Android, 4 is Web and 16 is Other",
|
77
|
+
optional: true,
|
78
|
+
is_string: false,
|
79
|
+
default_value: 1,
|
80
|
+
verify_block: proc do |value|
|
81
|
+
raise "Platfrom mask is an integer value".red unless value.is_a?(Integer)
|
82
|
+
end),
|
83
|
+
FastlaneCore::ConfigItem.new(key: :keys,
|
84
|
+
description: "Keys to add",
|
85
|
+
optional: false,
|
86
|
+
is_string: false,
|
87
|
+
verify_block: proc do |value|
|
88
|
+
raise "Keys must be passed as array of strings".red unless (value.kind_of? Array and not value.empty?)
|
89
|
+
value.each_with_index do |key, index|
|
90
|
+
raise "Key at index #{index} must be string".red unless key.kind_of? String
|
91
|
+
raise "Key at index #{index} can't be empty".red if key.empty?
|
92
|
+
end
|
93
|
+
end)
|
94
|
+
]
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.authors
|
98
|
+
"Fedya-L"
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.is_supported?(platform)
|
102
|
+
[:ios, :mac].include? platform
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Lokalise Fastlane Actions for Android
|
2
|
+
|
3
|
+
Fastlane actions for integrating Lokalise into your Android project using Fastlane.
|
4
|
+
|
5
|
+
All Android actions based on APIs V2
|
6
|
+
|
7
|
+
## Note
|
8
|
+
|
9
|
+
These are Fastlane actions, not plugins. Add them to `fastlane/actions` folder in the root of your project.
|
10
|
+
|
11
|
+
## lokalise_download
|
12
|
+
|
13
|
+
This action downloads strings.xml files to you main resources folder `./app/src/main/res`.
|
14
|
+
|
15
|
+
>That will replace your local strings.xml file with the latest version from lokalise project.
|
16
|
+
>So make sure to call lokalise_upload first to don't miss any added keys.
|
17
|
+
|
18
|
+
Parameters:
|
19
|
+
|
20
|
+
- `api_token`. Your API token. Can be set up using enviromental parameter `LOKALISE_API_TOKEN`
|
21
|
+
- `project_identifier`. Your Project ID. Can be set up using enviromental parameter `LOKALISE_PROJECT_ID`
|
22
|
+
- `languages`. Languages to download *(must be passed as array of strings)* Ex. `["en", "ar"]`.
|
23
|
+
|
24
|
+
Sample:
|
25
|
+
```
|
26
|
+
lokalise_download(
|
27
|
+
api_token: "YOUR_API_TOKEN",
|
28
|
+
project_identifier: "YOUR_PROJECT_ID",
|
29
|
+
languages: ["en", "ar"]
|
30
|
+
)
|
31
|
+
|
32
|
+
```
|
33
|
+
|
34
|
+
## lokalise_upload
|
35
|
+
|
36
|
+
This action uploads the new keys from your local strings.xml files to lokalise project.
|
37
|
+
|
38
|
+
- `api_token`. Your API token. Can be set up using enviromental parameter `LOKALISE_API_TOKEN`
|
39
|
+
- `project_identifier`. Your Project ID. Can be set up using enviromental parameter `LOKALISE_PROJECT_ID`
|
40
|
+
- `languages`. Languages to download *(must be passed as array of strings)* Ex. `["en", "ar"]`.
|
41
|
+
|
42
|
+
Sample:
|
43
|
+
```
|
44
|
+
lokalise_upload(
|
45
|
+
api_token: "YOUR_API_TOKEN",
|
46
|
+
project_identifier: "YOUR_PROJECT_ID",
|
47
|
+
languages: ["en", "ar"]
|
48
|
+
)
|
49
|
+
|
50
|
+
```
|
51
|
+
|
52
|
+
|
53
|
+
_All this actions are the basic ones, and can be enhanced for supporting flavors_
|
@@ -0,0 +1,144 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Actions
|
3
|
+
class LokaliseAction < Action
|
4
|
+
def self.run(params)
|
5
|
+
require 'net/http'
|
6
|
+
require 'json'
|
7
|
+
require 'zip'
|
8
|
+
require 'rubygems'
|
9
|
+
|
10
|
+
token = params[:api_token]
|
11
|
+
project_identifier = params[:project_identifier]
|
12
|
+
destination = params[:destination]
|
13
|
+
|
14
|
+
request_data = {
|
15
|
+
format: "xml",
|
16
|
+
original_filenames: false,
|
17
|
+
bundle_structure: "values-%LANG_ISO%/strings.%FORMAT%",
|
18
|
+
ota_plugin_bundle: 0,
|
19
|
+
export_empty: "base",
|
20
|
+
include_comments: false,
|
21
|
+
replace_breaks: true
|
22
|
+
}
|
23
|
+
|
24
|
+
languages = params[:languages]
|
25
|
+
if languages.kind_of? Array
|
26
|
+
request_data["langs"] = languages.to_json
|
27
|
+
end
|
28
|
+
|
29
|
+
tags = params[:tags]
|
30
|
+
if tags.kind_of? Array
|
31
|
+
request_data["include_tags"] = tags.to_json
|
32
|
+
end
|
33
|
+
|
34
|
+
uri = URI("https://api.lokalise.com/api2/projects/#{project_identifier}/files/download")
|
35
|
+
request = Net::HTTP::Post.new(uri)
|
36
|
+
request["content-type"] = 'application/json'
|
37
|
+
request["x-api-token"] = token
|
38
|
+
request.body = request_data.to_json
|
39
|
+
|
40
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
41
|
+
http.use_ssl = true
|
42
|
+
response = http.request(request)
|
43
|
+
|
44
|
+
jsonResponse = JSON.parse(response.body)
|
45
|
+
UI.error "Bad response 🉐\n#{response.body}" unless jsonResponse.kind_of? Hash
|
46
|
+
if jsonResponse["bundle_url"].kind_of?(String) then
|
47
|
+
UI.message "Downloading localizations archive 📦"
|
48
|
+
FileUtils.mkdir_p("lokalisetmp")
|
49
|
+
fileURL = jsonResponse["bundle_url"]
|
50
|
+
uri = URI(fileURL)
|
51
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
52
|
+
http.use_ssl = true
|
53
|
+
zipRequest = Net::HTTP::Get.new(uri)
|
54
|
+
response = http.request(zipRequest)
|
55
|
+
if response.content_type == "application/zip" or response.content_type == "application/octet-stream" then
|
56
|
+
FileUtils.mkdir_p("lokalisetmp")
|
57
|
+
open("lokalisetmp/a.zip", "wb") { |file|
|
58
|
+
file.write(response.body)
|
59
|
+
}
|
60
|
+
unzip_file("lokalisetmp/a.zip", destination)
|
61
|
+
FileUtils.remove_dir("lokalisetmp")
|
62
|
+
UI.success "Localizations extracted to #{destination} 📗 📕 📘"
|
63
|
+
else
|
64
|
+
UI.error "Response did not include ZIP"
|
65
|
+
end
|
66
|
+
elsif jsonResponse["error"]["code"].kind_of?(Integer)
|
67
|
+
code = jsonResponse["error"]["code"]
|
68
|
+
message = jsonResponse["error"]["message"]
|
69
|
+
UI.error "Response error code #{code} (#{message}) 📟"
|
70
|
+
else
|
71
|
+
UI.error "Bad response 🉐\n#{jsonResponse}"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
def self.unzip_file(file, destination)
|
77
|
+
Zip::File.open(file) { |zip_file|
|
78
|
+
UI.message "Unarchiving localizations to destination 📚"
|
79
|
+
zip_file.each { |f|
|
80
|
+
f_path= File.join(destination, f.name)
|
81
|
+
FileUtils.mkdir_p(File.dirname(f_path))
|
82
|
+
FileUtils.rm(f_path) if File.file? f_path
|
83
|
+
zip_file.extract(f, f_path)
|
84
|
+
}
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
#####################################################
|
90
|
+
# @!group Documentation
|
91
|
+
#####################################################
|
92
|
+
|
93
|
+
def self.description
|
94
|
+
"Download Android localization from Lokalise"
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.available_options
|
98
|
+
[
|
99
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
100
|
+
env_name: "LOKALISE_API_TOKEN",
|
101
|
+
description: "API Token for Lokalise",
|
102
|
+
verify_block: proc do |value|
|
103
|
+
UI.user_error! "No API token for Lokalise given, pass using `api_token: 'token'`" unless (value and not value.empty?)
|
104
|
+
end),
|
105
|
+
FastlaneCore::ConfigItem.new(key: :project_identifier,
|
106
|
+
env_name: "LOKALISE_PROJECT_ID",
|
107
|
+
description: "Lokalise Project ID",
|
108
|
+
verify_block: proc do |value|
|
109
|
+
UI.user_error! "No Project Identifier for Lokalise given, pass using `project_identifier: 'identifier'`" unless (value and not value.empty?)
|
110
|
+
end),
|
111
|
+
FastlaneCore::ConfigItem.new(key: :destination,
|
112
|
+
description: "Localization destination",
|
113
|
+
verify_block: proc do |value|
|
114
|
+
UI.user_error! "Things are pretty bad" unless (value and not value.empty?)
|
115
|
+
UI.user_error! "Directory you passed is in your imagination" unless File.directory?(value)
|
116
|
+
end),
|
117
|
+
FastlaneCore::ConfigItem.new(key: :languages,
|
118
|
+
description: "Languages to download",
|
119
|
+
optional: true,
|
120
|
+
is_string: false,
|
121
|
+
verify_block: proc do |value|
|
122
|
+
UI.user_error! "Language codes should be passed as array" unless value.kind_of? Array
|
123
|
+
end),
|
124
|
+
FastlaneCore::ConfigItem.new(key: :tags,
|
125
|
+
description: "Include only the keys tagged with a given set of tags",
|
126
|
+
optional: true,
|
127
|
+
is_string: false,
|
128
|
+
verify_block: proc do |value|
|
129
|
+
UI.user_error! "Tags should be passed as array" unless value.kind_of? Array
|
130
|
+
end),
|
131
|
+
|
132
|
+
]
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.authors
|
136
|
+
"simonkarmy"
|
137
|
+
end
|
138
|
+
|
139
|
+
def self.is_supported?(platform)
|
140
|
+
[:android].include? platform
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Actions
|
3
|
+
class LokaliseUploadAction < Action
|
4
|
+
def self.run(params)
|
5
|
+
require 'net/http'
|
6
|
+
require 'json'
|
7
|
+
require 'base64'
|
8
|
+
|
9
|
+
token = params[:api_token]
|
10
|
+
project_identifier = params[:project_identifier]
|
11
|
+
languages = params[:languages]
|
12
|
+
|
13
|
+
for lang_code in languages do
|
14
|
+
file_path = (lang_code == "en" ? "./app/src/main/res/values/strings.xml" : "./app/src/main/res/values-#{lang_code}/strings.xml")
|
15
|
+
self.upload_lang(token, project_identifier, lang_code, file_path)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.upload_lang(token, project_id, lang_code, lang_file_path)
|
20
|
+
|
21
|
+
file_data = File.open(lang_file_path, "r").read
|
22
|
+
file_data_64 = Base64.encode64(file_data).delete("\n")
|
23
|
+
|
24
|
+
request_data = {
|
25
|
+
filename: "strings.xml",
|
26
|
+
data: file_data_64 ,
|
27
|
+
lang_iso: lang_code,
|
28
|
+
convert_placeholders: true ,
|
29
|
+
slashn_to_linebreak: true
|
30
|
+
}
|
31
|
+
|
32
|
+
uri = URI("https://api.lokalise.com/api2/projects/#{project_id}/files/upload")
|
33
|
+
request = Net::HTTP::Post.new(uri)
|
34
|
+
request["content-type"] = 'application/json'
|
35
|
+
request["x-api-token"] = token
|
36
|
+
request.body = request_data.to_json
|
37
|
+
|
38
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
39
|
+
http.use_ssl = true
|
40
|
+
response = http.request(request)
|
41
|
+
|
42
|
+
jsonResponse = JSON.parse(response.body)
|
43
|
+
UI.error "Bad response 🉐\n#{response.body}" unless jsonResponse.kind_of? Hash
|
44
|
+
if jsonResponse["project_id"].kind_of?(String) then
|
45
|
+
UI.message "Uploaded localization file for #{lang_code} successfully #{jsonResponse["result"]}"
|
46
|
+
elsif jsonResponse["error"]["code"].kind_of?(Integer)
|
47
|
+
code = jsonResponse["error"]["code"]
|
48
|
+
message = jsonResponse["error"]["message"]
|
49
|
+
UI.error "Response error code #{code} (#{message}) 📟"
|
50
|
+
else
|
51
|
+
UI.error "Bad response 🉐\n#{jsonResponse}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
#####################################################
|
57
|
+
# @!group Documentation
|
58
|
+
#####################################################
|
59
|
+
|
60
|
+
def self.description
|
61
|
+
"Upload Android strings.xml to Lokalise"
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.available_options
|
65
|
+
[
|
66
|
+
FastlaneCore::ConfigItem.new(key: :api_token,
|
67
|
+
env_name: "LOKALISE_API_TOKEN",
|
68
|
+
description: "API Token for Lokalise",
|
69
|
+
verify_block: proc do |value|
|
70
|
+
UI.user_error! "No API token for Lokalise given, pass using `api_token: 'token'`" unless (value and not value.empty?)
|
71
|
+
end),
|
72
|
+
FastlaneCore::ConfigItem.new(key: :project_identifier,
|
73
|
+
env_name: "LOKALISE_PROJECT_ID",
|
74
|
+
description: "Lokalise Project ID",
|
75
|
+
verify_block: proc do |value|
|
76
|
+
UI.user_error! "No Project Identifier for Lokalise given, pass using `project_identifier: 'identifier'`" unless (value and not value.empty?)
|
77
|
+
end),
|
78
|
+
FastlaneCore::ConfigItem.new(key: :languages,
|
79
|
+
description: "Languages to download",
|
80
|
+
optional: true,
|
81
|
+
is_string: false,
|
82
|
+
verify_block: proc do |value|
|
83
|
+
UI.user_error! "Language codes should be passed as array" unless value.kind_of? Array
|
84
|
+
end),
|
85
|
+
|
86
|
+
]
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.authors
|
90
|
+
"simonkarmy"
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.is_supported?(platform)
|
94
|
+
[:android].include? platform
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|