Translate
ianm/translate
Translate post content
- Downloads
- 24,870
- Subscribers
- 16
Plan comparison
Plans
Subscribe to any of the available plans below.
Translate for Flarum helps translate all your discussions without you having to do a thing. Using AI, all comments on your community can be auto-translated based on the user's language; it's as simple as clicking a button. Furthermore, the extension now supports discussion title translations.
All monthly/yearly subscription plans come with a 7-day free trial, so you can determine if this extension is right for you or not.
Technical support and updates are both included in your subscription.
Features
- Post Language Detection: A handy label is displayed when the post is viewed if the viewer's locale differs from that of the post. User preference option to always show the label, if required.
- Discussion Title Translations: Easily detect and translate discussion titles.
- Post language detection is independent of any installed Forum language packs.
- On-Demand Post Translation: Displayed directly under the original content. Translations are cached in the database to reduce the number of translation requests to the provider, saving money (if your provider charges per translation request), and provide a speed increase.
- Formatting Preservation: Formatting is preserved as far as possible between the original and translated content by running translated content back through the same post renderer as the original.
- Seamless Translations: Users may translate from any driver-supported language to any enabled forum language (subject to permission). Just one language pack installed? No problem! This extension will simply translate any 'foreign' posts to your single language seamlessly.
- Automatic Updates: Cached translations are updated after a post has been edited.
-
Multiple Translation Driver Support: Supports various translation sources like Google Translate, Google Cloud Translate, DeepL, and more. See
Drivers
below. -
Translation Permissions: Define any level of access to view translations, from
Guest
users and up, to suit your needs. - Admin Controls: Admin users may force a refresh of any translation, if required.
Screenshots
Regular permissions, English locale, Welsh content.
Regular permissions German locale, Welsh content.
Translate All
permission, English locale, Welsh content.
Permission options
User preference options
Premium
This extension requires an active subscription from extiverse. Once your subscription is active you can follow the instructions on the Extiverse subscriptions page to configure composer. Once completed you can run the following command for installation:
composer require ianm/translate
For updates:
composer update ianm/translate
php flarum migrate
php flarum cache:clear
Installation
After setting up your subscription (as described above) and installing the extension, it will be pre-configured to use the Google Translate
driver. See Drivers for information on how to select and configure drivers.
Once the extension is enabled, any existing forum posts will not have their language detected. This means that the language header for each post will not be displayed, and the available translation options will not be as filtered as normal (i.e., normally the option to translate a post to the language it was written in is not displayed). As each post is edited, its language will be detected and will be stored and only updated if the content changes.
Alternatively, you can use the CLI to process all posts and detect their language ahead of first use. See CLI below.
By default, all users (including guests) may translate post content to that of their current locale when the post content differs from it.
Drivers
Google Translate
Status: Production ready. A "best effort" translation using the translate.google.com
website. Ideal for testing, initial setup, etc.
This driver uses Google Translate
APIs under the hood, but without any configuration required.
Google Cloud Translate
Status: Production ready. Additional costs via Google Cloud may apply.
Setup steps:
- Log in to Google Developer Console
- Create a new
Project
to contain your translation API, and enable any billing as required. - Select
Enable API
and search forCloud Translation API
and enable it. - Click
Create Credentials
and chooseAPI Key
. Give this key a name so you can refer back to it at a later date. Optionally, restrict this key to the translation API only for improved security. - Once you have generated your key, copy/paste it into the
Google Cloud Translator
section of this extension's settings.
DeepL
Status: Production ready. Additional costs via DeepL may apply, depending on your chosen plan.
Supports both the DeepL free and Pro variants, formality setting and English "flavour" (en-US or en-GB)
Setup steps:
- Log in and choose a plan at DeepL
- Follow the signup steps as described. Note, you will need to enter billing information, even for the free teir.
- Once you have setup your new account, obtain your API key from DeepL Account Settings and enter it into the relevant setting field in this extension.
- [optional] set your preferences for
Formality
andEnglish variant
LibreTranslate
Status: beta. Supports self hosted or hosted Libre instances.
Setup steps:
- URL
- Port
- Token, if required by your chosen instance.
AWS Translate
Status: planned
Azure Cognitive Services Translator
Status: planned
Yandex Translate
Status: planned
Translation strings
While user-generated content is handled by your chosen translation driver, some of the UI elements of this extension rely on traditional Flarum language packs. Check on the status of your language on weblate
CLI
This extension provides several command-line interfaces (CLI) to detect and handle the languages of discussions and posts. Here are the commands, their options, and a brief description:
translate:detect
This command detects the language of both discussions and posts that do not have a detected language set.
Options
--force: Force all items (discussions/posts) to be re-detected.
Example:
php flarum translate:detect
php flarum translate:detect --force
translate:detect-discussions
Detects the language of all discussions that do not have a detected language set.
Options
--discussion=ID: Specify the discussion ID to detect languages. Replace ID with the appropriate discussion ID.
--force: Force all discussions to be re-detected.
Examples:
php flarum translate:detect-discussions --discussion=26
php flarum translate:detect-discussions --force
php flarum translate:detect-discussions --discussion=26 --force
translate:detect-posts
Detects the language of all posts that do not have a detected language set.
Options
--post=ID: Specify the post ID to detect languages of posts. Replace ID with the appropriate post ID.
--force: Force all posts to be re-detected.
Examples:
php flarum translate:detect-posts --post=15
php flarum translate:detect-posts --force
php flarum translate:detect-posts --post=15 --force
You should ensure that all discussions/posts have had their languages identified, so that the correct translation experience is presented to your forum users.
Custom BBCode and translations
If you use custom BBCode within your Flarum project, these custom BBCodes MUST be registered with the translation service, else they may get translated and therefore break them.
(new Extend\Conditional())
->whenExtensionEnabled('ianm-translate', fn () => [
(new \IanM\Translate\Extend\Translate())
->addBBCodeIdentifiers(['custom-bbcode', 'another-custom-bbcode'])
])
FAQs
How are translation updates handled?
When a post is edited, all cached translations are marked as "needing an update". Rather than automatically refreshing all translations for that post, the next time a translation for x
language is requested, we call the translation service to provide it seamlessly on demand. This helps to reduce translation costs and server load too.
Future improvements/additions
In addition to the stated additional translation provider drivers, other features may be added over time. These will be driven by subscriber feedback. Accepted and planned improvements will appear here.
- Support for
fof/polls
- now included as a beta feature, disabled by default.
Support
Technical support is included in your subscription and is provided in the first instance on Discuss, but can also be provided via email, Discord, etc., as required.
Links
Versions
-
Version 0.5.0-beta.57.
Likely works with Flarum v1.8.9.
-
77 additional versions.
-
Extension created.