Is Polylang GDPR compliant?

Is Polylang GDPR compliant?

Since the version 4.9.6, WordPress allows to export personal data. This includes the biographical info. As Polylang and Polylang Pro allow the users to translate their biographical info, the translations are added to the exported data since the version 2.3.6.
None of our plugins collect other personal data.

My menu doesn’t change with the language

My menu doesn’t change with the language

A frequent issue is a menu which is correct when directly accessing the page but doesn’t switch when clicking on the language switcher. More and more themes are loading the content in Ajax and thus don’t reload the menu and content common to every pages (ex footer, widgets). This Ajax feature is obviously not compatible with multilingual websites. Try disabling the Ajax feature in your theme options or contact the theme support if you don’t find such option.

I can’t add the language switcher in the menus

I can’t add the language switcher in the menus

In Appearance >Menus, go to screen options on top right of your screen and check the “Language switcher” checkbox. You then should have a new metabox which allows you to add a language switcher the same way you add other menu items.
Due to WordPress limitations, it is currently not possible to add the language switcher from the Customizer Menus.

Can I use my own flags for the language switcher?

Can I use my own flags for the language switcher?

Yes. You can use PNG, JPG or even SVG files and name them with the WordPress locale. For example, en_US.png.
Upload these files in the /wp-content/polylang/ directory.
Note: You have to create the directory yourself. Don’t use the /polylang/flags/ directory as your files would be removed when automatically updating the plugin. Alternatively, it’s possible to store the files in the /polylang/ subdirectory of the theme or the child theme.
Once the custom flags are uploaded, go to Languages > Settings. Click on the “URL modifications” settings and then on Save Changes.
Note: To specify the height and widh of SVG flags, you need to use the PHP filter pll_custom_flag.
Note: Your custom flags won’t be used on admin side. You can change them only with the PHP filter pll_flag.

Can I display a language switcher without the widget?

Can I display a language switcher without the widget?

It is possible to get a language switcher where you want in your theme without using the widget. For this, you can use  the following template tag in your theme:
1

    See the documentation for theme and plugin programmers for more information about the function parameters.

    The language switcher doesn’t appear on frontend

    The language switcher doesn’t appear on frontend

    To avoid 404 errors, Polylang does not display a language if there is no published content (post or page) in that language. If there is no content in any language, then the language switcher does not appear at all.

    How to

    How to

    How to know the current language in the theme ?
    WordPress provides at least two functions for the themes or plugins authors to know the current language:

    get_locale() returns the WordPress locale in the format ‘en_US’
    get_bloginfo(‘language’) returns the locale in the format ‘en-US’

    Note the difference between ‘_’ and ‘-‘ in the two functions. You can have a look at the following forum topics:

    Return the current language as variable for your template
    How to translate/switch specific contents on templates

    Additionaly, Polylang now provides the function ‘pll_current_language’ which can return either the language code, the locale or the language name.
    How to make translatable user defined strings in my plugin or theme ?
    You have to register strings on the admin side with the function ‘pll_register_string’ and display them on frontend with ‘pll__’ or ‘pll_e’.
    How to make my custom post types and taxonomies multilingual?
    You must register your custom post type (or taxonomy) in a function hooked to the ‘init’ action as usual.
    The user will have access to an option to enable languages and translations for the custom post type (or taxonomy) in the Polylang settings. You can however use the ‘pll_get_post_types’ or ‘pll_get_taxonomies’ filters to get full control on this.
    How to query content in a different language than the current one?
    Polylang does set the language of the theme based on the main query, but it is possible to query content in a different language. For example, you can display the list of the five most recent French posts on an English page. Your custom query just needs to add the ‘lang’ parameter.
    Example:
    12345$posts = get_posts( array(    ‘post_type’ => ‘post’,    ‘lang’ => ‘fr’, // use language slug in the query    ‘showposts’ => 5,) );
    This ‘lang’ parameter is not only available for posts but also for terms using the function ‘get_terms’ and comments using the function ‘get_comments’.
    How to query multiple languages?
    Example:
    12345$posts = get_posts( array(    ‘post_type’ => ‘post’,    ‘lang’ => ‘de,fr’, // query German and French posts    ‘showposts’ => 5,) );
    How to deactivate the current language filter?
    Example:
    12345$posts = get_posts( array(    ‘post_type’ => ‘post’,    ‘lang’ => ”, // deactivates the Polylang filter    ‘showposts’ => 5,) );
    How to display links to posts translations within the loop?
    Example:
    1234

      $post->ID ) ); ?>

    How to load the Polylang API for ajax requests on frontend ?
    Polylang should automatically detect AJAX requests on frontend and load the current language. You can optionally set the ‘lang’ variable (with the language code) in the request (POST or GET) to load a specific language instead of the current language. The variable ‘pll_load_front’ which was necessary in old versions is useless since v1.4.
    When Polylang does load the language?
    There are two cases:

    The language is set from the content: Polylang needs to defer the language loading and does it in a function hooked to the action ‘wp’ action with priority 5.
    The language code is added to all urls (default): there is no need to defer the language loading and it is done as if Polylang were not active.

    Due to the first case, plugin authors should not attempt to translate strings before the ‘wp’ action has been fired. Polylang provides a new action ‘pll_language_defined’ which is fired as soon as the language is defined. It works whatever the option chosen by the user to set the language.
    How to give access to strings translations to non-administrators?
    As the main purpose of the strings translations is to translate options, Polylang checks for the ‘manage_options’ capability, which is assigned to administrators by default, to control the access to the strings translations table. You can modify the required capability with the following snippet:
    12345add_action( ‘admin_menu’, function() {    if ( ! current_user_can( ‘manage_options’ ) && function_exists( ‘PLL’ ) ) {        add_menu_page( __( ‘Strings translations’, ‘polylang’ ), __( ‘Languages’, ‘polylang’ ), ‘edit_pages’, ‘mlang_strings’, array( PLL(), ‘languages_page’ ), ‘dashicons-translation’ );    }} );
    Here the capability was changed to ‘edit_pages’, which is assigned to administrators and editors by default. See the codex to discover which capability you can use to target other roles.