Main menu

Filter the source language sent to translation APIs

This provides an alternative way to change the source language that gets posted to translation APIs.

Setting the "src" key via loco_api_providers takes priority, but this filter has the advantage that the PO file being translated is also available.

This example changes the source language for only a specific text domain:

function filter_loco_api_provider_source( $tag, $path ){
    if( 'german-theme' === substr(basename($path),0,12) ){
        $tag = 'de';
    }
    return $tag;
}
add_filter('loco_api_provider_source','filter_loco_api_provider_source',999,2);

See also

Last updated by