Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions API.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
use Piwik\Plugins\CustomTranslations\TranslationTypes\TranslationTypeProvider;

/**
* Public API for managing CustomTranslations translation values and metadata.
*
* All endpoints exposed by this API require Super User access.
* Exposes Super User endpoints for listing translatable entities and storing custom label overrides.
* Saved translations are applied to supported dashboard, event, custom dimension, and custom report outputs.
*
* @method static \Piwik\Plugins\CustomTranslations\API getInstance()
*/
Expand All @@ -40,12 +39,13 @@ public function __construct(TranslationsDao $storage, TranslationTypeProvider $p
}

/**
* Sets (overwrites) the translations for a specific type. Make sure to pass all translations for the given type
* / language.
* @param string $idType
* @param string $languageCode
* @param array $translations An array where (original value => translation)
* @throws \Exception If type, language, or translations is not valid
* Stores the full translation map for a specific type and language.
* Pass an empty array to remove any saved translations for that type and language.
*
* @param string $idType Translation type identifier returned by getTranslatableTypes().
* @param string $languageCode Language code to store translations for.
* @param array<string, string> $translations Map of original labels to replacement labels.
* @return void
*/
public function setTranslations($idType, $languageCode, $translations = array())
{
Expand All @@ -58,10 +58,11 @@ public function setTranslations($idType, $languageCode, $translations = array())
}

/**
* Get all existing translations for a specific type and language.
* @param string $idType
* @param string $languageCode
* @throws \Exception If type, language, or translations is not valid
* Returns the saved translations for a specific type and language.
*
* @param string $idType Translation type identifier returned by getTranslatableTypes().
* @param string $languageCode Language code to load translations for.
* @return array<string, string> Translation map keyed by the original label for the requested type and language.
*/
public function getTranslationsForType($idType, $languageCode)
{
Expand All @@ -84,8 +85,10 @@ private function checkLanguageAvailable($languageCode)
}

/**
* Get a list of all translatable types.
* @return array[]
* Lists the translation types that can be configured through this plugin.
*
* @return array<int, array{id: string, name: string, description: string, translationKeys: array<int, string>}>
* Available translation type metadata, sorted by name.
*/
public function getTranslatableTypes()
{
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Changelog

### 5.0.3 - 27/04/2026

- Updated API documentation


### 5.0.2 - 02/03/2026

- Updated API documentation
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "CustomTranslations",
"description": "Translate entities and tracked values into different languages. For example Custom dimensions, dashboard names, custom report names, event values, ...",
"version": "5.0.2",
"version": "5.0.3",
"theme": false,
"require": {
"matomo": ">=5.0.0-b1,<6.0.0-b1"
Expand Down
Loading