Load translation files as late as possible for your plugin’s use-case. This allows other plugins as much time as possible to fully initialise.
Why should you care about other plugins? Because they may be involved in the localisation process too. For example, changing the site language or filtering translation file paths. They can’t do those things if you beat them to it.
From your two examples: plugins_loaded
fires first, so init
is the better of the two in most cases. However, it still runs the risk that your init code fires before another plugin’s init code, so set a low priority in your add_action call. (larger number = lower priority).
If your translations are needed earlier then you’ll have to load them earlier. However, if you need them earlier than init then your whole setup might be firing too early.
Related Posts:
- How to debug failed load_theme_textdomain()?
- Multiple text-domains per single plugin – admin and frontend
- How to get menu strings, categories and tags into po file for translation
- Use WordPress default text domain for translating labels
- Use the wp-admin translations on the front end
- How can I see my theme’s text domain?
- WordPress Theme .mo-file won’t load
- How to solve a translation function issue with no arguments and missing a text-domain?
- Fix Problem With Textdomain Translation
- What is a Theme textdomain?
- Override default WordPress core translation
- Different Language for Frontend vs Backend
- How to get a translated string from a language other than the current one?
- Is it ok to use a function to output the text domain name in a wordpress theme
- Custom strings for translation using Polylang plugin
- Is a text-domain necessary for a child theme
- How to get a localized version of WordPress from a repository?
- Working with l10n contexts (_x etc)
- How-to: Translate plural forms for themes/plugins with PoEdit
- generating po mo translating files from scratch in a wordpress theme
- How to escape the single quote character in i18n translation strings?
- How do translated, escaped strings (esc_attr) in Themes work?
- Changing the language of a single page
- what’s different between _x() and _()
- How to handle text with function __(?
- Obtain a list of available translations
- How do I translate: “2 hours and 15 minutes”?
- Disabling Translation Update
- custom theme: english .mo file not working
- Unknown language json files
- How to save a translation of a plugin in “CodeStyling Localization”?
- How to escape single and plural i18n text strings?
- How to load translation in JavaScript?
- Set language per post
- Overwrite textdomain of plugins by default – Lost Translation
- List of Default Translated Phrases
- What are the most used WordPress localization?
- How to add extra language packs to WordPress
- Difference between 2 internationalization (i18n) functions __() & _e()
- How to extract translatable (double underscores and _e) strings?
- How to Translate Contact Form 7 using qTranslate? [closed]
- How to set locale in ajax requests?
- translation does not work with text_domain
- Theme elements not translating
- Translate Navigation Menu & Sidebar Widget Titles
- Localization works but still get “This plugin is not properly prepared for localization” msg in directory
- Translate content, not instance, per-post
- Localization / textdomain is slow and chaotic
- Why should I escape translatable strings? and how shall i do that?
- How to load theme textdomain from plugin?
- How to handle single quote in a translatable string in WordPress
- Make theme translatable for WPML
- get_the_date() for translating date format
- Translation of plugin in MU-PLUGINS directory not working
- How can I make “Leave a comment” translation ready?
- Custom translation of Month names
- How to override languages files in wp-content/languages/themes with child theme
- Should i use _n for pronouns in translation?
- I can’t translate text in my plugin using a .mo file, load_plugin_textdomain() function is always false
- How to add translation for a string
- How to translate a WordPress.org plugin?
- Where the WordPress Core Translation is “actually” taking place?
- New plugin translation does not work
- Do i have make the content() also translation ready in theme?
- POEdit with Custom mu-plugins code
- Transfer from English page to Arabic page
- Make changes to translation?
- Gutenberg not all editor text translated
- How does WordPress choose which translation file to use?
- How to translate theme name
- 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]
- Is this a correct usage of esc_html_e?
- WPML Translated Term
- Proper way to create / manage gettext (.po, .pot) files?
- Where is the right .mo file inside the language repository?
- setlocale for date
- where to set the PO file for a plugin?
- How to translate functions like get_the_date()?
- Internationalization: Not loading plugin translated text
- translating wordpress with poedit
- Replacing strings within posts with the translatable string
- Change / tweak existing wordpress translations
- Should I include colon in my msgid in PO file?
- How to display get_post_type() translated?
- Plugin translations not installed but… strings are translated!
- WPML custom string translation get outside of container
- Replace text string on individual page
- Change template copy with po/mo files
- loco translate plugin edits file in plugin folder
- .mo translation strings not loading in PHP scripts that handle AJAX calls
- Implementing conditional gettext translation
- How to add LTR to a custom theme which in RTL by default
- How to syntax Json output for translation?
- Translating a word with locotranslate, but wordpress does display another by default
- Translating publish dates to Arabic
- _e() function get text_string from function
- Two text domains in one plugin
- Updating WordPress Theme/Plugin POT file without losing line numbers consistency