As your function returns the translated string, you could pass the translation function as parameter for esc_attr()
and esc_attr_e()
:
esc_attr__( __myfunction( 'no_comments' ) );
esc_attr_e( __myfunction( 'no_comments' ) );
But esc_attr__()
and esc_attr_e()
will perform translation tasks that you don’t need because you handle the translation at your own, so I think it is better to use esc_attr()
only:
esc_attr( __myfunction( 'no_comments' ) );
and
echo esc_attr( __myfunction( 'no_comments' ) );
Related Posts:
- Override default WordPress core translation
- How to get a translated string from a language other than the current one?
- Custom strings for translation using Polylang plugin
- Working with l10n contexts (_x etc)
- How to debug failed load_theme_textdomain()?
- How do translated, escaped strings (esc_attr) in Themes work?
- How to handle text with function __(?
- How do I translate: “2 hours and 15 minutes”?
- Disabling Translation Update
- How to save a translation of a plugin in “CodeStyling Localization”?
- Set language per post
- List of Default Translated Phrases
- Difference between 2 internationalization (i18n) functions __() & _e()
- How to extract translatable (double underscores and _e) strings?
- How to set locale in ajax requests?
- Translate content, not instance, per-post
- How to load theme textdomain from plugin?
- Make theme translatable for WPML
- get_the_date() for translating date format
- How can I make “Leave a comment” translation ready?
- Custom translation of Month names
- Multiple text-domains per single plugin – admin and frontend
- How to add translation for a string
- New plugin translation does not work
- POEdit with Custom mu-plugins code
- Make changes to translation?
- Gutenberg not all editor text translated
- How does WordPress choose which translation file to use?
- Use WordPress default text domain for translating labels
- Is this a correct usage of esc_html_e?
- WPML Translated Term
- Where is the right .mo file inside the language repository?
- setlocale for date
- translating wordpress with poedit
- Replacing strings within posts with the translatable string
- WPML custom string translation get outside of container
- Change template copy with po/mo files
- Implementing conditional gettext translation
- Translations not returning translated strings
- Can’t generate pot file using wp cli
- How to avoid override string by child theme mo files when the string is empty?
- How to translate timestamp?
- How to override default WordPress core language file
- Translate pages and URLs without duplicating
- How can you locate the .po file used for translation of a page?
- Add a string to file .pot using Poedit
- Use the wp-admin translations on the front end
- Translating dynamic strings
- Translate theme only
- How do I troubleshoot translation issues?
- Easy export/import of data for Translation
- How to change a word in theme?
- WordPress Theme .mo-file won’t load
- Using _e() or __() to translate text with div
- Is it best practice to use English as the base of a translation-ready theme?
- WordPress Translation Issue
- How to translate “$before” with get text in get_the_term_list?
- WordPress localization – gettext and git
- Translation with wordpress what does the process involve?
- Get Text Domain For Transalation
- Found a translation function that is missing a text-domain. Function _n
- Can I set WordPress to display languages based on system language without a plugin?
- Fix Problem With Textdomain Translation
- /languages/ folder missing in default themes
- WordPress Translations
- Trying to localize a Underscores starter theme [duplicate]
- Programmatically choose language for translation
- Post types translation
- mo / po translation files does not seem to work
- Internationalize plugin so strings can be translated in WPML [closed]
- localization of theme and plugins to English (originally in another language)
- String translation for esc_html__() when registering string [closed]
- Making WP theme / plugin multii-lingual without plugins
- __() function inside html tags
- How to do translations in WordPress?
- Can’t translate child theme
- Qtranslate-X get raw post title value
- Interface translation without plugins
- WordPress does not translate
- Debug WordPress gettext function
- How to use translation functions inside WordPress page
- qtranslate loading the wrong language
- issue in translating a wordpress them
- Understanding WordPress Default Theme – twentyfifteen.1.4 >> Languages Folder
- WordPress Localization error within return value
- Custom theme .mo translation file not working
- Plugin translation not displaying
- Adding a translation phrase to WordPress Theme
- Translate Plugin with french as base language
- WordPress translation
- Language & translation
- Tweak the loop for translation
- GlotPress – WordPress integration
- How to translate placeholder?
- Archive widget numbers translation?
- Translations in source code
- String translation with or without po file
- Translating “comments”, “leave a comment”, “prev”, “next”, “share”
- Website Language/Locale Switching
- Can’t load text domain in a mu-plugin