There are filter hooks that will let you alter strings in any manner you care to define. However, you can only use WP localization functions on predefined, known strings. They cannot translate any random string that you happen to pass to them.
There are a few different established approaches to handle translations.
Multilingual WordPress
Thank you for replay. I know I can call WP localization functions as plugin developer.
But I was more wondering if the localization can be requested directly from Post/Page Editor – accessible via standard Editor Role User (not developer). Something like shortcode: [translate “Edit Page”].
The first idea was to make a plugin doing only extension of predefined known strings (*.po and *.mo files) and Editors can used them when editing Post/Page. I can still implement such shortcode into mentioned plugin.
Thank you also for the link. Good list of localization approaches in different plugins.
Shortcode handler functions can call any PHP resource, so in theory yes, but the strings passed to translate in the shortcode must be of limited scope since they have to be pre-defined. I’m unsure how practical this would be except in very specific situations. Authors could have difficulty providing precisely the correct phrase as a shortcode attribute.
I imagine a custom block that presents a dropdown of common phrases that all exist in the .mo files. It could then dynamically translate the chosen phrase based on the current user’s locale.
Thank you for clarify.
My idea was to use it in oposit way. At the first create pages in base languages (English) using some of discussed shortcode (for sentences or whole paragraphs). Then create own .mo files based on those pages, so build translation step-by-step with single page for all languages. Yes, there is question if this is useful approach.
My original question was if there is such tool in default WordPress. And it must be developed as plugin.
Such functionality is technically feasible in a theme, but a plugin makes much more sense. Theme are meant to manage appearance, not functionality.
You could send page content out to a machine translation service so any arbitrary content could be displayed in the current locale’s language. Of course, such translations do not always do a very good job of it, but the result is usually understandable.
The gettext translation scheme is intended for single phrases. It doesn’t do as well with larger blocks of text that may contain HTML for paragraph breaks and other text styling. IMO you’re better off using one of the approaches outlined in the article I initially linked.