• Hello,
    I’m reporting an issue with Loco Translate when using the official Belarusian WordPress locale “bel” (https://translate.wordpress.org/locale/bel/).

    When I try automatic translation (Microsoft Translator or OpenAI), Loco shows the error:

    “The target language is not valid.” or\and “FAILED”

    The request is never sent to the API.

    Reason:
    WordPress uses locale “bel”, but external providers expect ISO 639-1 code “be”. Loco validates the locale before sending, rejects “bel”, and blocks translation for Belarusian completely.

    Because of this, Belarusian users cannot use automatic translation at all.

    Could you please consider one of the following:
    – map “bel” → “be” when sending to providers
    – or provide a filter to override target language
    – or allow custom ISO code for custom languages

    Thank you.

Viewing 1 replies (of 1 total)
  • Plugin Author Tim W

    (@timwhitlock)

    Ok. I’ve added a mapping for “bel” -> “be” into the Microsoft and Google APIs. This is in the trunk, and will be included in the text release.

    A few things to note:

    Loco doesn’t block or reject unsupported locale codes. If a WordPress locale code cannot be mapped to an equivalent code supported by the API then it is simply sent as-is, and allows for the API to return its own error. This is observable for Microsoft Translator and Google Translate via the browser’s network inspector.

    Whenever Loco Translate parses a locale code it fires the loco_parse_locale action. You can modify a locale object as follows. But note that this applies everywhere, not just API translation.

    add_action( 'loco_parse_locale', function( Loco_Locale $locale, string $tag ){
    if( 'bel' === $tag ){
    $locale->lang = 'be';
    }
    }, 10, 2 );

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.