PHPackages                             lekoala/silverstripe-multilingual - 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. [Localization &amp; i18n](/categories/localization)
4. /
5. lekoala/silverstripe-multilingual

ActiveSilverstripe-vendormodule[Localization &amp; i18n](/categories/localization)

lekoala/silverstripe-multilingual
=================================

i18n tools for SilverStripe

2.2.0(2mo ago)12.8k↓50%1MITPHPPHP ^8.1CI passing

Since Feb 8Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/lekoala/silverstripe-multilingual)[ Packagist](https://packagist.org/packages/lekoala/silverstripe-multilingual)[ GitHub Sponsors](https://github.com/lekoala)[ RSS](/packages/lekoala-silverstripe-multilingual/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (9)Versions (5)Used By (0)

SilverStripe i18n tools module
==============================

[](#silverstripe-i18n-tools-module)

[![Build Status](https://github.com/lekoala/silverstripe-multilingual/actions/workflows/ci.yml/badge.svg)](https://github.com/lekoala/silverstripe-multilingual/actions/workflows/ci.yml/badge.svg)[![scrutinizer](https://camo.githubusercontent.com/cc1ee55370ff3cc964875b079dc82e732c00e7ba09806ae236e344ab22d97386/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c656b6f616c612f73696c7665727374726970652d6d756c74696c696e6775616c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/lekoala/silverstripe-multilingual/)[![Code coverage](https://camo.githubusercontent.com/c377c003f3018d6cd989d114e0bf01c267b5809ea9b66485ce177fdb6cc36d20/68747470733a2f2f636f6465636f762e696f2f67682f6c656b6f616c612f73696c7665727374726970652d6d756c74696c696e6775616c2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/lekoala/silverstripe-multilingual)

Intro
-----

[](#intro)

Provide some helper tools when working with Fluent and multilingual websites

LangHelper
----------

[](#langhelper)

The `LangHelper` class provide a consistent i18n function regardless of Fluent being installed or not.

You can call global translation under the "Global" entity. These are accessible with LangHelper::globalTranslation or g() shortcut.

FluentLocale only if cookies are enabled
----------------------------------------

[](#fluentlocale-only-if-cookies-are-enabled)

This module disable by default `persist_cookie` for Fluent.

You need to make sure to call `LangHelper::persistLocaleIfCookiesAreAllowed` (works with two types of cookie consent modules) or call with your own logic `LangHelper::persistLocale`.

Improved text collector task
----------------------------

[](#improved-text-collector-task)

[![ConfigurableI18nTextCollectorTask](docs/ConfigurableI18nTextCollectorTask.png "ConfigurableI18nTextCollectorTask")](docs/ConfigurableI18nTextCollectorTask.png)

This improved text collector helps you to collect translation from specific modules.

It supports merge (even of older version of SilverStripe, that now does that as well), auto translating new string from google api, clear unused strings...

This is available from a convenient interface.

Translations import/export task
-------------------------------

[](#translations-importexport-task)

[![TranslationsImportExportTask](docs/TranslationsImportExportTask.png "TranslationsImportExportTask")](docs/TranslationsImportExportTask.png)

Collecting translations for customers is not always easy. In order to provide a simple mean to collect label, everything can be exported to a csv file. This will create as many columns as the number of .yml files in your `lang` folder.

It can then be imported back from the file to your yml files.

If you use `lekoala/silverstripe-excel-import-export`, this file can be exported in xlsx.

This is available from a convenient interface.

Glossary Support
----------------

[](#glossary-support)

This module provides a mechanism to manage translation glossaries, ensuring consistent translation of specific terms. For a detailed technical overview of how this integrates with the DeepL API, see [Glossary Architecture](docs/glossary.md).

### Usage

[](#usage)

1. **Generate glossary candidates**:

    ```
    php vendor/bin/sake dev/tasks/GlossaryTask action=generate module=app
    ```

    This scans your YML files for single-word translations (e.g., "Word" -&gt; "Mot") and creates CSV files in `app/lang/glossaries/`. These files can be reviewed and edited manually.
2. **Sync with DeepL (Optional)**:

    ```
    php vendor/bin/sake dev/tasks/GlossaryTask action=sync module=app
    ```

    This uploads the CSV files to DeepL as a single multilingual glossary. The resulting glossary ID is stored in `app/lang/glossaries/map.json`.
3. **List remote glossaries**:

    ```
    php vendor/bin/sake dev/tasks/GlossaryTask action=list
    ```

When using the `DeeplTranslator`, it will automatically detect and apply the glossary if a valid `map.json` file is found in the module's `lang/glossaries` directory.

Supported translators
---------------------

[](#supported-translators)

We support a few drivers out of the box. You can configure the default translator using SilverStripe's dependency injection system in your `app/_config/config.yml`:

### For DeepL

[](#for-deepl)

```
SilverStripe\Core\Injector\Injector:
  LeKoala\Multilingual\TranslatorInterface:
    class: LeKoala\Multilingual\DeeplTranslator
    constructor:
      apiKey: 'your-api-key'
```

### For Ollama

[](#for-ollama)

```
SilverStripe\Core\Injector\Injector:
  LeKoala\Multilingual\TranslatorInterface:
    class: LeKoala\Multilingual\OllamaTranslator
    constructor:
      model: 'mistral'
```

Tasks will use this configuration unless you explicitly override options (like `driver`, `model`, or `key`) via CLI.

DeepL Integration
-----------------

[](#deepl-integration)

You can use DeepL as an alternative to Ollama. First, install the SDK:

```
composer require deeplcom/deepl-php
```

Then configure the tasks to use the `deepl` driver and provide your API key.

```
sake dev/tasks/TranslationsImportExportTask module=yourmodule export=1 export_auto_translate=1 source_lang=en driver=deepl key=your-api-key
```

DeepL support includes:

- **Batch Translation**: Grouping multiple strings to reduce API calls (grouped by context).
- **Context Support**: Passing context to DeepL to improve translation quality.
- **Variable Preservation**: Automatic restoration of variables (e.g. `{name}`) if the API messes them up.

Ollama Integration
------------------

[](#ollama-integration)

This module uses `OllamaTranslator` to leverage local LLMs for translation.

By default, it uses the `translategemma:4b` model:

```
ollama pull translategemma:4b
```

You can select a different model from the task UI via the **model** option, or pass it as a parameter.

### Source Language

[](#source-language)

Use the `source_lang` option (available in both tasks) to specify the source language for translation. This is used both for loading reference `.yml` files and as the LLM's input language.

```
sake dev/tasks/TranslationsImportExportTask module=yourmodule export=1 export_auto_translate=1 source_lang=en
```

### Batch Translation

[](#batch-translation)

The translator supports **batch mode**, sending multiple strings in a single LLM call for significantly faster throughput (10–20× vs single-key). Strings without a reference translation are batched in groups of 15; strings with a reference are translated individually for quality.

```
$translator = new OllamaTranslator();
$results = $translator->translateBatch([
    ['key' => 'TITLE', 'value' => 'Title', 'context' => null],
    ['key' => 'SAVE', 'value' => 'Save', 'context' => 'Button label'],
], 'fr', 'en');
```

### Translation Review &amp; Audit

[](#translation-review--audit)

Enable the **review\_translations** option to automatically audit existing translations via the LLM. Invalid translations are corrected in-place before writing.

Review also supports batch mode via `reviewBatch()`:

```
$results = $translator->reviewBatch([
    ['key' => 'TITLE', 'source' => 'Title', 'translation' => 'Nom', 'context' => null],
], 'fr', 'en');
// Returns: ['TITLE' => ['valid' => false, 'correction' => 'Titre']]
```

See `bin/test-audit.php` for a standalone audit example.

### Context Support

[](#context-support)

Context is provided to the LLM automatically in two ways:

1. **Explicit**: From `_t()` calls with a `context` key (e.g. ``)
2. **Implicit**: Derived from the entity key (e.g. `Member.FIRSTNAME` → `"Field 'FIRSTNAME' in 'Member'"`)

### Progress Reporting

[](#progress-reporting)

Both translation and review operations emit progress messages during execution (e.g. `Translating batch 15/142...`, `Review complete: 50 reviewed, 3 corrected`).

Todo
----

[](#todo)

- Make BuildTaskTools into a specific module

Compatibility
-------------

[](#compatibility)

Tested with ^5

Maintainer
----------

[](#maintainer)

LeKoala -

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance85

Actively maintained with recent releases

Popularity25

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 98.9% 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 ~612 days

Total

4

Last Release

88d ago

Major Versions

1.0.0 → 2.0.02024-01-29

PHP version history (3 changes)1.0.0PHP &gt;=7.2

2.0.0PHP ^8

2.1.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/250762?v=4)[Thomas Portelange](/maintainers/lekoala)[@lekoala](https://github.com/lekoala)

---

Top Contributors

[![lekoala](https://avatars.githubusercontent.com/u/250762?v=4)](https://github.com/lekoala "lekoala (94 commits)")[![jmsche](https://avatars.githubusercontent.com/u/3929498?v=4)](https://github.com/jmsche "jmsche (1 commits)")

---

Tags

i18nmodulesilverstripei18nsilverstripemultilingualcmsmodule

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/lekoala-silverstripe-multilingual/health.svg)

```
[![Health](https://phpackages.com/badges/lekoala-silverstripe-multilingual/health.svg)](https://phpackages.com/packages/lekoala-silverstripe-multilingual)
```

###  Alternatives

[tractorcow/silverstripe-fluent

Simple localisation for Silverstripe

92421.6k26](/packages/tractorcow-silverstripe-fluent)[silverstripe/translatable

Allows translation of DataObject and SiteTree records into multiple languages

53192.0k8](/packages/silverstripe-translatable)[typicms/base

A modular multilingual CMS built with Laravel, enabling developers to manage structured content like pages, news, events, and more.

1.6k20.3k](/packages/typicms-base)[lekoala/silverstripe-cms-actions

Add actions to your models in SilverStripe

39279.9k22](/packages/lekoala-silverstripe-cms-actions)[imaginaerum/magento2-language-fr-fr

Magento2 French Language Pack (fr\_FR)

41738.1k2](/packages/imaginaerum-magento2-language-fr-fr)[lekoala/silverstripe-mandrill

Adds mandrill in the SilverStripe CMS

1827.3k](/packages/lekoala-silverstripe-mandrill)

PHPackages © 2026

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