Translate Refer a Friend

Refer a Friend has two kinds of text, and they’re translated in different places:

  • Built-in texts, such as button labels and messages, come with the plugin. They use the text domain gens-raf.
  • Your texts are the ones you typed in the settings, such as the share text, rewards box and emails.

The plugin comes translated into German, Spanish, French, Italian and Japanese. Those are used automatically when your site language matches.

Single-language stores

To change or add a translation of the built-in texts, use Loco Translate:

  1. Install Loco Translate.
  2. Go to Loco Translate → Plugins → Refer a Friend.
  3. Add your language, or edit an existing one, and save it in the Custom location so plugin updates don’t overwrite it.

Your texts don’t need translating. Type them in your language in the settings and the WooCommerce email settings.

WPML

  1. Go to WPML → String Translation.
  2. Choose the gens-raf domain and translate the built-in texts.
  3. Choose the wpgens-raf-emails domain to translate the subjects, headings and content of the four Refer a Friend emails. They’re added when you save the email settings in WooCommerce → Settings → Emails.
  4. For texts from the plugin settings, click Translate texts in admin screens at the bottom of String Translation. Find the gens_raf_… options you need, such as gens_raf_share_text and gens_raf_myaccount_text, and add them to String Translation.

Emails are sent in the language of the order they relate to. Share emails use the language the advocate was browsing in. Developers can change this with the wpgens_raf_email_language filter.

Polylang

Polylang doesn’t read the plugin’s settings texts on its own. This snippet adds them to Languages → Translations and shows the right translation on each language. Read Add code snippets safely first. Checked with version 4.4.12.

add_action( 'init', function () {
    if ( ! function_exists( 'pll_register_string' ) ) {
        return;
    }

    $options = array(
        'gens_raf_share_text'            => 'Share text',
        'gens_raf_myaccount_text'        => 'My Account text',
        'gens_raf_guest_text'            => 'Guest text',
        'gens_raf_you_receive'           => 'You receive',
        'gens_raf_you_receive_reward'    => 'You receive reward',
        'gens_raf_friend_receive'        => 'Friend receives',
        'gens_raf_friend_receive_reward' => 'Friend receives reward',
        'gens_raf_guest_coupon_msg'      => 'Cart message',
        'gens_raf_hide_no_orders_text'   => 'No orders text',
    );

    foreach ( $options as $option => $name ) {
        if ( is_admin() && ! wp_doing_ajax() ) {
            $value = get_option( $option );
            if ( is_string( $value ) && '' !== $value ) {
                pll_register_string( $name, $value, 'Refer a Friend', true );
            }
        } else {
            add_filter( 'option_' . $option, function ( $value ) {
                return ( is_string( $value ) && '' !== $value ) ? pll__( $value ) : $value;
            } );
        }
    }
} );

Then go to Languages → Translations, choose the Refer a Friend group, and translate each text. If you change a text in the plugin settings later, translate it again.

You don’t need to edit template files for this.

For built-in texts on Polylang sites, use Loco Translate as described above.

Currency switchers

Fixed-amount reward coupons are created in your store’s main currency. Whether they’re converted at checkout depends on your currency switcher. Test a fixed coupon in each currency, or use percentage rewards, which work the same in every currency.

Related

Browse our plugins

Lightweight WooCommerce plugins built for speed. No bloat, no frameworks -- just clean code that works.

View all plugins
Stay in the loop

Get notified when we launch new plugins. No spam, just product updates.