Making WordPress.org

Changeset 14407


Ignore:
Timestamp:
03/27/2025 09:30:34 AM (6 days ago)
Author:
amieiro
Message:

Translate: Solve a problem in the bulk-pretranslations

Solve a problem with a breaking change in the DeepL API
More info at: https://meta.trac.wordpress.org/ticket/7936

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-bulk-pretranslations/inc/class-deepl.php

    r14205 r14407  
    5050        }
    5151
     52        $options = array(
     53            'timeout' => 20,
     54            'headers' => array(
     55                'Content-Type'  => 'application/json',
     56                'Authorization' => 'DeepL-Auth-Key ' . $deepl_api_key,
     57            ),
     58            'body' => wp_json_encode( array(
     59                'text'        => array( $original->singular ),
     60                'target_lang' => $target_lang,
     61                'formality'   => $this->get_language_formality( $target_lang, $locale->slug ),
     62            )),
     63        );
    5264        $deepl_response = wp_remote_post(
    5365            $deepl_url,
    54             array(
    55                 'timeout' => 20,
    56                 'body'    => array(
    57                     'auth_key'    => $deepl_api_key,
    58                     'text'        => $original->singular,
    59                     'source_lang' => 'EN',
    60                     'target_lang' => $target_lang,
    61                     'formality'   => $this->get_language_formality( $target_lang, $locale->slug ),
    62                 ),
    63             ),
     66            $options
    6467        );
    6568        if ( is_wp_error( $deepl_response ) ) {
Note: See TracChangeset for help on using the changeset viewer.