fastlane-plugin-ovo_poeditor 1.0.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 +7 -0
- data/LICENSE +21 -0
- data/README.md +96 -0
- data/lib/fastlane/plugin/ovo_poeditor/actions/ovo_poeditor_strings_action.rb +95 -0
- data/lib/fastlane/plugin/ovo_poeditor/helper/ovo_poeditor_helper.rb +98 -0
- data/lib/fastlane/plugin/ovo_poeditor/version.rb +5 -0
- data/lib/fastlane/plugin/ovo_poeditor.rb +16 -0
- metadata +46 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: eaa989467e195285f9da509bfff7d80c8d88071d2f5725a7ab009dde29cf56d0
|
|
4
|
+
data.tar.gz: 74d78ea4d189e71546e89d621058cf6152d2e585b9cb536921606cde84b7d44d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e68fac94606eefb45e9e47eb8b8f097c2bd23dc6281b7e5b754f286f9a36078debee4820cd8b3b629e9eb91b6a10b975e44ce9b7c73698c3fe5bbd7ea5e25605
|
|
7
|
+
data.tar.gz: 04d1404d97ed221e85e2c674c45673593a9fcf1217a9e70cf77e7eff3496d305907b5c3a1339ac86ebb830442095f1e140cded4fc099b9e340b351d9ce5102cc
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Alessio Arsuffi <alessio.arsuffi@ovolab.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,96 @@
|
|
|
1
|
+
# Ovo POEditor Plugin
|
|
2
|
+
|
|
3
|
+
[](https://rubygems.org/gems/fastlane-plugin-ovo_poeditor)
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-ovo_poeditor`, add it to your project by running:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
fastlane add_plugin ovo_poeditor
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## About Ovo POEditor
|
|
14
|
+
|
|
15
|
+
Fetch latest POEditor terms and download them as `.xcstrings/.strings/.xml` file
|
|
16
|
+
|
|
17
|
+
## Available Actions
|
|
18
|
+
|
|
19
|
+
### ovo_poeditor_strings
|
|
20
|
+
|
|
21
|
+
This action will download the latest terms from POEditor to the specified `output_dir` in the specified `file_format`.
|
|
22
|
+
|
|
23
|
+
#### iOS
|
|
24
|
+
|
|
25
|
+
##### `xcstrings`:
|
|
26
|
+
```ruby
|
|
27
|
+
ovo_poeditor_strings(
|
|
28
|
+
api_token: "api_token",
|
|
29
|
+
project_id: "project_id",
|
|
30
|
+
languages: ["fr"],
|
|
31
|
+
output_dir: "./XCStrings",
|
|
32
|
+
file_format: "xcstrings",
|
|
33
|
+
file_name: "Localizable.xcstrings"
|
|
34
|
+
)
|
|
35
|
+
```
|
|
36
|
+
NB: when `file_format: "xcstrings"`, you can pass a single language to the script, it will export all the available languages in the project to the `.xcstrings` file.
|
|
37
|
+
|
|
38
|
+
##### `strings`:
|
|
39
|
+
```ruby
|
|
40
|
+
ovo_poeditor_strings(
|
|
41
|
+
api_token: "api_token",
|
|
42
|
+
project_id: "project_id",
|
|
43
|
+
languages: ["fr", "en", "it", "ru"],
|
|
44
|
+
output_dir: "./Strings",
|
|
45
|
+
file_format: "apple_strings",
|
|
46
|
+
file_name: "Localizable.strings"
|
|
47
|
+
)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
#### Android
|
|
51
|
+
```ruby
|
|
52
|
+
ovo_poeditor_strings(
|
|
53
|
+
api_token: "api_token",
|
|
54
|
+
project_id: "project_id",
|
|
55
|
+
languages: ["fr", "en", "it", "ru"],
|
|
56
|
+
output_dir: "./values",
|
|
57
|
+
file_format: "android_strings",
|
|
58
|
+
file_name: "strings.xml"
|
|
59
|
+
)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
## Example
|
|
64
|
+
|
|
65
|
+
Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
|
|
66
|
+
|
|
67
|
+
**Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
|
|
68
|
+
|
|
69
|
+
## Run tests for this plugin
|
|
70
|
+
|
|
71
|
+
To run both the tests, and code style validation, run
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
rake
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
To automatically fix many of the styling issues, use
|
|
78
|
+
```
|
|
79
|
+
rubocop -a
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Issues and Feedback
|
|
83
|
+
|
|
84
|
+
For any other issues and feedback about this plugin, please submit it to this repository.
|
|
85
|
+
|
|
86
|
+
## Troubleshooting
|
|
87
|
+
|
|
88
|
+
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
|
|
89
|
+
|
|
90
|
+
## Using _fastlane_ Plugins
|
|
91
|
+
|
|
92
|
+
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
|
|
93
|
+
|
|
94
|
+
## About _fastlane_
|
|
95
|
+
|
|
96
|
+
_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,95 @@
|
|
|
1
|
+
require 'fastlane/action'
|
|
2
|
+
require_relative '../helper/ovo_poeditor_helper'
|
|
3
|
+
|
|
4
|
+
module Fastlane
|
|
5
|
+
module Actions
|
|
6
|
+
class OvoPoeditorStringsAction < Action
|
|
7
|
+
def self.run(params)
|
|
8
|
+
api_token = params[:api_token]
|
|
9
|
+
project_id = params[:project_id]
|
|
10
|
+
languages = params[:languages]
|
|
11
|
+
output_dir = params[:output_dir]
|
|
12
|
+
file_format = params[:file_format]
|
|
13
|
+
file_name = params[:file_name]
|
|
14
|
+
|
|
15
|
+
Helper::OvoPoeditorHelper.sync_strings(
|
|
16
|
+
api_token: api_token,
|
|
17
|
+
project_id: project_id,
|
|
18
|
+
languages: languages,
|
|
19
|
+
output_dir: output_dir,
|
|
20
|
+
file_format: file_format,
|
|
21
|
+
file_name: file_name
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.description
|
|
26
|
+
"Fetch latest POEditor terms and download them as .strings/.xml/.xcstrings file"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.authors
|
|
30
|
+
["Alessio Arsuffi"]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.return_value
|
|
34
|
+
# If your method provides a return value, you can describe here what it does
|
|
35
|
+
"Return a file with all POEditor terms"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.details
|
|
39
|
+
# Optional:
|
|
40
|
+
"Fetch latest POEditor terms and download them as .strings/.xml/.xcstrings file"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.available_options
|
|
44
|
+
[
|
|
45
|
+
FastlaneCore::ConfigItem.new(
|
|
46
|
+
key: :api_token,
|
|
47
|
+
env_name: "POEDITOR_API_TOKEN",
|
|
48
|
+
description: "POEditor read-only API Token",
|
|
49
|
+
optional: false,
|
|
50
|
+
type: String
|
|
51
|
+
),
|
|
52
|
+
FastlaneCore::ConfigItem.new(
|
|
53
|
+
key: :project_id,
|
|
54
|
+
env_name: "POEDITOR_PROJECT_ID",
|
|
55
|
+
description: "POEditor Project ID",
|
|
56
|
+
optional: false,
|
|
57
|
+
type: String
|
|
58
|
+
),
|
|
59
|
+
FastlaneCore::ConfigItem.new(
|
|
60
|
+
key: :languages,
|
|
61
|
+
env_name: "POEDITOR_LANGUAGES",
|
|
62
|
+
description: "The languages to export strings for",
|
|
63
|
+
optional: false,
|
|
64
|
+
type: Array
|
|
65
|
+
),
|
|
66
|
+
FastlaneCore::ConfigItem.new(
|
|
67
|
+
key: :output_dir,
|
|
68
|
+
env_name: "POEDITOR_OUTPUT_DIR",
|
|
69
|
+
description: "Directory containing strings file",
|
|
70
|
+
optional: false,
|
|
71
|
+
type: String
|
|
72
|
+
),
|
|
73
|
+
FastlaneCore::ConfigItem.new(
|
|
74
|
+
key: :file_name,
|
|
75
|
+
env_name: "POEDITOR_FILE_NAME",
|
|
76
|
+
description: "The name of the file to be downloaded",
|
|
77
|
+
optional: false,
|
|
78
|
+
type: String
|
|
79
|
+
),
|
|
80
|
+
FastlaneCore::ConfigItem.new(
|
|
81
|
+
key: :file_format,
|
|
82
|
+
env_name: "POEDITOR_EXPORT_FILE_FORMAT",
|
|
83
|
+
description: "Export file format (xcstrings, apple_strings, android_strings)",
|
|
84
|
+
optional: false,
|
|
85
|
+
type: String
|
|
86
|
+
)
|
|
87
|
+
]
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def self.is_supported?(platform)
|
|
91
|
+
true
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
require 'fastlane_core/ui/ui'
|
|
2
|
+
require 'fastlane'
|
|
3
|
+
|
|
4
|
+
require 'json'
|
|
5
|
+
require 'open-uri'
|
|
6
|
+
require 'fileutils'
|
|
7
|
+
|
|
8
|
+
module Fastlane
|
|
9
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
|
|
10
|
+
|
|
11
|
+
module Helper
|
|
12
|
+
class OvoPoeditorHelper
|
|
13
|
+
@supported_export_types = ["apple_strings", "xcstrings", "android_strings"].freeze
|
|
14
|
+
|
|
15
|
+
def self.sync_strings(api_token:, project_id:, languages:, output_dir:, file_format:, file_name:)
|
|
16
|
+
unless @supported_export_types.include?(file_format)
|
|
17
|
+
UI.error("Invalid export type '#{file_format}'. Allowed values: #{@supported_export_types.join(', ')}")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
languages.each do |language|
|
|
21
|
+
UI.message("Fetching terms for language: #{language}")
|
|
22
|
+
|
|
23
|
+
export_url = fetch_export_url(
|
|
24
|
+
api_token: api_token,
|
|
25
|
+
project_id: project_id,
|
|
26
|
+
language: language,
|
|
27
|
+
file_format: file_format
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
if export_url.nil?
|
|
31
|
+
UI.error("No export URL for language '#{language}'. Please check if it's enabled in POEditor.")
|
|
32
|
+
next
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
strings_data = download_file(export_url, language)
|
|
36
|
+
next unless strings_data
|
|
37
|
+
|
|
38
|
+
output_path = build_output_path(output_dir, language, file_name, file_format)
|
|
39
|
+
|
|
40
|
+
begin
|
|
41
|
+
FileUtils.mkdir_p(File.dirname(output_path))
|
|
42
|
+
File.write(output_path, strings_data)
|
|
43
|
+
UI.success("Downloaded localization file for #{language} to #{output_path}")
|
|
44
|
+
rescue Errno::EACCES => e
|
|
45
|
+
UI.error("Permission denied while writing to #{output_path}: #{e.message}")
|
|
46
|
+
rescue IOError, SystemCallError => e
|
|
47
|
+
UI.error("Failed to write file for #{language}: #{e.message}")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def self.fetch_export_url(api_token:, project_id:, language:, file_format:)
|
|
53
|
+
uri = URI("https://api.poeditor.com/v2/projects/export")
|
|
54
|
+
request = Net::HTTP::Post.new(uri)
|
|
55
|
+
|
|
56
|
+
form_data = {
|
|
57
|
+
"api_token" => api_token,
|
|
58
|
+
"id" => project_id,
|
|
59
|
+
"language" => language,
|
|
60
|
+
"order" => "terms",
|
|
61
|
+
"type" => file_format
|
|
62
|
+
}
|
|
63
|
+
form_data["options"] = '[{"export_all":1}]' if file_format == "xcstrings"
|
|
64
|
+
|
|
65
|
+
request.set_form_data(form_data)
|
|
66
|
+
|
|
67
|
+
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
|
68
|
+
http.request(request)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
return nil unless response.is_a?(Net::HTTPSuccess)
|
|
72
|
+
|
|
73
|
+
result = JSON.parse(response.body)
|
|
74
|
+
result.dig("result", "url")
|
|
75
|
+
rescue JSON::ParserError => e
|
|
76
|
+
UI.error("Failed to parse POEditor response: #{e.message}")
|
|
77
|
+
nil
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def self.download_file(url, language)
|
|
81
|
+
URI.open(url).read
|
|
82
|
+
rescue => e
|
|
83
|
+
UI.error("Error downloading file for language '#{language}': #{e.message}")
|
|
84
|
+
nil
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def self.build_output_path(base_dir, language, file_name, format)
|
|
88
|
+
if format == "xcstrings"
|
|
89
|
+
"#{base_dir}/#{file_name}"
|
|
90
|
+
elsif format == "apple_strings"
|
|
91
|
+
"#{base_dir}/#{language}.lproj/#{file_name}"
|
|
92
|
+
else
|
|
93
|
+
"#{base_dir}/#{language}/#{file_name}"
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'fastlane/plugin/ovo_poeditor/version'
|
|
2
|
+
|
|
3
|
+
module Fastlane
|
|
4
|
+
module OvoPoeditor
|
|
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::OvoPoeditor.all_classes.each do |current|
|
|
15
|
+
require current
|
|
16
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: fastlane-plugin-ovo_poeditor
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Alessio Arsuffi
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
email: alessio.arsuffi@ovolab.com
|
|
13
|
+
executables: []
|
|
14
|
+
extensions: []
|
|
15
|
+
extra_rdoc_files: []
|
|
16
|
+
files:
|
|
17
|
+
- LICENSE
|
|
18
|
+
- README.md
|
|
19
|
+
- lib/fastlane/plugin/ovo_poeditor.rb
|
|
20
|
+
- lib/fastlane/plugin/ovo_poeditor/actions/ovo_poeditor_strings_action.rb
|
|
21
|
+
- lib/fastlane/plugin/ovo_poeditor/helper/ovo_poeditor_helper.rb
|
|
22
|
+
- lib/fastlane/plugin/ovo_poeditor/version.rb
|
|
23
|
+
homepage: https://github.com/ovolab/fastlane-plugin-ovo_poeditor
|
|
24
|
+
licenses:
|
|
25
|
+
- MIT
|
|
26
|
+
metadata:
|
|
27
|
+
rubygems_mfa_required: 'true'
|
|
28
|
+
rdoc_options: []
|
|
29
|
+
require_paths:
|
|
30
|
+
- lib
|
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '2.6'
|
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
requirements: []
|
|
42
|
+
rubygems_version: 3.6.9
|
|
43
|
+
specification_version: 4
|
|
44
|
+
summary: Fetch latest POEditor terms and download them as .xcstrings and .strings
|
|
45
|
+
file
|
|
46
|
+
test_files: []
|