Custom Post Type Localization

Both the Custom Post Type slug and the additional sub-URLs can be localized at runtime to the active locale. The configuration remains similar but for the extra i18n configuration keys.

Slugs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
namespace App\Model;

class MyCPT extends AppCustomPostType
{
    public $configuration = array(
        "rewrite"   => array(
            'slug'       => 'business/industry',
        ),
        'i18n' => array(
            'fr_CA' => array(
                "rewrite"   => array('slug' => 'affaires/industrie'),
            ),
            'es_ES' => array(
                "rewrite"   => array('slug' => 'negocios/industria'),
            ),
        ),
    );
}
?>

Additional urls

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
namespace App\Model;

class MyCPT extends AppCustomPostType
{
     public $routed = array(
        "rewrite" =>  array(
            'send_contact' => 'send',
        ),
        'i18n' => array(
            'fr_CA' => array(
                "rewrite" => array(
                    'send_contact' => 'envoyer',
                ),
            ),
            'es_ES' => array(
                "rewrite" => array(
                    'send_contact' => 'enviar',
                ),
            ),
        ),
    );
}
?>