• Extensions
  • Linguist, customize translations with ease

Hari unfortunately Linguist can't help here because the translation system is not used for this.

It's relatively easy to make the change using some custom code in the root extend.php file:

<?php

use Flarum\Extend;

class MailServiceProvider extends \Flarum\Foundation\AbstractServiceProvider {
    public function register()
    {
        $this->container->extend('mailer', function ($mailer) {
            $mailer->alwaysFrom(
                $this->container->make('flarum.settings')->get('mail_from'),
                'EmailFromName' // Change this string with your custom name
            );
            
            return $mailer;
        });
    }
}

return [
    // Register extenders here to customize your forum!
    (new Extend\ServiceProvider())->register(MailServiceProvider::class),
];

An extension could easily add this as a new field on the Admin > EMail page. I'm not sure why Flarum doesn't make the From name customizable. It's indeed hard-coded to be the forum name by default.

    Hari The main extend.php file will not be overwritten, only the stuff in the vendor folder.

      me again 👀, when my server gets stuck due to heavy load flarum throws an error saying "flarum Encountered Boot Error" how can i change this error message?

      i want it to be generic saying We Encountered Boot Error don't want to confuse my users with the word "flarum"

        Hari unfortunately that error message cannot be customized. It's hard-coded on purpose because on boot error the translation system might not be available.

        It's not supposed to be visible unless something went terribly wrong though. What is the actual error behind the scene? You might be able to solve/detect the issue at that level and react accordingly.

        For instance if it's the database that receives too many connections, a Flarum extension could detect it before it's too late and offer a custom error page for that situation.

          clarkwinkelmann true but at the same time i can not divert my users saying "flarum" i request to edit this at the core level to We Encountered Boot Error in later versions of flarum.

            Hari we can certainly discuss a change for core, but in my opinion it's important that the error message contains the word "Flarum" so a forum administrator understands which part of the software is throwing the error. Otherwise it's difficult to tell whether it's an error at the webserver level or at the Flarum level. It speeds up troubleshooting a lot when you know what fact.

            You might be able to change your webserver configuration to force a given HTML file to be rendered for all 500 errors.

            Changing the message in Flarum locally will require some Composer tricks to provide an override file, or place the overridden class in a different namespace and call it from index.php. I don't think it's possible to just wrap everything in a new try/catch block, because the bit of code where this message is hard-coded is the big try/catch block that catches everything the regular Flarum error handler can't handle.

            But again, that page is not supposed to be visible under normal operation. Feel free to open a new issue/discussion about your actual 500 error so we can see if we can handle this situation more gracefully and not end up with a boot error in the first place.

              clarkwinkelmann sure, i have deleted old logs once I face the same issue again i will start a new discussion with log

              2 months later

              clarkwinkelmann How to add new language to translate to it i mean like in the topic picture
              english (en)
              italiano
              instead of translating strings to my desires lang in field of All

                AhmedShiboub languages need to be registered by a language pack. This extension is then intended for changing or completing the existing translations.

                If you want to translate for a language that doesn't have a language pack yet, you would have to create the pack, even with no translations inside, just to define and enable the language. This shouldn't be an issue for Italian since I assume a pack is available.

                If you already have the language installed, make sure it's enabled. To complete missing translations, you also need to have one other language pack enabled that contains those missing translations in a different language, so it's best to keep English enabled during this process to make sure every single string gets listed. You can disable English once you're done translating.

                  clarkwinkelmann can i download an arabic package even it is incompatible then retranslated it using linguist extension cauz translation using weblate is exhausting to me especially many refreshing the page after each string translation

                    AhmedShiboub the pack needs to be compatible with your Flarum version, it just doesn't need to be complete.

                    If you have control over the source code of an existing pack, there shouldn't be a lot of work to get to that stage from a language pack that was only compatible with Flarum beta. You might need to switch the code in extend.php with a new extender and replace the required Flarum version in composer.json.

                    If you are planning to translate an entire language, working directly in Yaml format in the language pack source code shouldn't be too much additional effort compared to using Linguist. And you have the benefit of being able to re-distribute the pack easily once done.

                      halimjr i know but i need a name of my language like Endlish (en) in the topic picture

                      a month later

                      @clarkwinkelmann
                      I got this error on an instance deployed over freeflarum where I wanted to translate to Cyrillic and titles are in Cyrillic. This error is thrown and the page doesn't load when I open a link to a post directly, if I open the root URL its fine. Any ideas?

                      Next Symfony\Component\Translation\Exception\InvalidArgumentException: Invalid message format (error #65807): msgfmt_create: message formatter creation failed: U_DEFAULT_KEYWORD_MISSING in /app/vendor/symfony/translation/Formatter/IntlFormatter.php:43
                      Stack trace:
                      #0 /app/vendor/symfony/translation/Formatter/MessageFormatter.php(54): Symfony\Component\Translation\Formatter\IntlFormatter->formatIntl()
                      #1 /app/vendor/symfony/translation/Translator.php(223): Symfony\Component\Translation\Formatter\MessageFormatter->formatIntl()
                      #2 /app/vendor/flarum/core/src/Frontend/Driver/BasicTitleDriver.php(41): Symfony\Component\Translation\Translator->trans()
                      #3 /app/vendor/flarum/core/src/Frontend/Document.php(221): Flarum\Frontend\Driver\BasicTitleDriver->makeTitle()
                      #4 /app/vendor/flarum/core/src/Frontend/Document.php(204): Flarum\Frontend\Document->makeTitle()
                      #5 /app/vendor/flarum/core/src/Frontend/Document.php(195): Flarum\Frontend\Document->makeView()
                      #6 /app/vendor/flarum/core/src/Frontend/Controller.php(32): Flarum\Frontend\Document->render()
                      #7 /app/vendor/flarum/core/src/Http/RouteHandlerFactory.php(41): Flarum\Frontend\Controller->handle()
                      #8 /app/vendor/flarum/core/src/Http/Middleware/ExecuteRoute.php(27): Flarum\Http\RouteHandlerFactory->Flarum\Http\{closure}()
                      #9 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\ExecuteRoute->process()
                      #10 /app/vendor/fof/oauth/src/Middleware/ErrorHandler.php(50): Laminas\Stratigility\Next->handle()
                      #11 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): FoF\OAuth\Middleware\ErrorHandler->process()
                      #12 /app/vendor/fof/secure-https/src/Middlewares/ContentSecurityPolicyMiddleware.php(32): Laminas\Stratigility\Next->handle()
                      #13 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): FoF\SecureHttps\Middlewares\ContentSecurityPolicyMiddleware->process()
                      #14 /app/vendor/flarum/core/src/Http/Middleware/ContentTypeOptionsHeader.php(21): Laminas\Stratigility\Next->handle()
                      #15 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\ContentTypeOptionsHeader->process()
                      #16 /app/vendor/flarum/core/src/Http/Middleware/ReferrerPolicyHeader.php(30): Laminas\Stratigility\Next->handle()
                      #17 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\ReferrerPolicyHeader->process()
                      #18 /app/vendor/flarum/core/src/Http/Middleware/FlarumPromotionHeader.php(30): Laminas\Stratigility\Next->handle()
                      #19 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\FlarumPromotionHeader->process()
                      #20 /app/vendor/flarum/core/src/Http/Middleware/ShareErrorsFromSession.php(57): Laminas\Stratigility\Next->handle()
                      #21 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\ShareErrorsFromSession->process()
                      #22 /app/vendor/flarum/core/src/Http/Middleware/CheckCsrfToken.php(36): Laminas\Stratigility\Next->handle()
                      #23 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\CheckCsrfToken->process()
                      #24 /app/vendor/flarum/core/src/Http/Middleware/ResolveRoute.php(67): Laminas\Stratigility\Next->handle()
                      #25 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\ResolveRoute->process()
                      #26 /app/vendor/flarum/core/src/Http/Middleware/SetLocale.php(51): Laminas\Stratigility\Next->handle()
                      #27 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\SetLocale->process()
                      #28 /app/vendor/flarum/core/src/Http/Middleware/AuthenticateWithSession.php(31): Laminas\Stratigility\Next->handle()
                      #29 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\AuthenticateWithSession->process()
                      #30 /app/vendor/flarum/core/src/Http/Middleware/RememberFromCookie.php(52): Laminas\Stratigility\Next->handle()
                      #31 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\RememberFromCookie->process()
                      #32 /app/vendor/flarum/core/src/Http/Middleware/StartSession.php(61): Laminas\Stratigility\Next->handle()
                      #33 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\StartSession->process()
                      #34 /app/vendor/flarum/core/src/Http/Middleware/CollectGarbage.php(46): Laminas\Stratigility\Next->handle()
                      #35 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\CollectGarbage->process()
                      #36 /app/vendor/flarum/core/src/Http/Middleware/ParseJsonBody.php(28): Laminas\Stratigility\Next->handle()
                      #37 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\ParseJsonBody->process()
                      #38 /app/vendor/migratetoflarum/canonical/src/Middlewares/CanonicalRedirectMiddleware.php(49): Laminas\Stratigility\Next->handle()
                      #39 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): MigrateToFlarum\Canonical\Middlewares\CanonicalRedirectMiddleware->process()
                      #40 /app/vendor/flarum/core/src/Http/Middleware/HandleErrors.php(57): Laminas\Stratigility\Next->handle()
                      #41 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\HandleErrors->process()
                      #42 /app/vendor/flarum/core/src/Http/Middleware/InjectActorReference.php(25): Laminas\Stratigility\Next->handle()
                      #43 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\InjectActorReference->process()
                      #44 /app/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(76): Laminas\Stratigility\Next->handle()
                      #45 /app/vendor/middlewares/request-handler/src/RequestHandler.php(84): Laminas\Stratigility\MiddlewarePipe->process()
                      #46 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Middlewares\RequestHandler->process()
                      #47 /app/vendor/middlewares/base-path-router/src/BasePathRouter.php(101): Laminas\Stratigility\Next->handle()
                      #48 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Middlewares\BasePathRouter->process()
                      #49 /app/vendor/laminas/laminas-stratigility/src/Middleware/OriginalMessages.php(36): Laminas\Stratigility\Next->handle()
                      #50 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Laminas\Stratigility\Middleware\OriginalMessages->process()
                      #51 /app/vendor/middlewares/base-path/src/BasePath.php(73): Laminas\Stratigility\Next->handle()
                      #52 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Middlewares\BasePath->process()
                      #53 /app/vendor/flarum/core/src/Http/Middleware/ProcessIp.php(24): Laminas\Stratigility\Next->handle()
                      #54 /app/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\ProcessIp->process()
                      #55 /app/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(76): Laminas\Stratigility\Next->handle()
                      #56 /app/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(65): Laminas\Stratigility\MiddlewarePipe->process()
                      #57 /app/vendor/laminas/laminas-httphandlerrunner/src/RequestHandlerRunner.php(96): Laminas\Stratigility\MiddlewarePipe->handle()
                      #58 /app/vendor/flarum/core/src/Http/Server.php(44): Laminas\HttpHandlerRunner\RequestHandlerRunner->run()
                      #59 /app/public/index.php(22): Flarum\Http\Server->listen()
                      #60 {main}  

                        gkkirilov are you able to access the admin panel? Could you share a screenshot or Yaml export of your custom translations?

                        There's likely an issue with one of the translations used in the Flarum "no-js" HTML for the discussion page.

                        If you didn't customize any translation that appears on that page, maybe it's an issue with the language pack itself?

                          4 months later

                          Hi.
                          In Flarum 1.5 when i enable this extension, all titles showing like this:

                          {1, plural, =1 {{Test Forum}} other {Page # - {Test Forum}}}

                          This kind of title even show in page's source so google will fetch titles like this!
                          I mean if i see my page's source, the title tag is like this:

                          <title>{1, plural, =1 {{Test Forum}} other {Page # - {Test Forum}}}</title>

                          I hope you fix this bug. This extension works fine in Flarum 1.4.1 but have mentioned bug in 1.5.

                          also my php flarum info:

                          Flarum core 1.5.0
                          PHP version: 8.0.19
                          MySQL version: 10.4.24-MariaDB
                          Loaded extensions: Core, bcmath, calendar, ctype, date, filter, hash, iconv, json, SPL, pcre, readline, Reflection, session, standard, mysqlnd, tokenizer, zip, zlib, libxml, dom, PDO, bz2, SimpleXML, xml, xmlreader, xmlwriter, openssl, curl, fileinfo, gettext, mbstring, exif, mysqli, pdo_mysql, pdo_sqlite, Phar, ftp
                          +--------------------------------------+---------+--------+
                          | Flarum Extensions                    |         |        |
                          +--------------------------------------+---------+--------+
                          | ID                                   | Version | Commit |
                          +--------------------------------------+---------+--------+
                          | flarum-flags                         | v1.5.0  |        |
                          | flarum-markdown                      | v1.5.0  |        |
                          | flarum-suspend                       | v1.5.0  |        |
                          | flarum-subscriptions                 | v1.5.0  |        |
                          | flarum-tags                          | v1.5.0  |        |
                          | flarum-approval                      | v1.5.0  |        |
                          | askvortsov-rich-text                 | v2.1.7  |        |
                          | flarum-lock                          | v1.5.0  |        |
                          | flarum-likes                         | v1.5.0  |        |
                          | afrux-forum-widgets-core             | v0.1.7  |        |
                          | fof-user-directory                   | 1.2.3   |        |
                          | fof-follow-tags                      | 1.1.6   |        |
                          | flarum-nicknames                     | v1.5.0  |        |
                          | fof-spamblock                        | 1.0.2   |        |
                          | fof-pages                            | 1.0.4   |        |
                          | fof-oauth                            | 1.2.2   |        |
                          | fof-byobu                            | 1.1.7   |        |
                          | v17development-blog                  | v0.6.4  |        |
                          | v17development-seo                   | v1.8.0  |        |
                          | the-turk-flamoji                     | 1.0.4   |        |
                          | sycho-profile-cover                  | v1.3.3  |        |
                          | swaggymacro-only-starter             | 0.6.4   |        |
                          | noriods-auto-more                    | v1.0.0  |        |
                          | nearata-twofactor                    | v2.1.1  |        |
                          | nearata-no-self-likes                | v1.2.1  |        |
                          | nearata-internal-links-noreload      | v2.1.3  |        |
                          | nearata-embed-video                  | v3.2.1  |        |
                          | miniflar-top-like-givers-widget      | 0.1.0   |        |
                          | mickmelon-coloured-usernames         | 0.1.1   |        |
                          | malago-achievements                  | 0.5.5   |        |
                          | justoverclock-welcomebox             | 1.3.7   |        |
                          | justoverclock-thread-read-time       | 0.1.7   |        |
                          | justoverclock-last-registered-users  | 0.1.5   |        |
                          | justoverclock-header-slideshow       | 0.1.1   |        |
                          | justoverclock-hashtag                | 1.0.1   |        |
                          | justoverclock-guestengagement        | 1.0.3   |        |
                          | justoverclock-feedback               | 0.1.9   |        |
                          | justoverclock-custom-html-widget     | 0.1.4   |        |
                          | justoverclock-contactme              | 0.2.3   |        |
                          | justoverclock-auto-post-count-badge  | 0.1.9   |        |
                          | irmmr-rtl                            | V0.1.4  |        |
                          | ianm-synopsis                        | 1.2.1   |        |
                          | ianm-follow-users                    | 1.2.0   |        |
                          | glowingblue-password-strength        | 3.1.0   |        |
                          | fof-username-request                 | 1.0.1   |        |
                          | fof-user-bio                         | 1.1.0   |        |
                          | fof-upload                           | 1.2.3   |        |
                          | fof-terms                            | 1.2.0   |        |
                          | fof-subscribed                       | 1.1.2   |        |
                          | fof-stopforumspam                    | 1.2.1   |        |
                          | fof-split                            | 1.1.0   |        |
                          | fof-sitemap                          | 2.0.1   |        |
                          | fof-share-social                     | 1.1.0   |        |
                          | fof-recaptcha                        | 1.1.0   |        |
                          | fof-pwned-passwords                  | 1.0.2   |        |
                          | fof-profile-image-crop               | 1.0.1   |        |
                          | fof-prevent-necrobumping             | 1.1.0   |        |
                          | fof-pretty-mail                      | 1.1.1   |        |
                          | fof-polls                            | 1.2.0   |        |
                          | fof-nightmode                        | 1.5.0   |        |
                          | fof-moderator-notes                  | 1.1.0   |        |
                          | fof-merge-discussions                | 1.3.1   |        |
                          | fof-links                            | 1.1.2   |        |
                          | fof-linguist                         | 1.0.4   |        |
                          | fof-gamification                     | 1.5.0   |        |
                          | fof-formatting                       | 1.0.2   |        |
                          | fof-drafts                           | 1.1.2   |        |
                          | fof-disposable-emails                | 1.0.0   |        |
                          | fof-best-answer                      | 1.2.3   |        |
                          | flarum-sticky                        | v1.5.0  |        |
                          | flarum-statistics                    | v1.5.0  |        |
                          | flarum-mentions                      | v1.5.0  |        |
                          | flarum-lang-english                  | v1.5.0  |        |
                          | flarum-emoji                         | v1.5.0  |        |
                          | flarum-bbcode                        | v1.5.0  |        |
                          | ffans-clipboardjs                    | v1.0.0  |        |
                          | extiverse-mercury                    | 0.2.0   |        |
                          | datlechin-title-length               | v0.1.1  |        |
                          | datlechin-silent-edit                | v0.1.0  |        |
                          | datlechin-more-discussions           | v0.1.0  |        |
                          | datlechin-bbcode-hide-content        | v0.1.5  |        |
                          | darkle-fancybox                      | 1.1.2   |        |
                          | clarkwinkelmann-username-blacklist   | 1.0.0   |        |
                          | clarkwinkelmann-predefined-avatars   | 1.0.1   |        |
                          | clarkwinkelmann-post-bookmarks       | 1.0.0   |        |
                          | clarkwinkelmann-mass-actions         | 1.1.2   |        |
                          | clarkwinkelmann-first-post-approval  | 1.0.1   |        |
                          | clarkwinkelmann-discussion-bookmarks | 2.0.0   |        |
                          | clarkwinkelmann-colorful-borders     | 1.0.0   |        |
                          | clarkwinkelmann-author-change        | 1.0.2   |        |
                          | blomstra-sort-order-toggle           | 0.2.0   |        |
                          | blomstra-mark-unread                 | 0.2.0   |        |
                          | askvortsov-moderator-warnings        | v0.6.1  |        |
                          | askvortsov-markdown-tables           | v1.2.1  |        |
                          | afrux-top-posters-widget             | v0.1.4  |        |
                          | afrux-online-users-widget            | v0.1.6  |        |
                          | afrux-forum-stats-widget             | v0.1.1  |        |
                          | acpl-mobile-tab                      | 1.1.0   |        |
                          | acpl-lscache                         | 0.4.1   |        |
                          +--------------------------------------+---------+--------+
                          Base URL: http://localhost/flarum/public
                          Installation path: C:\xampp\htdocs\flarum
                          Queue driver: sync
                          Mail driver: smtp
                          Debug mode: off