Title: Language detection
Last modified: March 29, 2024

---

# Language detection

 *  Resolved [Nikodemsky](https://wordpress.org/support/users/nikodemsky/)
 * (@nikodemsky)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/language-detection-5/)
 * So the:
   **LANGUAGE AUTO-DETECTION STRATEGY: Document**doesn’t work properly, 
   no matter what language is used in <html lang=””> it shows content always in 
   english.Maybe the issue is that it looks for simplfied codes like:**de**instead
   of iso codes:**de-DE**?Tried it both with WPML and Polylang – it’s broken on 
   both of those.

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [pressidium](https://wordpress.org/support/users/pressidium/)
 * (@pressidium)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/language-detection-5/#post-17538522)
 * Hey, [@nikodemsky](https://wordpress.org/support/users/nikodemsky/)!
 * > Maybe the issue is that it looks for simplfied codes like:
   > **de**instead of
   > iso codes:**de-DE**?
 * Within the plugin’s UI, you’ll find different language options. Opting for **
   German** will attempt to detect `de`, while **German (Germany)** will try to 
   detect `de-DE`, **German (Austria)** will result in `de-AT`, and so forth.
 * Double-check that the languages you’ve selected are consistent with the settings
   of your translation plugin, such as WPML, Polylang, or similar plugins.
 * If this doesn’t resolve your issue, please let us know and provide a link to 
   a website where the problem can be reproduced, if it’s possible.
 *  Thread Starter [Nikodemsky](https://wordpress.org/support/users/nikodemsky/)
 * (@nikodemsky)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/language-detection-5/#post-17538531)
 * Ok so that explains a lot, it’s kind of confusing tho imo – any chance that you
   can add iso codes like [de] or [de-DE] before language name in dropdown?
 *  Plugin Author [pressidium](https://wordpress.org/support/users/pressidium/)
 * (@pressidium)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/language-detection-5/#post-17538612)
 * Thanks for following up! It’s good to know that everything is working as expected.
 * > it’s kind of confusing tho imo – any chance that you can add iso codes like[
   > de] or [de-DE] before language name in dropdown?
 * Yeah, we’ll definitely look into making things clearer to prevent confusion in
   the future.
 * I’m going to mark this as resolved. If you come across any other issues, feel
   free to [create a new topic](https://wordpress.org/support/plugin/pressidium-cookie-consent/)
   or [open an issue on GitHub](https://github.com/pressidium/pressidium-cookie-consent/issues).
 *  [smartjb](https://wordpress.org/support/users/smartjb/)
 * (@smartjb)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/language-detection-5/#post-17562516)
 * Hi,
   I came across the same issue. But there is no Polish (Polish) to choose from
   the list so it always looks for “pl” instead of pl_PL (Polylang)
 *  Plugin Author [pressidium](https://wordpress.org/support/users/pressidium/)
 * (@pressidium)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/language-detection-5/#post-17563064)
 * Hey, [@smartjb](https://wordpress.org/support/users/smartjb/)!
 * This is already on our radar. We’re tracking its progress in [#61](https://github.com/pressidium/pressidium-cookie-consent/issues/61)
   on the plugin’s GitHub repository.
 * We’ll refine the options available within the language select field in a future
   iteration of the plugin.
 * Thanks for your understanding and patience.
 *  [dodaxas](https://wordpress.org/support/users/dodaxas/)
 * (@dodaxas)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/language-detection-5/#post-17736868)
 * Just use FILTER to modify LANG attribute OUTPUT
 *     ```wp-block-code
       function modify_language_attributes_defaults($output, $doctype) {
   
           // Check if WPML is active
           if (function_exists('icl_object_id')) {
   
               // Get the current language code
   
                $current_language = apply_filters('wpml_current_language', NULL);
   
               switch ($current_language) {
   
                   case 'en':
   
                       $output = str_replace('en-US', 'en', $output);
   
                       break;
   
                   case 'lt':
   
                       $output = str_replace('lt-LT', 'lt', $output);
   
                       break;
   
                   case 'ru':
   
                       $output = str_replace('ru-RU', 'ru', $output);
   
                        break;
   
                }
   
           }
   
           return $output;
       }
   
       // add the filter
       add_filter( "language_attributes", "modify_language_attributes_defaults", 10, 2 );
       ```
   

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Language detection’ is closed to new replies.

 * ![](https://ps.w.org/pressidium-cookie-consent/assets/icon-256x256.png?rev=2928033)
 * [Pressidium Cookie Consent](https://wordpress.org/plugins/pressidium-cookie-consent/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/pressidium-cookie-consent/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/pressidium-cookie-consent/)
 * [Active Topics](https://wordpress.org/support/plugin/pressidium-cookie-consent/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pressidium-cookie-consent/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pressidium-cookie-consent/reviews/)

 * 6 replies
 * 4 participants
 * Last reply from: [dodaxas](https://wordpress.org/support/users/dodaxas/)
 * Last activity: [2 years, 3 months ago](https://wordpress.org/support/topic/language-detection-5/#post-17736868)
 * Status: resolved