PHPackages                             mistralys/deepl-xml-translator - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mistralys/deepl-xml-translator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mistralys/deepl-xml-translator
==============================

DeepL XML Translator.

3.0.1(5mo ago)41.4k↓80%[2 PRs](https://github.com/Mistralys/deepl-xml-translator/pulls)1GPL-3.0-or-laterPHPPHP ^8.4CI failing

Since Oct 22Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/Mistralys/deepl-xml-translator)[ Packagist](https://packagist.org/packages/mistralys/deepl-xml-translator)[ RSS](/packages/mistralys-deepl-xml-translator/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (12)Versions (18)Used By (1)

[![Build Status](https://camo.githubusercontent.com/dc99114597b05a5239cc81290197448ed6ea4dc54c4751c68d41ebf2d11c6733/68747470733a2f2f7472617669732d63692e636f6d2f4d69737472616c79732f646565706c2d786d6c2d7472616e736c61746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/Mistralys/deepl-xml-translator)

DeepL XML Translator
====================

[](#deepl-xml-translator)

This is a drop-in PHP helper class that can translate a bundle of strings, which may contain markup. It uses [DeepL](https://www.deepl.com)'s [XML translation feature](https://www.deepl.com/docs-api.html?part=xml), and is designed to be very easy to use.

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

[](#installation)

Simply require the package in your project via Composer:

```
"require": {
    "mistralys/deepl-xml-translator" : "dev-master"
}
```

See the packagist page:

Usage
-----

[](#usage)

### Create a new instance of the helper

[](#create-a-new-instance-of-the-helper)

```
$translator = new \DeeplXML\Translator(
    'YourAPIKey', // the DeepL API key to use to connect
    'EN', // source language
    'DE' // target language
);
```

### Add strings to translate

[](#add-strings-to-translate)

```
$translator->addString('string1', 'Please translate me');
$translator->addString('string2', 'Please also translate me');
```

### Fetch the translation

[](#fetch-the-translation)

```
try
{
    $translator->translate();
}
catch(\DeeplXML\Translator_Exception $e)
{
    // handle errors
}
```

### Access the translated strings

[](#access-the-translated-strings)

Retrieving all strings at once:

```
$strings = $translator->getStrings();

 foreach($strings as $string)
 {
     $text = $string->getTranslatedText();
 }
```

Retrieving specific strings by ID:

```
$string = $translator->getStringByID('string2');
$text = $string->getTranslatedText();
```

### Ignoring parts of strings

[](#ignoring-parts-of-strings)

To avoid parts of strings being translated, the characters to ignore can be specified as needed. They are replaced by placeholders by a simple search &amp; replace before sending the translation to DeepL, and restored again afterwards.

```
$string = $translator->addString('string1', 'Please ignore me');

// the text "ignore" will not be translated in the string
$string->addIgnoreString('ignore');
```

DeepL API connection
--------------------

[](#deepl-api-connection)

The translator class uses the [SC-Networks/deepl-api-connector](https://github.com/SC-Networks/deepl-api-connector) DeepL API package to connect to the service in the background.

If you need more advanced features, like translating files and the like, you may use the fully configured connector instance directly:

```
$api = $translator->getConnector();

// do something with it
```

Running the tests
-----------------

[](#running-the-tests)

By default, the unit tests will only test the offline API of the Translator itself. To enable live testing with the DeepL API, rename the file `tests/apikey.dist.php` to `tests/apikey.php` and edit it to insert your API key. The additional tests will be enabled automatically.

Manual API checks
-----------------

[](#manual-api-checks)

**For free API keys** (ending in :fx)

```
curl -s "https://api-free.deepl.com/v2/usage" \
    -H "Authorization: DeepL-Auth-Key YOUR_API_KEY_HERE"
```

**For paid API keys**

```
curl -s "https://api.deepl.com/v2/usage" \
    -H "Authorization: DeepL-Auth-Key YOUR_API_KEY"
```

**With a proxy**

```
curl -x "http://user:pass@proxy:3128" \
    -H "Authorization: DeepL-Auth-Key YOUR_API_KEY" \
    "https://api.deepl.com/v2/usage"
```

A successful response looks like:

```
{
    "character_count":1234,
    "character_limit":500000
}
```

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance80

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 95.8% 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 ~212 days

Recently: every ~344 days

Total

12

Last Release

152d ago

Major Versions

1.0.5 → 2.0.02022-04-26

2.0.3 → 3.0.02026-03-18

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8895528?v=4)[Mistralys](/maintainers/Mistralys)[@Mistralys](https://github.com/Mistralys)

---

Top Contributors

[![Mistralys](https://avatars.githubusercontent.com/u/8895528?v=4)](https://github.com/Mistralys "Mistralys (68 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mistralys-deepl-xml-translator/health.svg)

```
[![Health](https://phpackages.com/badges/mistralys-deepl-xml-translator/health.svg)](https://phpackages.com/packages/mistralys-deepl-xml-translator)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k832.6k55](/packages/neuron-core-neuron-ai)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

762297.9k53](/packages/civicrm-civicrm-core)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.3M49](/packages/tencentcloud-tencentcloud-sdk-php)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)[oat-sa/tao-core

TAO core extension

64147.9k151](/packages/oat-sa-tao-core)[egroupware/egroupware

EGroupware extends a classic groupware with an integrated CRM-system, a secure file-server and Collabora Online Office.

2951.7k](/packages/egroupware-egroupware)

PHPackages © 2026

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