8.4.2 page names installed during package installation not translated

Permalink
I install pages during a package installation, the install():
$page = Page::getByPath('/my-page');
if (!is_object($page) || $page->isError()) {
    $page = Page::getByID(1)->add(
        PageType::getByHandle('page'),
        array(
            'cName' => t('My Page'),
            'cHandle' => 'my-page',
            'pkgID' => $pkg->getPackageID(),
        )
    );
}

however the page name 'My Page' does not get translated. If I change its name in the Site Map, then it gets translated. What's the problem? Does the translator work during installation?

Thank you.

linuxoid
 
A3020 replied on at Permalink Reply
A3020
You shouldn't wrap the page name in the t-function during *install*. Once the page is installed, it's outputted via the t-string, then it's translated.
linuxoid replied on at Permalink Reply
linuxoid
Does anything get translated during install?
A3020 replied on at Permalink Reply
A3020
Would it matter? Say I install an add-on when logged in as a Spanish user, a pages could be added in Spanish. 'Bienvenido' wouldn't be found as a source language string (as opposed to 'Welcome'), for example.
linuxoid replied on at Permalink Reply
linuxoid
It matters to the number of using the t(). If I wrap a string in t() during install which is then used 100 times throughout - this is 1 t(). Otherwise I have to use t() 100 times.
A3020 replied on at Permalink Reply
A3020
Yes, that's true. That's probably also why you'd find so many t-calls in the core. But if you translate it during install, then your base / source string might not be in English.
linuxoid replied on at Permalink Reply
linuxoid
Well, thinking more about it, why does it matter at all where the t() is if translations are taken from the language file, not from the php. I guess the questions then should be why doesn't the translator pick up the page name translation AFTER installation?