src/Connector/Languages.php
public function createLanguage(
        string $slug,
        string $langCode,
        array $coordinators,
        array $options = [],
        bool $skipInvalidUsername = false
    ): ResponseInterface {
        // Make sure the $coordinators array is not empty
        if (!\count($coordinators)) {
            throw new \InvalidArgumentException('The coordinators array must contain at least one username.');
        }

        $uri = $this->createUri("/api/2/project/$slug/languages/");

        if ($skipInvalidUsername) {
            $uri = $uri->withQuery('skip_invalid_username');
        }

        // Build the required request data.
        $data = [
            'language_code' => $langCode,
            'coordinators'  => $coordinators,
        ];

        // Valid options to check
        $validOptions = ['translators', 'reviewers', 'list'];

        // Loop through the valid options and if we have them, add them to the request data
        foreach ($validOptions as $option) {
            if (isset($options[$option])) {
                $data[$option] = $options[$option];
            }
        }

        $request = $this->createRequest('POST', $uri);
        $request = $request->withBody($this->streamFactory->createStream(\json_encode($data)));

        return $this->client->sendRequest($request);
    }
public function createLanguage(
        string $slug,
        string $langCode,
        array $coordinators,
        array $options = [],
        bool $skipInvalidUsername = false
    ): ResponseInterface {
        // Make sure the $coordinators array is not empty
        if (!\count($coordinators)) {
            throw new \InvalidArgumentException('The coordinators array must contain at least one username.');
        }

        $uri = $this->createUri("/api/2/project/$slug/languages/");

        if ($skipInvalidUsername) {
            $uri = $uri->withQuery('skip_invalid_username');
        }

        // Build the required request data.
        $data = [
            'language_code' => $langCode,
            'coordinators'  => $coordinators,
        ];

        // Valid options to check
        $validOptions = ['translators', 'reviewers', 'list'];

        // Loop through the valid options and if we have them, add them to the request data
        foreach ($validOptions as $option) {
            if (isset($options[$option])) {
                $data[$option] = $options[$option];
            }
        }

        $request = $this->createRequest('POST', $uri);
        $request = $request->withBody($this->streamFactory->createStream(\json_encode($data)));

        return $this->client->sendRequest($request);
    }
public function createLanguage ( string $ slug , string $ langCode , array $ coordinators , array $ options = [ ] , bool $ skipInvalidUsername = false ) : ResponseInterface { // Make sure the $coordinators array is not empty if ( ! \ count ( $ coordinators ) ) { throw new \ InvalidArgumentException ( 'The coordinators array must contain at least one username.' ) ; } $ uri = $ this -> createUri ( "/api/2/project/$slug/languages/" ) ; if ( $ skipInvalidUsername ) { $ uri = $ uri -> withQuery ( 'skip_invalid_username' ) ; } // Build the required request data. $ data = [ 'language_code' => $ langCode , 'coordinators' => $ coordinators , ] ; // Valid options to check $ validOptions = [ 'translators' , 'reviewers' , 'list' ] ; // Loop through the valid options and if we have them, add them to the request data foreach ( $ validOptions as $ option ) { if ( isset ( $ options [ $ option ] ) ) { $ data [ $ option ] = $ options [ $ option ] ; } } $ request = $ this -> createRequest ( 'POST' , $ uri ) ; $ request = $ request -> withBody ( $ this -> streamFactory -> createStream ( \ json_encode ( $ data ) ) ) ; return $ this -> client -> sendRequest ( $ request ) ; }
Create a language for a project.

@param string   $slug                The slug for the project
@param string   $langCode            The language code for the new language
@param string[] $coordinators        An array of coordinators for the language
@param array    $options             Optional additional params to send with the request
@param bool     $skipInvalidUsername If true, the API call does not fail and instead will return a list of invalid usernames

@return ResponseInterface

@throws \InvalidArgumentException
Create a language for a project .