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(3mo 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 3w 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 today

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

56

—

FairBetter than 97% of packages

Maintenance89

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity84

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

107d 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.0k656.1k38](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M45](/packages/tencentcloud-tencentcloud-sdk-php)[civicrm/civicrm-core

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

751291.4k43](/packages/civicrm-civicrm-core)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[oat-sa/tao-core

TAO core extension

66143.7k124](/packages/oat-sa-tao-core)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

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