fastlane-plugin-translate 0.3.0 → 0.3.1

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: cb50e549d9a01fa0537ad44d52a80ddb8fb372417336eb31e2455b684f84ecba
4
- data.tar.gz: c9a6afa40d2c1d40fc07cc1bf4a143f71db9603519c4a9c20cbdd356adf56ce9
3
+ metadata.gz: 84a340dcd01c9646d94cab2d3d5506f5a19aaef2f0eef88002e6d6562d87aa7c
4
+ data.tar.gz: 106704f3f1042b56f6e9a448a15257458db846722f070aa3bb8ce616f6e73499
5
5
  SHA512:
6
- metadata.gz: ce8b51d5e1c16e0249d56b90c2b1500dcbcb4d82560e6d64da3c1a88753e0f13a96d21110c9f743613ec168a029f0f2dc9dd7ad48dc988d258e3d4d7ef8942e2
7
- data.tar.gz: 682624a1f320c81a3304d3a6dab231909e3c6dce4a0e7c7b7c624db178afc312a57d7dd760df983a8f126352149b5610db5c077a07f9a92bf0250be036d44936
6
+ metadata.gz: e93d40e4ca1fcc375f9bcc216fd60c3135d5db2f7fa0615212b0dfbe5a2003a592410d0c6bfb7dc0b0a9a74628451cd54cc80cf8bba96708f7061dca751f9456
7
+ data.tar.gz: 1a4683fb3b08ef928faae6495b8a86cbc02c4539cb5eebc73c462d4209935508350fc95a211aa57e5284b69be445291c1feb1bfd36e39dc98e3b1710ae53d32f
@@ -87,19 +87,50 @@ module Fastlane
87
87
  end
88
88
 
89
89
  def self.setup_deepl_client(params)
90
- DeepL.configure do |config|
91
- config.auth_key = params[:api_token]
92
- config.host = params[:free_api] ? 'https://api-free.deepl.com' : 'https://api.deepl.com'
90
+ # If free_api is explicitly set, use that configuration
91
+ if params[:free_api] != nil
92
+ DeepL.configure do |config|
93
+ config.auth_key = params[:api_token]
94
+ config.host = params[:free_api] ? 'https://api-free.deepl.com' : 'https://api.deepl.com'
95
+ end
96
+
97
+ begin
98
+ DeepL.usage
99
+ api_type = params[:free_api] ? 'Free' : 'Pro'
100
+ UI.success("✅ DeepL API key validated (#{api_type} API)")
101
+ return
102
+ rescue DeepL::Exceptions::AuthorizationFailed
103
+ UI.user_error!('❌ Invalid DeepL API key. Get one at: https://www.deepl.com/pro#developer')
104
+ rescue StandardError => e
105
+ UI.user_error!("❌ DeepL API connection failed: #{e.message}")
106
+ end
93
107
  end
94
108
 
95
- # Test API key
96
- begin
97
- DeepL.usage
98
- UI.success(' DeepL API key validated')
99
- rescue DeepL::Exceptions::AuthorizationFailed
100
- UI.user_error!('❌ Invalid DeepL API key. Get one at: https://www.deepl.com/pro#developer')
101
- rescue StandardError => e
102
- UI.user_error!("❌ DeepL API connection failed: #{e.message}")
109
+ # Auto-detect: try Pro API first, then Free API
110
+ endpoints = [
111
+ { host: 'https://api.deepl.com', name: 'Pro' },
112
+ { host: 'https://api-free.deepl.com', name: 'Free' }
113
+ ]
114
+
115
+ endpoints.each_with_index do |endpoint, index|
116
+ DeepL.configure do |config|
117
+ config.auth_key = params[:api_token]
118
+ config.host = endpoint[:host]
119
+ end
120
+
121
+ begin
122
+ DeepL.usage
123
+ UI.success("✅ DeepL API key validated (#{endpoint[:name]} API)")
124
+ UI.message("💡 Tip: You can skip auto-detection by setting free_api: #{endpoint[:name] == 'Free'}") if index > 0
125
+ return
126
+ rescue DeepL::Exceptions::AuthorizationFailed
127
+ # Try next endpoint if this one fails
128
+ next if index < endpoints.length - 1
129
+ # Both endpoints failed
130
+ UI.user_error!('❌ Invalid DeepL API key. Get one at: https://www.deepl.com/pro#developer')
131
+ rescue StandardError => e
132
+ UI.user_error!("❌ DeepL API connection failed: #{e.message}")
133
+ end
103
134
  end
