> For the complete documentation index, see [llms.txt](https://akyos.gitbook.io/book/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://akyos.gitbook.io/book/wordpress/plugins/polylang.md).

# Polylang

### Installation

{% hint style="danger" %}
Installez, activez polylang et paramétrez vos langues avant de créer des pages/posts/terms, vous aurez des erreurs sinon et vous devrez tout remettre à jour une fois la langue créée.
{% endhint %}

Lien vers polylang pro 🤫 : <https://drive.google.com/file/d/1MLAdXiBGJXl3TPFI7TKPgjjrH4ODmRla/view?usp=share_link>

<table><thead><tr><th width="171">Add-on</th><th width="353.3333333333333">Description</th><th>Url</th></tr></thead><tbody><tr><td>Polylang WC</td><td>Permet la traduction des produits</td><td><a href="https://drive.google.com/file/d/14-5ZmjuyvfQCKutZn_5rZAs9ewM4G2tG/view?usp=share_link">Lien vers Drive</a></td></tr><tr><td>Polylang theme options</td><td>Permet de gérer les themes options en plusieurs langues</td><td><a href="https://github.com/BeAPI/acf-options-for-polylang">Lien vers Github</a></td></tr></tbody></table>

### Ajouter des traductions

{% hint style="warning" %}
Pensez à chercher rigoureusement toutes les petites chaines de caractères car il faut tout traduire.&#x20;
{% endhint %}

* Soit dans le code via un fichier `translate.php` à intégrer dans `/app`

```php
add_action('init', function() {

    $translate_strings = [
        'Mon compte',
        'Rechercher',
        "Lire l'article",
        "Me déconnecter",
        "Dernières actualités",
    ];

    foreach ($translate_strings as $string) {
        pll_register_string('chefcut-theme', $string, 'chefcut');
    }

});
```

* Soit dans un fichier .PO à importer ensuite dans le back-office, dans l'onglet "String translations"

### Afficher les traductions

Pour afficher une string en fonction de la langue courante, simplement utiliser :&#x20;

```php
{{ pll__($string) }}
```

### Afficher le menu drapeau

```php
pll_the_languages(['show_flags' => 1, 'show_names' => 0]);
```

### Ajouter un drapeau personnalisé

[TUTO ICI](https://polylang.pro/doc/can-i-use-my-own-flags-for-the-language-switcher/)&#x20;
