-
-
Notifications
You must be signed in to change notification settings - Fork 20
Add shortcuts for auto-translate mode. #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b9d3ba5
e53f5aa
516192e
23afdf6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| <?php namespace Winter\Translate\Models; | ||
|
|
||
| use Config; | ||
| use Model; | ||
|
|
||
| /** | ||
|
|
@@ -78,5 +79,19 @@ public static function applyConfigValues(): void | |
| $config->set('winter.translate::providers.deepl.key', $key); | ||
| $config->set('winter.translate::providers.deepl.url', $settings->getDeeplUrl()); | ||
| } | ||
| $config->set('winter.translate::defaultProvider', $settings->defaultProvider); | ||
| } | ||
|
|
||
| public function filterFields($fields) | ||
| { | ||
| $providers = []; | ||
| if (!empty($fields->google_api_key->value)) { | ||
| $providers['google'] = 'Google'; | ||
| } | ||
| if (!empty($fields->deepl_api_key->value)) { | ||
| $providers['deepl'] = 'Deepl'; | ||
| } | ||
|
|
||
| $fields->defaultProvider->options = $providers; | ||
|
Comment on lines
+85
to
+95
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Use effective provider configuration throughout the settings UI. The runtime provider list includes environment and file-configured keys, but the settings UI checks only persisted API-key fields. This makes configured providers usable at runtime but unavailable for default-provider selection.
📍 Affects 2 files
🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,14 +129,21 @@ public function prepareLocaleVars() | |
| $this->vars['defaultLocale'] = $this->defaultLocale; | ||
| $this->vars['locales'] = Locale::listAvailable(); | ||
| $this->vars['providers'] = $usableProviders; | ||
| $this->vars['defaultProvider'] = $this->getDefaultProvider($usableProviders); | ||
| $this->vars['field'] = $this->makeRenderFormField(); | ||
| } | ||
|
|
||
| public function getDefaultProvider($usableProviders): ?string | ||
| { | ||
| // Pre-select a provider only when exactly one is usable — a lone configured | ||
| // provider is an unambiguous default that saves a click. With several, stay | ||
| // on "None" so the user consciously picks a service rather than silently | ||
| // defaulting to a paid one. | ||
| $this->vars['defaultProvider'] = count($usableProviders) === 1 | ||
| ? (string) array_key_first($usableProviders) | ||
| : ''; | ||
| $this->vars['field'] = $this->makeRenderFormField(); | ||
| if (count($usableProviders) === 1) { | ||
| return (string) array_key_first($usableProviders); | ||
| } else { | ||
| return Config::get('winter.translate::defaultProvider'); | ||
| } | ||
|
Comment on lines
+136
to
+146
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Validate the configured provider against When multiple providers are usable, this method returns any configured value without checking that its key exists in Return the configured value only when it is a usable provider; otherwise return 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Use the product name
DeepL.The new option label is
Deepl, while the existing language strings useDeepL.🤖 Prompt for AI Agents