104
135
  end
105
136
 
@@ -56,19 +56,50 @@ module Fastlane
56
56
  end
57
57
 
58
58
  def self.setup_deepl_client(params)
59
- DeepL.configure do |config|
60
- config.auth_key = params[:api_token]
61
- config.host = params[:free_api] ? 'https://api-free.deepl.com' : 'https://api.deepl.com'
59
+ # If free_api is explicitly set, use that configuration
60
+ if params[:free_api] != nil
61
+ DeepL.configure do |config|
62
+ config.auth_key = params[:api_token]
63
+ config.host = params[:free_api] ? 'https://api-free.deepl.com' : 'https://api.deepl.com'
64
+ end
65
+
66
+ begin
67
+ DeepL.usage
68
+ api_type = params[:free_api] ? 'Free' : 'Pro'
69
+ UI.success("✅ DeepL API key validated (#{api_type} API)")
70
+ return
71
+ rescue DeepL::Exceptions::AuthorizationFailed
72
+ UI.user_error!('❌ Invalid DeepL API key. Get one at: https://www.deepl.com/pro#developer')
73
+ rescue StandardError => e
74
+ UI.user_error!("❌ DeepL API connection failed: #{e.message}")
75
+ end
62
76
  end
63
77
 
64
- # Test API key
65
- begin
66
- DeepL.usage
67
- UI.success(' DeepL API key validated')
68
- rescue DeepL::Exceptions::AuthorizationFailed
69
- UI.user_error!('❌ Invalid DeepL API key. Get one at: https://www.deepl.com/pro#developer')
70
- rescue StandardError => e
71
- UI.user_error!("❌ DeepL API connection failed: #{e.message}")
78
+ # Auto-detect: try Pro API first, then Free API
79
+ endpoints = [
80
+ { host: 'https://api.deepl.com', name: 'Pro' },
81
+ { host: 'https://api-free.deepl.com', name: 'Free' }
82
+ ]
83
+
84
+ endpoints.each_with_index do |endpoint, index|
85
+ DeepL.configure do |config|
86
+ config.auth_key = params[:api_token]
87
+ config.host = endpoint[:host]
88
+ end
89
+
90
+ begin
91
+ DeepL.usage
92
+ UI.success("✅ DeepL API key validated (#{endpoint[:name]} API)")
93
+ UI.message("💡 Tip: You can skip auto-detection by setting free_api: #{endpoint[:name] == 'Free'}") if index > 0
94
+ return
95
+ rescue DeepL::Exceptions::AuthorizationFailed
96
+ # Try next endpoint if this one fails
97
+ next if index < endpoints.length - 1
98
+ # Both endpoints failed
99
+ UI.user_error!('❌ Invalid DeepL API key. Get one at: https://www.deepl.com/pro#developer')
100
+ rescue StandardError => e
101
+ UI.user_error!("❌ DeepL API connection failed: #{e.message}")
102
+ end
72
103
  end
73
104
  end
74
105
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fastlane
4
4
  module Translate
5
- VERSION = '0.3.0'
5
+ VERSION = '0.3.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-translate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tijs Teulings
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  - !ruby/object:Gem::Version
202
202
  version: '0'
203
203
  requirements: []
204
- rubygems_version: 3.6.9
204
+ rubygems_version: 3.7.2
205
205
  specification_version: 4
206
206
  summary: Automatically translate iOS Localizable.xcstrings files and App Store metadata
207
207
  using DeepL API