Speedy Translate for developers

Make your extension translatable with Speedy Translate from your own package, and know where Speedy Translate keeps its logs and caches.

How Speedy Translate translates

Speedy Translate stores every translation in one table, keyed by the translated table, the row's key, the field and the language. On a page in another language, it runs Joomla's queries through its own database driver: it works out which translatable tables and columns a query reads, and puts the translations into the rows before your code sees them. Your extension keeps querying its own tables as usual.

It needs to know which tables and fields are translatable, and which forms edit them. That is what an adapter declares.

Ship an adapter with your extension

Speedy Translate's bundled adapters are the files

administrator/components/com_speedytranslate/extensions/com_*.php

Read one of them, com_contact.php for instance, as the model for yours. An extension ships its own adapter in its own package: a plugin listens to the event onSpeedyRegisterAdapters and names the adapter class, which extends SpeedyTranslate\Extension\Extension.

use SpeedyTranslate\Component\Speedytranslate\Administrator\Adapter\RegisterAdaptersEvent;

public static function getSubscribedEvents(): array
{
	return ['onSpeedyRegisterAdapters' => 'registerAdapters'];
}

public function registerAdapters(RegisterAdaptersEvent $event): void
{
	// The file is optional when the class is autoloaded; given, a change to it renews the cache
	$event->addAdapter(
		'com_example',
		\Example\SpeedyTranslateAdapter::class,
		__DIR__ . '/../SpeedyTranslateAdapter.php'
	);
}
  • Put the listener in a plugin of the speedytranslate group, or in a system plugin.
  • An adapter is loaded only on its component's pages and in the translation list, so it costs nothing elsewhere.
  • Registering an adapter for a component that Speedy Translate already bundles replaces the bundled one.
  • Joomla's tag pages, their feed and the Tags - Similar module read a copy of each tagged item from #__ucm_content. Speedy Translate translates that copy as the item itself, through the field mappings of the item's content type in #__content_types, which Joomla's tags need anyway. It does so for any translatable table keyed by one column.
  • The tables every adapter declares are cached (group com_speedytranslate_adapters), renewed when an adapter file changes.
  • Adapters work the same in Speedy Translate Lite and Pro.

Coming from Falang content elements? The Falang import already brings your users' translations of your tables; they show as soon as your adapter is installed.

Content tags

Two tags work in any content or module on the site:

  • {lang fr}…{/lang} keeps the text only on pages in the language whose URL code is fr. A page drops the blocks of other languages. Tags inside form fields are left alone, so editors can write them.
  • {spt}KEY{/spt} is replaced by the language string KEY in the page's language.

A page with neither tag is not processed at all.

Logs, caches and the action log

  • Errors from translation providers, with keys masked, go to the log file:
    administrator/logs/com_speedytranslate.errors.php
  • The analysis of each query is kept in Joomla's cache, group com_speedytranslate_queries, whatever the site's caching setting. A new version of Speedy Translate's analysing code is picked up by itself.
  • The tables of the adapters are kept in Joomla's cache, group com_speedytranslate_adapters, renewed when an adapter file changes.
  • Changes to the options, and each machine translation, are recorded in Users → User Actions Log, with the plugin Action Log - Speedy Translate enabled.
  • Language string overrides and their backups are files in the component's language folder:
    administrator/components/com_speedytranslate/language/overrides/
    administrator/components/com_speedytranslate/language/backups/

System → Clear Cache empties both cache groups; Speedy Translate analyses the queries again on the next pages. Machine translation from your own code goes through the component's translation endpoint, which answers only logged-in users who can edit content, and needs Joomla's form token.

All the things you need to make your work easier. Did you like Solidres?