fastlane-plugin-ovo_poeditor 1.0.0 → 1.1.0
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 051422ad4d30b1f8154f475883f0665e01e1db9a9f6fed969c003023e38b9e24
|
|
4
|
+
data.tar.gz: c9798a6ee87e8fa1b43a033ae28e600b9c486afd8c2d7acaf3353db909c0b206
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b2b34ca78e6c43ffc5e3d0e078d7c76165fb6611a9f347c2730f07fbbf322a514e49ed7c0f6221276664ad511a2898e1f56b5c1d4cb462085b0edf8b2e960b15
|
|
7
|
+
data.tar.gz: 0ec29fa34adfc6158442837519c01f0c5e715499d081a7b65b508fbeaa575ee2ac53d324ef26a02a02cc5cc02a2bd056a60855d10d3a9685ed97b6ce7635e408
|
data/README.md
CHANGED
|
@@ -55,7 +55,12 @@ ovo_poeditor_strings(
|
|
|
55
55
|
languages: ["fr", "en", "it", "ru"],
|
|
56
56
|
output_dir: "./values",
|
|
57
57
|
file_format: "android_strings",
|
|
58
|
-
file_name: "strings.xml"
|
|
58
|
+
file_name: "strings.xml",
|
|
59
|
+
default_language: 'default-lang',
|
|
60
|
+
language_map: {
|
|
61
|
+
'language1' => 'language-country1',
|
|
62
|
+
'language2' => 'language-country2'
|
|
63
|
+
}
|
|
59
64
|
)
|
|
60
65
|
```
|
|
61
66
|
|
|
@@ -11,6 +11,9 @@ module Fastlane
|
|
|
11
11
|
output_dir = params[:output_dir]
|
|
12
12
|
file_format = params[:file_format]
|
|
13
13
|
file_name = params[:file_name]
|
|
14
|
+
default_language = params[:default_language]
|
|
15
|
+
language_map = params[:language_map]
|
|
16
|
+
unquoted_strings = params[:unquoted_strings]
|
|
14
17
|
|
|
15
18
|
Helper::OvoPoeditorHelper.sync_strings(
|
|
16
19
|
api_token: api_token,
|
|
@@ -18,76 +21,103 @@ module Fastlane
|
|
|
18
21
|
languages: languages,
|
|
19
22
|
output_dir: output_dir,
|
|
20
23
|
file_format: file_format,
|
|
21
|
-
file_name: file_name
|
|
24
|
+
file_name: file_name,
|
|
25
|
+
default_language: default_language,
|
|
26
|
+
language_map: language_map,
|
|
27
|
+
unquoted_strings: unquoted_strings
|
|
22
28
|
)
|
|
23
29
|
end
|
|
24
30
|
|
|
25
31
|
def self.description
|
|
26
|
-
|
|
32
|
+
'Fetch latest POEditor terms and download them as .strings/.xml/.xcstrings file'
|
|
27
33
|
end
|
|
28
34
|
|
|
29
35
|
def self.authors
|
|
30
|
-
[
|
|
36
|
+
['Alessio Arsuffi']
|
|
31
37
|
end
|
|
32
38
|
|
|
33
39
|
def self.return_value
|
|
34
40
|
# If your method provides a return value, you can describe here what it does
|
|
35
|
-
|
|
41
|
+
'Return a file with all POEditor terms'
|
|
36
42
|
end
|
|
37
43
|
|
|
38
44
|
def self.details
|
|
39
45
|
# Optional:
|
|
40
|
-
|
|
46
|
+
'Fetch latest POEditor terms and download them as .strings/.xml/.xcstrings file'
|
|
41
47
|
end
|
|
42
48
|
|
|
43
49
|
def self.available_options
|
|
44
50
|
[
|
|
45
51
|
FastlaneCore::ConfigItem.new(
|
|
46
52
|
key: :api_token,
|
|
47
|
-
env_name:
|
|
48
|
-
description:
|
|
53
|
+
env_name: 'POEDITOR_API_TOKEN',
|
|
54
|
+
description: 'POEditor API token (read-only recommended)',
|
|
49
55
|
optional: false,
|
|
50
56
|
type: String
|
|
51
57
|
),
|
|
52
58
|
FastlaneCore::ConfigItem.new(
|
|
53
59
|
key: :project_id,
|
|
54
|
-
env_name:
|
|
55
|
-
description:
|
|
60
|
+
env_name: 'POEDITOR_PROJECT_ID',
|
|
61
|
+
description: 'POEditor project ID',
|
|
56
62
|
optional: false,
|
|
57
63
|
type: String
|
|
58
64
|
),
|
|
59
65
|
FastlaneCore::ConfigItem.new(
|
|
60
66
|
key: :languages,
|
|
61
|
-
env_name:
|
|
62
|
-
description:
|
|
67
|
+
env_name: 'POEDITOR_LANGUAGES',
|
|
68
|
+
description: 'List of language codes to export (e.g. ["en", "it"])',
|
|
63
69
|
optional: false,
|
|
64
70
|
type: Array
|
|
65
71
|
),
|
|
66
72
|
FastlaneCore::ConfigItem.new(
|
|
67
73
|
key: :output_dir,
|
|
68
|
-
env_name:
|
|
69
|
-
description:
|
|
74
|
+
env_name: 'POEDITOR_OUTPUT_DIR',
|
|
75
|
+
description: 'Output directory where the localized files will be written',
|
|
70
76
|
optional: false,
|
|
71
77
|
type: String
|
|
72
78
|
),
|
|
73
79
|
FastlaneCore::ConfigItem.new(
|
|
74
80
|
key: :file_name,
|
|
75
|
-
env_name:
|
|
76
|
-
description:
|
|
81
|
+
env_name: 'POEDITOR_FILE_NAME',
|
|
82
|
+
description: 'Output file name to write (e.g. Localizable.strings, strings.xml)',
|
|
77
83
|
optional: false,
|
|
78
84
|
type: String
|
|
79
85
|
),
|
|
80
86
|
FastlaneCore::ConfigItem.new(
|
|
81
87
|
key: :file_format,
|
|
82
|
-
env_name:
|
|
83
|
-
description:
|
|
88
|
+
env_name: 'POEDITOR_EXPORT_FILE_FORMAT',
|
|
89
|
+
description: 'Export file format: xcstrings, apple_strings, android_strings',
|
|
84
90
|
optional: false,
|
|
85
91
|
type: String
|
|
92
|
+
),
|
|
93
|
+
FastlaneCore::ConfigItem.new(
|
|
94
|
+
key: :default_language,
|
|
95
|
+
env_name: 'POEDITOR_DEFAULT_LANGUAGE',
|
|
96
|
+
description: 'Default/fallback language code for the project',
|
|
97
|
+
optional: true,
|
|
98
|
+
type: String
|
|
99
|
+
),
|
|
100
|
+
FastlaneCore::ConfigItem.new(
|
|
101
|
+
key: :language_map,
|
|
102
|
+
description: 'Map POEditor language codes to platform-specific folder names',
|
|
103
|
+
optional: true,
|
|
104
|
+
type: Hash
|
|
105
|
+
),
|
|
106
|
+
FastlaneCore::ConfigItem.new(
|
|
107
|
+
key: :unquoted_strings,
|
|
108
|
+
env_name: 'POEDITOR_UNQUOTED_STRINGS',
|
|
109
|
+
description: 'Set to 1 to export Android strings without quotes (unquoted). Allowed values: 0 or 1',
|
|
110
|
+
optional: true,
|
|
111
|
+
type: Integer,
|
|
112
|
+
default_value: 0,
|
|
113
|
+
verify_block: proc do |value|
|
|
114
|
+
UI.user_error!("unquoted_strings (POEDITOR_UNQUOTED_STRINGS) must be 0 or 1. Received: #{value}.") unless [0, 1].include?(value)
|
|
115
|
+
end
|
|
86
116
|
)
|
|
87
117
|
]
|
|
88
118
|
end
|
|
89
119
|
|
|
90
|
-
def self.is_supported?(
|
|
120
|
+
def self.is_supported?(_platform)
|
|
91
121
|
true
|
|
92
122
|
end
|
|
93
123
|
end
|
|
@@ -10,9 +10,19 @@ module Fastlane
|
|
|
10
10
|
|
|
11
11
|
module Helper
|
|
12
12
|
class OvoPoeditorHelper
|
|
13
|
-
@supported_export_types = [
|
|
14
|
-
|
|
15
|
-
def self.sync_strings(
|
|
13
|
+
@supported_export_types = %w[apple_strings xcstrings android_strings].freeze
|
|
14
|
+
|
|
15
|
+
def self.sync_strings(
|
|
16
|
+
api_token:,
|
|
17
|
+
project_id:,
|
|
18
|
+
languages:,
|
|
19
|
+
output_dir:,
|
|
20
|
+
file_format:,
|
|
21
|
+
file_name:,
|
|
22
|
+
default_language:,
|
|
23
|
+
language_map:,
|
|
24
|
+
unquoted_strings:
|
|
25
|
+
)
|
|
16
26
|
unless @supported_export_types.include?(file_format)
|
|
17
27
|
UI.error("Invalid export type '#{file_format}'. Allowed values: #{@supported_export_types.join(', ')}")
|
|
18
28
|
end
|
|
@@ -24,7 +34,8 @@ module Fastlane
|
|
|
24
34
|
api_token: api_token,
|
|
25
35
|
project_id: project_id,
|
|
26
36
|
language: language,
|
|
27
|
-
file_format: file_format
|
|
37
|
+
file_format: file_format,
|
|
38
|
+
unquoted_strings: unquoted_strings
|
|
28
39
|
)
|
|
29
40
|
|
|
30
41
|
if export_url.nil?
|
|
@@ -35,7 +46,7 @@ module Fastlane
|
|
|
35
46
|
strings_data = download_file(export_url, language)
|
|
36
47
|
next unless strings_data
|
|
37
48
|
|
|
38
|
-
output_path = build_output_path(output_dir, language, file_name, file_format)
|
|
49
|
+
output_path = build_output_path(output_dir, language, file_name, file_format, default_language, language_map)
|
|
39
50
|
|
|
40
51
|
begin
|
|
41
52
|
FileUtils.mkdir_p(File.dirname(output_path))
|
|
@@ -49,18 +60,19 @@ module Fastlane
|
|
|
49
60
|
end
|
|
50
61
|
end
|
|
51
62
|
|
|
52
|
-
def self.fetch_export_url(api_token:, project_id:, language:, file_format:)
|
|
53
|
-
uri = URI(
|
|
63
|
+
def self.fetch_export_url(api_token:, project_id:, language:, file_format:, unquoted_strings:)
|
|
64
|
+
uri = URI('https://api.poeditor.com/v2/projects/export')
|
|
54
65
|
request = Net::HTTP::Post.new(uri)
|
|
55
66
|
|
|
56
67
|
form_data = {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
68
|
+
'api_token' => api_token,
|
|
69
|
+
'id' => project_id,
|
|
70
|
+
'language' => language,
|
|
71
|
+
'order' => 'terms',
|
|
72
|
+
'type' => file_format
|
|
62
73
|
}
|
|
63
|
-
form_data[
|
|
74
|
+
form_data['options'] = '[{"export_all":1}]' if file_format == 'xcstrings'
|
|
75
|
+
form_data['options'] = "[{'unquoted': #{unquoted_strings}}]" if file_format == 'android_strings'
|
|
64
76
|
|
|
65
77
|
request.set_form_data(form_data)
|
|
66
78
|
|
|
@@ -71,7 +83,7 @@ module Fastlane
|
|
|
71
83
|
return nil unless response.is_a?(Net::HTTPSuccess)
|
|
72
84
|
|
|
73
85
|
result = JSON.parse(response.body)
|
|
74
|
-
result.dig(
|
|
86
|
+
result.dig('result', 'url')
|
|
75
87
|
rescue JSON::ParserError => e
|
|
76
88
|
UI.error("Failed to parse POEditor response: #{e.message}")
|
|
77
89
|
nil
|
|
@@ -79,18 +91,27 @@ module Fastlane
|
|
|
79
91
|
|
|
80
92
|
def self.download_file(url, language)
|
|
81
93
|
URI.open(url).read
|
|
82
|
-
rescue => e
|
|
94
|
+
rescue StandardError => e
|
|
83
95
|
UI.error("Error downloading file for language '#{language}': #{e.message}")
|
|
84
96
|
nil
|
|
85
97
|
end
|
|
86
98
|
|
|
87
|
-
def self.build_output_path(base_dir, language, file_name, format)
|
|
88
|
-
if format ==
|
|
99
|
+
def self.build_output_path(base_dir, language, file_name, format, default_language, language_map)
|
|
100
|
+
if format == 'xcstrings'
|
|
89
101
|
"#{base_dir}/#{file_name}"
|
|
90
|
-
elsif format ==
|
|
102
|
+
elsif format == 'apple_strings'
|
|
91
103
|
"#{base_dir}/#{language}.lproj/#{file_name}"
|
|
104
|
+
elsif language == default_language
|
|
105
|
+
"#{base_dir}/values/#{file_name}"
|
|
92
106
|
else
|
|
93
|
-
|
|
107
|
+
mapped_language = language_map&.[](language.to_s)
|
|
108
|
+
values_folder = if mapped_language.nil? || mapped_language.empty?
|
|
109
|
+
"values-#{language}"
|
|
110
|
+
else
|
|
111
|
+
"values-#{mapped_language}"
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
"#{base_dir}/#{values_folder}/#{file_name}"
|
|
94
115
|
end
|
|
95
116
|
end
|
|
96
117
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fastlane-plugin-ovo_poeditor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alessio Arsuffi
|
|
@@ -32,7 +32,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
32
32
|
requirements:
|
|
33
33
|
- - ">="
|
|
34
34
|
- !ruby/object:Gem::Version
|
|
35
|
-
version: '
|
|
35
|
+
version: '3.0'
|
|
36
36
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - ">="
|