Polylang: pll_e() & pll__() on functions.php, doesn’t work

I have no experience with the Polylang plugin, but I think it’s safe to assume that this is has to do with load order of the Polylang plugin and your theme’s functions.php. When you call a function in the global scope (i.e. not from within another function) of index.php or any other template file, it will be executed at a late stage in the page loading process, after WordPress has been completely initialized and even after the server has begun sending the response to the client.

A function called from the global scope of the functions.php file, however, will be executed at a much earlier point. During a typical page load, essentially what happens is first WordPress will set itself up, then load the plugins and at last the theme. However, this process is not as linear as you might think, as some plugins might depend on functionality which might not be available until WordPress is completely initialized, the theme is loaded or the page server response has begun. WordPress solves this by using hooks, which allows a plugin or theme to execute code at certain stages during the load process.

To make a long answer short even longer, what you need to do is to make sure you don’t call pll_e() or pll__() until you are certain the Polylang plugin is ready. This can be determined by looking at its source (or perhaps its documentation), but I guess hooking onto to init hook will suffice. Functions called in the global scope of functions.php will be executed before the init hook, but by adding an init hook you can make a function run at a later stage. Here’s how:

function my_setup() {
    global $some_var;
    $some_var = pll__('A string in need of localization', 'localization_domain'); // This is assuming that this function behaves analogous to __() 

    pll_e("We'll just echo this, somewhere", 'localization_domain');
}
add_action('init', 'my_setup');