When you have content in custom code, it needs to be output using specific functions and other methods to ensure it can be translated through the administrative UI. How this is exposed depends on the manner it is embedded in the code.
Using the multilingual API
PHP code
Like Drupal 7, there are still the t() and format_plural() functions. However, the functionality behind these relies on the TranslationManager class. This means that it can be dependency injected into any Drupal 8 services, controllers, plugins, and so on. This is the preferred mechanism for translating text in PHP, and many base plugin classes in Drupal already implement functions that delegate to the TranslationManager.
One thing to be aware of is that the...