Short answer: You don’t. Not with the I18N functions. Data in the database is data that can change, and should be translated via some separate means. Data in the code is hard-coded, and doesn’t change, and can be translated via the I18N functions.
If you want to store all your translatable text in a single PHP file as an array, and then reference it from elsewhere in the code, then that works fine.
Related Posts:
- How to make a WordPress plugin translation ready?
- How to provide translations for a WordPress TinyMCE plugin?
- Problems with localization
- `wp_set_script_translations` with `wp.i18n` does not return translated strings in simple plugin
- Can’t we use strings defined as PHP constants if we want to translate them in a plugin?
- WordPress: After Gutenberg plugin migration to block.json the localization/ translations with PolyGlot in JavaScript does not work anymore
- Should I always prefer esc_attr_e & esc_html_e instead of _e?
- Should shorcodes in i18n plugins be translated and if so, how?
- Generate JSON files for language translation from po file without wp-cli i18n make-json
- How to prevent someone from entering strings without making it available for translation?
- Plugin language always shows WP site language, not profile language
- Is hint for translator compulsory while internationalizing a string containing variables?
- Translation not working for Constant strings in Plugin
- Save translation file of third party plugin in a custom plugin?
- Preparing a string in an array for localization
- Shortcodes, output buffering, and WordPress functions
- Multiple textdomains
- How to properly load text domain of custom mu plugin
- How does gettext works for translating readme file of plugin?
- WordPress Localization and Templating
- How to properly load text domain of custom mu plugin
- How to update the language used by wordpress from a plugin
- Singular name Plugin localization
- use __($str) to translate strings (symfony/twig)
- Plugin Localization
- Is it possible to check is loaded language files correctly with WordPress plugin?
- Translate strings not recognised in plugin
- What is the way to ship read-me strings like plugin-strings for internationalization?
- Making my plugin translation ready. Poedit not working
- Some strings from a .mo file do not load
- A better way to include localized labels in WordPress plugins
- Widget translation on my plugin
- How to render a time-of-day string like ’16:42′ with a site’s chosen time format?
- Frontend language per user
- Plugin translations not installed but… strings are translated!
- .mo translation strings not loading in PHP scripts that handle AJAX calls
- What can be reason for no plugin-strings available under stable section on translate.wordpress.org?
- Build a translation correcter plugin
- Is there a way to test that readme looks in other language before submitting translation?
- Translation per IP location [closed]
- Translate slug in WPMU with PO files
- Shortcode returning localized HTML part
- load_plugin_textdomain doestn’t work with add_action plugins_loaded
- Translate MCE button text/tooltip in custom plugin
- esc_html__() and __() not working within arrays
- Readme.txt seems to be cached but not the version
- Return Value of load_plugin_textdomain
- I18n not working in plugin
- Mixing l18n string from my plugin with WordPress’ translations
- Translate javascript with WordPress built-in localization API for static strings
- Translating plugin settings page – dropdown list
- Make dynamic string translatable
- Translation issue with global variables
- How to ignore extra whitespaces in translation functions like _e?
- Using HTML links within translatable string
- Plugin not properly prepared for localization
- How to translate wordpress backend to another language
- Borrowing of Previously Translated Strings by Child Plugin
- Translations only load from `wp-content/languages/plugins` but not from the plugin’s languages folder
- Use localized plugin name and description even when the plugin is disabled
- Include external po file for 3th party plugin to theme
- HTML Elements in my WP Plugin being generated in JS. Security and Translated Text Question about this method being used
- Do I lose translations when I change my Text domain for my plugin on wp.org?
- Transform internationalized plugin into internationalized mu-plugin?
- Load custom translation in custom plugin fails
- Add language localisation to javascript alert?
- How to store in the database directly the translation?
- Load textdomain from global languages directory
- Plugin translation not being displayed
- Problem with Poedit [closed]
- How to translate WP plugin name?
- How are themes and plugins localized using the gettext GNU framework?
- get the queried_object of an url
- React Plugin Settings Page Localization
- How to get locale within WP REST Request?
- Using composer for dependency management in plugindevelopment
- add_filter and remove_filter added before and after wp_query
- What is the difference between strip_tags and wp_filter_nohtml_kses?
- How can I hook into existing WordPress Bulk actions?
- creating elements/innerblocks via rangecontrol
- How to check if current static page is frontpage from admin plugin
- Earliest WP Hook to Safely and Reliably Redirect
- Is it possible to delay execution of shortcode output callback?
- Activate Child Theme .mo and .po files
- How can I add a custom “Text” widget to Appearance manager from functions.php?
- what are the checksums surrounding keywords in the SQL generated by WP_Query and do I need to use them too?
- How to do POST request with WP REST API v2 to custom table?
- Easy export/import of data for Translation
- Special Formatting for WordPress Plugin Description?
- Change the behaviour of a button
- Progress bar in plugin within admin
- WordPress admin panel not working
- Load script on frontend from widget plugin
- Can’t get wpColorPicker to work in a widget
- Ajax functionality not being called under wordpress plugin
- I don’t understand how symlinks in plugin work
- Help interpreting @wordpress/create-block-tutorial-template usage error
- Leveraging Core Functionality in Icon Upload Plugin [closed]
- How can I chanage the user for the composer container in wp-env?
- Adding a navigation with wp_nav_menu() to a custom block in the site editor