Skip to main content
The cart is empty

How to translate custom string

Falang use the WPML string translation system , you can use after that the Falang String translation system. 

1) Register the strings that need translation with WPML system

to do this call :

icl_register_string ( string $context, string $name, string $value );

The complete WPML documentation can be found here : Translation for texts by other plugins and themes

2) how to use it 

In your code just call

 falang__(String)

3) Exemple with woocommerce 

In this exemple when the stock is set to 0 , the sold text replace the price.

if (function_exists('icl_register_string')) {
    icl_register_string('mysite', 'Vendu', 'Vendu');
}

function myprefix_edit_woo_price( $price, $product ) {
    if ( ! $product->is_in_stock() ) {
        if (function_exists( 'falang__' )){
            $price = falang__('Vendu');
        } else {
            $price = __('SOLD', 'mysite');
        }
    }
    return strtoupper($price);
}

add_filter( 'woocommerce_variable_sale_price_html', 'myprefix_edit_woo_price', 10, 2);
add_filter( 'woocommerce_variable_price_html', 'myprefix_edit_woo_price', 10, 2);
add_filter( 'woocommerce_get_price_html', 'myprefix_edit_woo_price', 10, 2);