get_translations_for_domain example

foreach ( $domains as $domain ) {
            // The default text domain is handled by `load_default_textdomain()`.             if ( 'default' === $domain ) {
                continue;
            }

            /* * Unload current text domain but allow them to be reloaded * after switching back or to another locale. */
            unload_textdomain( $domain, true );
            get_translations_for_domain( $domain );
        }
    }

    /** * Changes the site's locale to the given one. * * Loads the translations, changes the global `$wp_locale` object and updates * all post type labels. * * @since 4.7.0 * * @global WP_Locale $wp_locale WordPress date and time locale object. * * @param string $locale The locale to change to. */

function translate( $text$domain = 'default' ) {
    $translations = get_translations_for_domain( $domain );
    $translation  = $translations->translate( $text );

    /** * Filters text with its translation. * * @since 2.0.11 * * @param string $translation Translated text. * @param string $text Text to translate. * @param string $domain Text domain. Unique identifier for retrieving translated strings. */
    
Home | Imprint | This part of the site doesn't use cookies.