<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[12511] sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates: Translate: Add the backend items to support OpenAI and DeepL</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/12511">12511</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/12511","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>amieiro</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-03-29 14:13:09 +0000 (Wed, 29 Mar 2023)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Translate: Add the backend items to support OpenAI and DeepL</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginswporggpcustomizationstemplateshelperfunctionsphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/helper-functions.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginswporggpcustomizationstemplatesjseditorjs">sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/js/editor.js</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginswporggpcustomizationstemplatessettingseditphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/settings-edit.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginswporggpcustomizationstemplatesstylecss">sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/style.css</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginswporggpcustomizationstemplateshelperfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/helper-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/helper-functions.php 2023-03-29 14:12:17 UTC (rev 12510)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/helper-functions.php 2023-03-29 14:13:09 UTC (rev 12511)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -33,6 +33,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> filemtime( __DIR__ . '/js/editor.js' )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+wp_localize_script(
+ 'wporg-translate-editor',
+ 'wporgEditorSettings',
+ array(
+ 'nonce' => wp_create_nonce( 'wporg-editor-settings' ),
+ )
+);
+
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_register_style(
</span><span class="cx" style="display: block; padding: 0 10px"> 'chartist',
</span><span class="cx" style="display: block; padding: 0 10px"> plugins_url( 'css/chartist.min.css', __FILE__ ),
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginswporggpcustomizationstemplatesjseditorjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/js/editor.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/js/editor.js 2023-03-29 14:12:17 UTC (rev 12510)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/js/editor.js 2023-03-29 14:13:09 UTC (rev 12511)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,6 +1,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ( function( $ ){
</span><span class="cx" style="display: block; padding: 0 10px"> var $html = $( 'html' );
</span><span class="cx" style="display: block; padding: 0 10px"> var $document = $( document );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var $openAITranslationsUsed = [];
+ var $deeplTranslationsUsed = [];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function checkStorage() {
</span><span class="cx" style="display: block; padding: 0 10px"> var test = 'test',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -69,6 +71,48 @@
</span><span class="cx" style="display: block; padding: 0 10px"> autosize( $textarea );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Adds the suggestion to the translation in an array, and removes the previous suggestions, so
+ * we only store the last one in the database, using the saveExternalSuggestions() function.
+ *
+ * @return {void}
+ */
+ function addSuggestion() {
+ var $row = $( this );
+ var $originalId = $row.closest( 'tr' ).attr( 'id' ).substring( 7 );
+ var $CSSclass = $row.attr( 'class' );
+ if ( $CSSclass.indexOf( 'openai' ) > -1 ) {
+ $openAITranslationsUsed[ $originalId ] = $row.find( '.translation-suggestion__translation' ).text();
+ $deeplTranslationsUsed.splice( $originalId, 1 );
+ } else if ( $CSSclass.indexOf( 'deepl' ) > -1 ) {
+ $deeplTranslationsUsed[ $originalId ] = $row.find( '.translation-suggestion__translation' ).text();
+ $openAITranslationsUsed.splice( $originalId, 1 );
+ }
+ }
+
+ /**
+ * Saves the number of external suggestions used and used without modification.
+ *
+ * @return {void}
+ **/
+ function saveExternalSuggestions() {
+ var $button = $( this );
+ var $row = $button.closest( 'tr.editor' );
+ var $originalId = $row.attr( 'id' ).substring( 7 );
+ var $translation = $row.find( 'textarea' ).val();
+ var $data = {
+ nonce: wporgEditorSettings.nonce,
+ translation: $translation,
+ openAITranslationsUsed: $openAITranslationsUsed[$originalId],
+ deeplTranslationsUsed: $deeplTranslationsUsed[$originalId]
+ };
+ $.ajax({
+ url: '/-save-external-suggestions',
+ type: 'POST',
+ data: $data,
+ });
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Override functions to adopt custom markup.
</span><span class="cx" style="display: block; padding: 0 10px"> $gp.editor.copy = function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var $activeTextarea = $gp.editor.current.find( '.textareas.active textarea' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -276,6 +320,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> .on( 'click', 'button.panel-header-actions__cancel', $gp.editor.hooks.cancel )
</span><span class="cx" style="display: block; padding: 0 10px"> .on( 'click', 'button.translation-actions__copy', $gp.editor.hooks.copy )
</span><span class="cx" style="display: block; padding: 0 10px"> .on( 'click', 'button.translation-actions__insert-tab', $gp.editor.hooks.tab )
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ .on( 'click', 'button.translation-actions__save', saveExternalSuggestions )
</ins><span class="cx" style="display: block; padding: 0 10px"> .on( 'click', 'button.translation-actions__save', $gp.editor.hooks.ok )
</span><span class="cx" style="display: block; padding: 0 10px"> .on( 'click', 'button.translation-actions__help', openHelpModal )
</span><span class="cx" style="display: block; padding: 0 10px"> .on( 'click', 'button.translation-actions__ltr', switchTextDirection )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -282,7 +327,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> .on( 'click', 'button.translation-actions__rtl', switchTextDirection )
</span><span class="cx" style="display: block; padding: 0 10px"> .on( 'focus', 'textarea', textareaAutosize )
</span><span class="cx" style="display: block; padding: 0 10px"> .on( 'click', 'summary', toggleDetails )
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- .on( 'click', 'button.button-menu__toggle', toggleLinkMenu );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ .on( 'click', 'button.button-menu__toggle', toggleLinkMenu )
+ .on( 'click', '.translation-suggestion.with-tooltip.openai', addSuggestion )
+ .on( 'click', '.translation-suggestion.with-tooltip.deepl', addSuggestion );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> })( $gp.editor.install_hooks );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginswporggpcustomizationstemplatessettingseditphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/settings-edit.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/settings-edit.php 2023-03-29 14:12:17 UTC (rev 12510)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/settings-edit.php 2023-03-29 14:13:09 UTC (rev 12511)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -22,15 +22,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'how' => 'desc',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+$gp_external_translations = get_user_option( 'gp_external_translations' );
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <table class="form-table">
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <th><label for="per_page"><?php _e( 'Number of items per page:', 'glotpress' ); ?></label></th>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <th><label for="per_page"><?php esc_html_e( 'Number of items per page:', 'glotpress' ); ?></label></th>
</ins><span class="cx" style="display: block; padding: 0 10px"> <td><input type="number" id="per_page" name="per_page" value="<?php echo esc_attr( $gp_per_page ); ?>"/></td>
</span><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <th><label for="default_sort[by]"><?php _e( 'Default Sort By:', 'glotpress' ); ?></label></th>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <th><label for="default_sort[by]"><?php esc_html_e( 'Default Sort By:', 'glotpress' ); ?></label></th>
</ins><span class="cx" style="display: block; padding: 0 10px"> <td>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> $sort_bys = wp_list_pluck( gp_get_sort_by_fields(), 'title' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -40,7 +42,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> </td>
</span><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <th><label for="default_sort[how]"><?php _e( 'Default Sort Order:', 'glotpress' ); ?></label></th>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <th><label for="default_sort[how]"><?php esc_html_e( 'Default Sort Order:', 'glotpress' ); ?></label></th>
</ins><span class="cx" style="display: block; padding: 0 10px"> <td>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> echo gp_radio_buttons(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -60,7 +62,108 @@
</span><span class="cx" style="display: block; padding: 0 10px"> I do this because the post values are processed in the GP_Route_Settings->settings_post,
</span><span class="cx" style="display: block; padding: 0 10px"> and I have to modify the GlotPress core to add a new configuration item. -->
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <th><label for="default_sort[notifications_optin]"><?php _e( 'I want to receive notifications of discussions:', 'glotpress' ); ?></label></th>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <th><label for="default_sort[notifications_optin]"><?php esc_html_e( 'I want to receive notifications of discussions:', 'glotpress' ); ?></label></th>
</ins><span class="cx" style="display: block; padding: 0 10px"> <td><input type="checkbox" id="default_sort[notifications_optin]" name="default_sort[notifications_optin]" <?php gp_checked( 'on' == gp_array_get( $gp_default_sort, 'notifications_optin', 'off' ) ); ?> /></td>
</span><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <tr>
+ <th>
+ <h4><?php esc_html_e( 'External translating services', 'glotpress' ); ?></h4>
+ </th>
+ </tr>
+ <tr>
+ <th><label for="default_sort[external_services_exclude_some_status]"><?php esc_html_e( 'Don\'t use OpenAI and DeepL with translations in current, rejected or old status.', 'glotpress' ); ?></label></th>
+ <td><input type="checkbox" id="default_sort[external_services_exclude_some_status]" name="default_sort[external_services_exclude_some_status]" <?php gp_checked( 'on' == gp_array_get( $gp_default_sort, 'external_services_exclude_some_status', 'off' ) ); ?> /></td>
+ </tr>
+ <tr>
+ <th>
+ <h4><?php esc_html_e( 'OpenAI (ChatGPT) settings', 'glotpress' ); ?></h4>
+ </th>
+ </tr>
+ <tr>
+ <th><label for="default_sort[openai_api_key]">
+ <?php esc_html_e( 'OpenAI API Key', 'glotpress' ); ?>
+ </label>
+ <?php
+ if ( gp_array_get( $gp_external_translations, 'openai_translations_used', 0 ) > 0 ) {
+ echo '<br>';
+ echo '<small>';
+ /* translators: Number of OpenAI translations used. */
+ echo esc_html( sprintf( _n( '%s OpenAI translation used:', '%s OpenAI translations used:', 'glotpress' ), number_format_i18n( gp_array_get( $gp_external_translations, 'openai_translations_used', 0 ) ) ) );
+ if ( gp_array_get( $gp_external_translations, 'openai_same_translations_used', 0 ) > 0 ) {
+ echo ' ' . esc_html(
+ sprintf(
+ /* translators: 1: Number of OpenAI translations used with modifications. 2: Number of OpenAI translations used without modifications. */
+ __( '%1$s with modifications and %2$s without modifications.', 'glotpress' ),
+ number_format_i18n( gp_array_get( $gp_external_translations, 'openai_translations_used', 0 ) - gp_array_get( $gp_external_translations, 'openai_same_translations_used', 0 ) ),
+ number_format_i18n( gp_array_get( $gp_external_translations, 'openai_same_translations_used', 0 ) ),
+ )
+ );
+ }
+ echo '</small>';
+ }
+ ?>
+ <br>
+ <a href="https://platform.openai.com/account/usage" target="_blank"><small>
+ <?php
+ $openai_tokens_used = gp_array_get( $gp_external_translations, 'openai_tokens_used', 0 );
+ if ( $openai_tokens_used > 0 ) {
+ /* translators: Number of OpenAI tokens used. */
+ echo esc_html( sprintf( __( 'OpenAI tokens used: %s', 'glotpress' ), number_format_i18n( $openai_tokens_used ) ) );
+ }
+ ?>
+ </small></a>
+ <br>
+ <br>
+ </th>
+ <td><input type="text" class="openai_api_key" id="default_sort[openai_api_key]" name="default_sort[openai_api_key]" value="<?php echo esc_html( gp_array_get( $gp_default_sort, 'openai_api_key', '' ) ); ?>" placeholder="Enter your OpenAI API key" /></td>
+ </tr>
+ <tr>
+ <th><label for="default_sort[openai_custom_prompt]"><?php esc_html_e( 'Custom Prompt', 'glotpress' ); ?></label></th>
+ <td><textarea class="openai_custom_prompt" id="default_sort[openai_custom_prompt]" name="default_sort[openai_custom_prompt]" placeholder="Enter your custom prompt for ChatGPT translation suggestions"><?php echo esc_html( gp_array_get( $gp_default_sort, 'openai_custom_prompt', '' ) ); ?></textarea></td>
+ </tr>
+ <tr>
+ <th><label for="default_sort[openai_temperature]"><?php esc_html_e( 'Temperature', 'glotpress' ); ?></label></th>
+ <td><input type="number" min="0" max="2" step=".1" class="openai_temperature" id="default_sort[openai_temperature]" name="default_sort[openai_temperature]" value="<?php echo esc_html( gp_array_get( $gp_default_sort, 'openai_temperature', 0 ) ); ?>" placeholder="Enter your OpenAI key" /></td>
+ </tr>
+ <tr>
+ <th>
+ <h4><?php esc_html_e( 'DeepL settings', 'glotpress' ); ?></h4>
+ </th>
+ </tr>
+ <tr>
+ <th><label for="default_sort[deepl_api_key]">
+ <?php esc_html_e( 'DeepL Free API Key', 'glotpress' ); ?>
+ </label>
+ <?php
+ if ( gp_array_get( $gp_external_translations, 'deepl_translations_used', 0 ) > 0 ) {
+ echo '<br>';
+ echo '<small>';
+ /* translators: Number of DeepL translations used. */
+ echo esc_html( sprintf( _n( '%s DeepL translation used:', '%s DeepL translations used:', 'glotpress' ), number_format_i18n( gp_array_get( $gp_external_translations, 'deepl_translations_used', 0 ) ) ) );
+ if ( gp_array_get( $gp_external_translations, 'deepl_same_translations_used', 0 ) > 0 ) {
+ echo ' ' . esc_html(
+ sprintf(
+ /* translators: 1: Number of DeepL translations used with modifications. 2: Number of DeepL translations used without modifications. */
+ __( '%1$s with modifications and %2$s without modifications.', 'glotpress' ),
+ number_format_i18n( gp_array_get( $gp_external_translations, 'deepl_translations_used', 0 ) - gp_array_get( $gp_external_translations, 'deepl_same_translations_used', 0 ) ),
+ number_format_i18n( gp_array_get( $gp_external_translations, 'deepl_same_translations_used', 0 ) ),
+ )
+ );
+ }
+ echo '</small>';
+ }
+ ?>
+ <br>
+ <a href="https://www.deepl.com/account/usage" target="_blank"><small>
+ <?php
+ $deepl_chars_used = gp_array_get( $gp_external_translations, 'deepl_chars_used', 0 );
+ if ( $deepl_chars_used > 0 ) {
+ /* translators: Number of chars translated with DeepL. */
+ echo esc_html( sprintf( __( 'Chars translated with DeepL: %s', 'glotpress' ), number_format_i18n( $deepl_chars_used ) ) );
+ }
+ ?>
+ </small></a>
+ </th>
+ <td><input type="text" class="deepl_api_key" id="default_sort[deepl_api_key]" name="default_sort[deepl_api_key]" value="<?php echo esc_html( gp_array_get( $gp_default_sort, 'deepl_api_key' ) ); ?>" placeholder="Enter your DeepL API key" /></td>
+ </tr>
</ins><span class="cx" style="display: block; padding: 0 10px"> </table>
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginswporggpcustomizationstemplatesstylecss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/style.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/style.css 2023-03-29 14:12:17 UTC (rev 12510)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/style.css 2023-03-29 14:13:09 UTC (rev 12511)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -154,6 +154,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> background: var( --gp-color-btn-bg );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.gp-content .openai_api_key, .gp-content .deepl_api_key {
+ width: auto;
+}
+
+.gp-content .openai_custom_prompt {
+ width: auto;
+ border: #7e7e7e thin solid !important;
+ border-radius: 3px;
+ height: 8rem;
+}
+
+@media screen and (min-width: 750px) {
+ .gp-content .openai_api_key, .gp-content .deepl_api_key {
+ width: 30rem;
+ }
+
+ .gp-content .openai_custom_prompt {
+ width: 30rem;
+ }
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> select.is-small {
</span><span class="cx" style="display: block; padding: 0 10px"> padding-top: 3px;
</span><span class="cx" style="display: block; padding: 0 10px"> padding-bottom: 3px;
</span></span></pre>
</div>
</div>
</body>
</html>