Rather than use a plugin that uses the eval()
function, you could write a simple shortcode to handle translations. something like this:
The issue you would face is that the strings wouldn’t be picked up automatically by a tool like POEdit, you would need to manually add the strings to the translation PO files.
/**
* [__]My string to translate[/__]
*
* @param $atts
* @param $content
* @return string|void
*/
function my_translate_shortcode( $atts ,$content ){
$atts = shortcode_atts( [
'textdomain' => 'mytextdomain'
], $atts );
return __( $content, $atts['textdomain'] );
}
add_shortcode( '__', 'my_translate_shortcode' );
Related Posts:
- How to get a translated string from a language other than the current one?
- How to debug failed load_theme_textdomain()?
- Changing the language of a single page
- Set language per post
- How to add LTR to a custom theme which in RTL by default
- Qtranslate-X get raw post title value
- Interface translation without plugins
- Website Language/Locale Switching
- HTML inside __() or _e() language translation string
- Setting WPLANG from a plugin
- How to get a localized version of WordPress from a repository?
- generating po mo translating files from scratch in a wordpress theme
- How to escape the single quote character in i18n translation strings?
- what’s different between _x() and _()
- Obtain a list of available translations
- custom theme: english .mo file not working
- Unknown language json files
- Titles in my sidebar widget appear in all languages – with qtranslate
- How to escape single and plural i18n text strings?
- Make a custom theme translate-ready
- What are the most used WordPress localization?
- How to add extra language packs to WordPress
- load_plugin_textdomain in `plugins_loaded` or `init`?
- How to Translate Contact Form 7 using qTranslate? [closed]
- Translate Navigation Menu & Sidebar Widget Titles
- How to handle single quote in a translatable string in WordPress
- Translation of plugin in MU-PLUGINS directory not working
- How can I make “Leave a comment” translation ready?
- WordPress For Urdu Language
- Multiple text-domains per single plugin – admin and frontend
- Where the WordPress Core Translation is “actually” taking place?
- Do i have make the content() also translation ready in theme?
- Getting translated string through a variable
- Transfer from English page to Arabic page
- How to translate theme name
- How to get menu strings, categories and tags into po file for translation
- How to save a translation of a plugin in “CodeStyling Localization”?
- Compile errors during translation compile
- Using polylang, how can I see which post is the “original” and which are the “translated children”? [closed]
- Where is the right .mo file inside the language repository?
- setlocale for date
- where to set the PO file for a plugin?
- Change / tweak existing wordpress translations
- Should I include colon in my msgid in PO file?
- How to display get_post_type() translated?
- Replace text string on individual page
- How to syntax Json output for translation?
- Translating a word with locotranslate, but wordpress does display another by default
- How do I translate month names in post metadata?
- Can’t have a Persian website with a completely English admin panel!
- Translatable Categories
- Force translated language on front
- Translate theme only
- Translating plugin or locale file
- what’s different between _x() and _()
- WordPress translation loading english file
- Is there any way to use @wordpress/i18n for
- How can I see my theme’s text domain?
- Language file doesn’t work
- Making a string translation ready with html in it
- Translation for plugin
- How to become a translator on wordpress.org?
- Plugin has no US english translation file
- Localization, escape html elements mid-sentence
- Translation with wordpress what does the process involve?
- How to translate custom Divi module using POEDIT and Polylang [closed]
- How to translate functions.php?
- Can the qTranslateX-Plugin translate non-article text? [closed]
- How to add a translatable string to post date
- Proper way to use esc_html__ and esc_attr__ etc for escaping value for translation
- How to use esc_attr__ with custom translation function?
- Programmatically choose language for translation
- How to translate wordpress backend to another language
- Post types translation
- Translate arguments of a user added custom code [closed]
- Translate a theme with a PO file
- How to define theme translation file?
- WordPress Translation to french, at -> à not working
- Transposh Japanese language transaltion not showing up
- WP-e-commerce (getshopped) Hebrew language files – where can I get them? [closed]
- Translation for a text that is not printed on the screen
- String translation for esc_html__() when registering string [closed]
- Translations not working on Safari
- __() function inside html tags
- How to do translations in WordPress?
- printf, translation function and date_i18n adds extra characters
- How to deal with differently translated prepositions?
- Plugin localization persistance (woocommerce)
- WordPress Localization error within return value
- Plugin translation not displaying
- Setting WPLANG from a plugin
- Language & translation
- Translating form labels shortcode output
- How to translate placeholder?
- Poedit ASCII errors ( WordPress )
- Does WPML translate numbers automatically, or do I have to do the string translation? [closed]
- Translations in source code
- WPML & Events Manager translatable fields after duplication
- How to translate the blog date in the Avada theme [closed]
- Theme translation file translating some strings and not translating others