Back to Community

How to Add Custom Languages to Antispam Bee's Comment Filter

16 threads Sep 9, 2025 PluginAntispam bee

Content

One of Antispam Bee's most powerful features is its ability to block comment spam by restricting submissions to specific languages. This is incredibly effective for blogs and websites that operate primarily in one or two languages. However, a common point of confusion arises when users discover that their desired language, such as Chinese, Hebrew, or Brazilian Portuguese, is not available in the default dropdown list within the plugin's settings.

This article will explain why this happens and provide the definitive solution for adding any language you need.

Why Isn't My Language Listed?

The Antispam Bee plugin does not include every possible language by default. The initial list is limited to a few common European languages. The underlying technology for language detection relies on a service that supports a vast number of tongues, but the plugin's interface only shows a select few. The good news is that the plugin's developers have built a way to extend this list using a simple code filter.

Solution: Using a Code Snippet to Add Languages

The most effective and supported method for adding new languages is to use the ab_get_allowed_translate_languages filter hook. This involves adding a small piece of code to your website.

Warning: Always avoid editing the plugin's core files directly. Modifying them will break your site when the plugin next updates, and your changes will be lost.

Here is how to do it safely:

  1. Identify the Correct Language Code: First, you need to find the correct ISO 639-1 code for your language (e.g., 'pt' for Portuguese, 'id' for Indonesian). You can find a full list of supported languages on Google Cloud's documentation page.
  2. Add the Code Snippet: Place the following code example into your theme's functions.php file, a custom functionality plugin, or a code snippets plugin. Replace 'id' and 'Indonesian' with your language's code and English name.
add_filter( 'ab_get_allowed_translate_languages', function( $languages ) {
    $languages['id'] = 'Indonesian';
    return $languages;
});

For example, to add both Hebrew and Brazilian Portuguese, your code would look like this:

add_filter( 'ab_get_allowed_translate_languages', function( $languages ) {
    $languages['he'] = 'Hebrew';
    $languages['pt'] = 'Portuguese';
    return $languages;
});
  1. Save and Test: After adding the code, save the file and clear any caching on your site. Then, visit the Antispam Bee settings page in your WordPress dashboard. Your new language(s) should now appear in the "Allow comments only in certain language" dropdown menu. Select it and save your settings.

Troubleshooting Common Issues

  • Site Breaks After Adding Code: A syntax error in the code (like a missing semicolon or bracket) will cause a white screen or error. Double-check your code for accuracy. Using a code snippets plugin can often prevent these errors.
  • Language Still Doesn't Appear: Ensure you are using the correct two-letter language code. Also, make sure you are adding the code to the correct file and that your changes have been saved.
  • Comments in Correct Language Are Blocked: The language detection service is highly accurate but not infallible. Very short comments or those with mixed languages might be misidentified.

Important Considerations

It is important to understand that this feature works by sending the comment text to a third-party translation service API for analysis. The Antispam Bee team has documented this and other privacy-related considerations on their official documentation. If you have strict data processing requirements, you may want to review this information.

By using this filter, you can tailor Antispam Bee's language filtering to your site's specific needs, creating a robust defense against international spam comments.

Related Support Threads Support