Is it allowed to call t($variable)? In Drupal 7 t() this warning was present:


  You should never use t() to translate variables


In Drupal 8, well, it's Drupal 8, who knows where to even look?

I tried


StringTranslationTrait::t
t()
LocaleTranslation::getStringTranslation()


and haven't found a similar warning. But absence of evidence is not evidence of absence. Is it OK now to use a variable?
The advice is the same, it's just moved. The docs for t() say:


  See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct()for important security information and usage guidelines.


On that page you'll find familiar advice:


  Translating Variables
  $string should always be an English literal string.
  
  $string should never contain a variable, such as:
  
  new TranslatableMarkup($text);
  
  ...


So generally speaking no, it's not OK to pass a variable as the first argument to t() in Drupal 8. Always use a literal string.

If you need to use variables for t(), pass a literal string containing placeholders, and a second argument containing their replacements. For example:

new TranslatableMarkup("@name's blog", [
  '@name' =&gt; $account
    -&gt;getDisplayName(),
]);