<commit_before>How to disable localised URLs?
==============================

URLs in Sylius are localised, this means they contain the ``/locale`` prefix with the current locale.
For example when the ``English (United States)`` locale is currently chosen in the channel, the URL of homepage will
look like that ``localhost:8000/en_US/``.

If you do not need localised URLs, this guide will help you to disable this feature.

**1.** Customise the application routing in the ``config/routes/sylius_shop.yaml``.

Replace:

.. code-block:: yaml

    # config/routes/sylius_shop.yaml
    
    sylius_shop:
        resource: "@SyliusShopBundle/Resources/config/routing.yml"
        prefix: /{_locale}
        requirements:
            _locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$

    sylius_shop_payum:
        resource: "@SyliusShopBundle/Resources/config/routing/payum.yml"

    sylius_shop_default_locale:
        path: /
        methods: [GET]
        defaults:
            _controller: sylius.controller.shop.locale_switch:switchAction

With:

.. code-block:: yaml

    # config/routes/sylius_shop.yaml    
    sylius_shop:
        resource: "@SyliusShopBundle/Resources/config/routing.yml"

    sylius_shop_payum:
        resource: "@SyliusShopBundle/Resources/config/routing/payum.yml"

**2.** Customise the security settings in the ``config/packages/security.yaml``.

Replace:

.. code-block:: yaml

    # config/packages/security.yaml

    parameters:
        # ...
        sylius.security.shop_regex: "^/(?!admin|api/.*|api$|media/.*)[^/]++"

With:

.. code-block:: yaml

    # config/packages/security.yaml

    parameters:
        # ...
        sylius.security.shop_regex: "^"

**3.** Customise SyliusShopBundle to use storage-based locale switching in the ``config/packages/_sylius.yaml``.

Replace :

.. code-block:: yaml

    # config/packages/_sylius.yaml

    sylius_shop:
        product_grid:
            include_all_descendants: true

With:

.. code-block:: yaml

    # config/packages/_sylius.yaml

    sylius_shop:
        product_grid:
            include_all_descendants: true
        locale_switcher: storage<commit_msg>refactor #12223 Remove security.yaml change when disabling localized URLs (maximehuran)<commit_after>How to disable localised URLs?
==============================

URLs in Sylius are localised, this means they contain the ``/locale`` prefix with the current locale.
For example when the ``English (United States)`` locale is currently chosen in the channel, the URL of homepage will
look like that ``localhost:8000/en_US/``.

If you do not need localised URLs, this guide will help you to disable this feature.

**1.** Customise the application routing in the ``config/routes/sylius_shop.yaml``.

Replace:

.. code-block:: yaml

    # config/routes/sylius_shop.yaml
    
    sylius_shop:
        resource: "@SyliusShopBundle/Resources/config/routing.yml"
        prefix: /{_locale}
        requirements:
            _locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$

    sylius_shop_payum:
        resource: "@SyliusShopBundle/Resources/config/routing/payum.yml"

    sylius_shop_default_locale:
        path: /
        methods: [GET]
        defaults:
            _controller: sylius.controller.shop.locale_switch:switchAction

With:

.. code-block:: yaml

    # config/routes/sylius_shop.yaml    
    sylius_shop:
        resource: "@SyliusShopBundle/Resources/config/routing.yml"

    sylius_shop_payum:
        resource: "@SyliusShopBundle/Resources/config/routing/payum.yml"

**2.** Customise SyliusShopBundle to use storage-based locale switching in the ``config/packages/_sylius.yaml``.

Replace :

.. code-block:: yaml

    # config/packages/_sylius.yaml

    sylius_shop:
        product_grid:
            include_all_descendants: true

With:

.. code-block:: yaml

    # config/packages/_sylius.yaml

    sylius_shop:
        product_grid:
            include_all_descendants: true
        locale_switcher: storage
{'fraction_non_alphanumeric': 0.13469184890656064, 'fraction_numerical': 0.009443339960238568, 'mean_word_length': 3.0697674418604652, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7651826', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1278, 'n_words': 287}