PHPackages                             arthur-salenko/translator-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. arthur-salenko/translator-client

ActiveLibrary[API Development](/categories/api)

arthur-salenko/translator-client
================================

PHP SDK client for Translator microservice

v1.2.2(3mo ago)0109proprietaryPHPPHP ^8.1

Since Jan 15Pushed 3mo agoCompare

[ Source](https://github.com/arthur-salenko/translator-client)[ Packagist](https://packagist.org/packages/arthur-salenko/translator-client)[ RSS](/packages/arthur-salenko-translator-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

arthur-salenko/translator-client
================================

[](#arthur-salenkotranslator-client)

PHP SDK for the `translator` service.

Requirements
------------

[](#requirements)

- PHP `^8.1`

Installation
------------

[](#installation)

```
composer require arthur-salenko/translator-client
```

Usage
-----

[](#usage)

```
use ArthurSalenko\TranslatorClient\ClientConfig;
use ArthurSalenko\TranslatorClient\Dto\TranslationItem;
use ArthurSalenko\TranslatorClient\TranslatorClient;

$client = new TranslatorClient(new ClientConfig(
  baseUrl: 'https://translator.my-domain.tld',
  brandKey: 'YOUR_BRAND_KEY',
));

// Health
$health = $client->health()->get();

// Languages
$languages = $client->languages()->index();

// Brands
$brands = $client->brands()->index();

// Folders
$folders = $client->folders()->index();

// Upsert translations
$result = $client->admin()->translations()->upsert(items: [
  new TranslationItem('common', 'sitename', ['en' => 'Hello', 'ru' => 'Привет']),
]);

// Create brand (admin)
// Note: requires brandKey in ClientConfig, otherwise API responds with 401
$newBrand = $client->admin()->brands()->create(code: 'doncoupon_ua', name: 'Doncoupon UA');
```

### Configuration

[](#configuration)

```
use ArthurSalenko\TranslatorClient\ClientConfig;
use ArthurSalenko\TranslatorClient\TranslatorClient;

$config = new ClientConfig(
  baseUrl: 'https://translator.my-domain.tld',
  brandKey: 'YOUR_BRAND_KEY',
  timeoutSeconds: 10.0,
  connectTimeoutSeconds: 5.0,
  userAgent: 'my-app/1.0',
);

$client = new TranslatorClient($config);
```

### Custom Guzzle client

[](#custom-guzzle-client)

```
use ArthurSalenko\TranslatorClient\ClientConfig;
use ArthurSalenko\TranslatorClient\TranslatorClient;
use GuzzleHttp\Client as GuzzleClient;

$guzzle = new GuzzleClient([
  'verify' => false,
]);

$client = new TranslatorClient(
  new ClientConfig('https://translator.my-domain.tld', 'YOUR_BRAND_KEY'),
  $guzzle,
);
```

Translations API
----------------

[](#translations-api)

Unless specified explicitly, read methods that accept `lang` default to `en`.

### Revisions

[](#revisions)

```
$revs = $client->translations()->revision();
```

### Get translations (JSON + headers)

[](#get-translations-json--headers)

`indexResponse()` returns a response object with:

- `statusCode`
- `headers`
- `json`
- `rawBody`

```
$response = $client->translations()->indexResponse(lang: 'ru');

if ($response->statusCode === 200) {
  $revision = $response->json['revision'] ?? null;
  $data = $response->json['data'] ?? [];
}
```

### Translations (ETag)

[](#translations-etag)

Service endpoint `index` may return `304 Not Modified`. The SDK provides methods that return status + headers:

```
$response = $client->translations()->indexResponse(
  lang: 'ru',
  folder: 'common',
  format: 'tree',
  scope: 'merged',
  ifNoneMatch: $etag,
);

if ($response->statusCode === 304) {
  // use cached response
} else {
  $etag = $response->header('ETag');
  $revision = $response->json['revision'] ?? null;
  $data = $response->json['data'] ?? [];
}
```

### Get translation value

[](#get-translation-value)

```
$value = $client->translations()->show(folder: 'common', key: 'sitename');
// service response: { revision: string, value: mixed|null }
```

### Upsert translations

[](#upsert-translations)

```
use ArthurSalenko\TranslatorClient\Dto\TranslationItem;

$res = $client->admin()->translations()->upsert(
  items: [
    new TranslationItem('common', 'sitename', ['en' => 'Hello', 'ru' => 'Привет']),
  ],
  target: 'brand',
);

$brandCode = $res->brandCode;
$baseRevision = $res->baseRevision;
$brandRevision = $res->brandRevision;
$effectiveRevision = $res->effectiveRevision;
$insertedToBase = $res->insertedToBase;
```

Errors
------

[](#errors)

- `ArthurSalenko\TranslatorClient\Exception\ApiException` — HTTP `4xx/5xx` (including parsed JSON, if available)
- `ArthurSalenko\TranslatorClient\Exception\NetworkException` — network/transport errors

```
use ArthurSalenko\TranslatorClient\Exception\ApiException;
use ArthurSalenko\TranslatorClient\Exception\NetworkException;

try {
  $client->admin()->translations()->upsert(items: [
    new TranslationItem('common', 'sitename', ['en' => 'Hello', 'ru' => 'Привет']),
  ]);
} catch (ApiException $e) {
  $status = $e->statusCode;
  $raw = $e->responseBody;
  $json = $e->responseJson;
} catch (NetworkException $e) {
  // connection errors, timeouts, etc
}
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance78

Regular maintenance activity

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

5

Last Release

116d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/71877216?v=4)[arthur-salenko](/maintainers/arthur-salenko)[@arthur-salenko](https://github.com/arthur-salenko)

---

Top Contributors

[![arthur-salenko](https://avatars.githubusercontent.com/u/71877216?v=4)](https://github.com/arthur-salenko "arthur-salenko (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/arthur-salenko-translator-client/health.svg)

```
[![Health](https://phpackages.com/badges/arthur-salenko-translator-client/health.svg)](https://phpackages.com/packages/arthur-salenko-translator-client)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
