'translation __() function doesnt seem to be working inside class

Why using __() this function inside Class SomeClass {} doesnt work?:

Class SomeClass {
public function setSections()
    {
        $args = [
            [
                'id' => 'settings_index',
                'title' => __("Settings" ,"plugin-name"),
                'page' => 'settings',
            ]
        ];

        $this->fieldSettings->setSections($args);
    }
}

Translations works when I dont use it inside Class brackets. How to fix this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source