src/Service/Loco.php
public function createAsset(Message $message)
    {
        $project = $this->getProject($message);

        try {
            $response = $this->makeApiRequest($project['api_key'], 'POST', 'assets', [
                'id' => $message->getId(),
                'name' => $message->getId(),
                'type' => 'text',
                // Tell Loco not to translate the asset
                'default' => 'untranslated',
            ]);

            if ($message->hasParameters()) {
                // Send those parameter as a note to Loco
                $notes = '';
                foreach ($message->getParameters() as $key => $value) {
                    if (!is_array($value)) {
                        $notes .= 'Parameter: ' . $key . ' (i.e. : ' . $value . ")\n";
                    } else {
                        foreach ($value as $k => $v) {
                            $notes .= 'Parameter: ' . $k . ' (i.e. : ' . $v . ")\n";
                        }
                    }
                }

                $resource = sprintf('assets/%s.json', $message->getId());
                $this->makeApiRequest($project['api_key'], 'PATCH', $resource, ['notes' => $notes], 'json');
            }
        } catch (HttpException $e) {
            if ($e->getCode() === 409) {
                //conflict.. ignore
                return false;
            }
            throw $e;
        }

        // if this project has multiple domains. Make sure to tag it
        if (!empty($project['domains'])) {
            $this->addTagToAsset($project, $response['id'], $message->getDomain());
        }

        return true;
    }
public function createAsset(Message $message)
    {
        $project = $this->getProject($message);

        try {
            $response = $this->makeApiRequest($project['api_key'], 'POST', 'assets', [
                'id' => $message->getId(),
                'name' => $message->getId(),
                'type' => 'text',
                // Tell Loco not to translate the asset
                'default' => 'untranslated',
            ]);

            if ($message->hasParameters()) {
                // Send those parameter as a note to Loco
                $notes = '';
                foreach ($message->getParameters() as $key => $value) {
                    if (!is_array($value)) {
                        $notes .= 'Parameter: ' . $key . ' (i.e. : ' . $value . ")\n";
                    } else {
                        foreach ($value as $k => $v) {
                            $notes .= 'Parameter: ' . $k . ' (i.e. : ' . $v . ")\n";
                        }
                    }
                }

                $resource = sprintf('assets/%s.json', $message->getId());
                $this->makeApiRequest($project['api_key'], 'PATCH', $resource, ['notes' => $notes], 'json');
            }
        } catch (HttpException $e) {
            if ($e->getCode() === 409) {
                //conflict.. ignore
                return false;
            }
            throw $e;
        }

        // if this project has multiple domains. Make sure to tag it
        if (!empty($project['domains'])) {
            $this->addTagToAsset($project, $response['id'], $message->getDomain());
        }

        return true;
    }
Create a new asset in Loco.

@param Message $message

@return bool