SyliusCon 2025
Early Bird Deal
LogoLogo
🛣️ Roadmap💻 Sylius Demo💬 Community Slack
  • Sylius Documentation
  • Sylius Plugins
  • Sylius Stack
  • 📖Sylius 2.0 Documentation
    • Organization
      • Release Cycle
      • Backwards Compatibility Promise
      • Sylius Team
      • Sylius Roadmap
  • Getting Started with Sylius
    • Installation
    • Basic Configuration
    • Shipping & Payment
    • First Product
    • Customizing the Shop
    • Customizing Business Logic
    • Using API
    • Installing Plugins
    • Deployment
    • Summary
  • The Book
    • Introduction to Sylius
    • Installation
      • System Requirements
      • Sylius CE Installation
        • Sylius CE Installation with Docker
      • ➕Sylius Plus Installation
      • Upgrading Sylius CE
      • Upgrading Sylius Plus
    • Architecture
      • Architecture Overview
      • Architectural Drivers
      • Resource Layer
      • State Machine
      • Translations
      • E-Mails
      • Contact
      • Fixtures
      • Events
    • Configuration
      • Channels
      • Locales
      • Currencies
    • Customers
      • Customer & ShopUser
      • ➕Customer Pools
      • AdminUser
      • Addresses
        • Countries
        • Zones
        • Addresses
        • Address Book
    • Products
      • Products
      • Product Reviews
      • Product Associations
      • Attributes
      • Pricing
      • Catalog Promotions
      • Taxons
      • Inventory
      • ➕Multi-Source Inventory
      • Search
    • Carts & Orders
      • Orders
      • Cart flow
      • Taxation
      • Adjustments
      • Cart Promotions
      • Coupons
      • Payments
      • 🧩Invoices
      • Shipments
    • Support
    • Contributing
      • Contributing Code
        • Submitting a Patch
        • ⚠️Security Issues
        • Coding Standards
        • Conventions
        • Sylius License and Trademark
      • Contributing Translations
      • Key Contributors
  • The Customization Guide
    • Customizing Models
      • How to add a custom model?
      • How to add a custom translatable model?
    • Customizing Forms
      • How to add a live form for a custom model?
    • Customizing Styles
    • Customizing Validation
    • Customizing Menus
    • Customizing Templates
    • Customizing Translations
    • Customizing Flashes
    • Customizing State Machines
    • Customizing Grids
    • Customizing Fixtures
    • Customizing API
    • Customizing Serialization of API
    • Customizing Payments
      • How to integrate a Payment Gateway as a Plugin?
  • 🧑‍🍳The Cookbook
  • How to resize images?
  • How to add one image to an entity?
  • How to add multiple images to an entity?
  • Sylius 1.X Documentation
    • 📓Sylius 1.x Documentation
Powered by GitBook
LogoLogo

Developer

  • Community
  • Online Course

About

  • Team

© 2025 Sylius. All Rights Reserved

On this page
  • Base Locale
  • Locale Context
  • Available Locales Provider

Was this helpful?

Edit on GitHub
  1. The Book
  2. Configuration

Locales

To add a new locale to your store you have to assign it to a channel.

To support multiple languages we are using Locales in Sylius. Locales are language codes standardized by ISO 15897.

In the dev environment, you can easily check the locale you are currently using in the Symfony debug toolbar.

Base Locale

During the installation, you provided a default base locale. This is the language in which everything in your system will be saved in the database - all the product names, texts on the website, e-mails, etc.

Locale Context

To manage the currently used language, we use the LocaleContext. You can always access it with the ID sylius.context.locale in the container.

public function fooAction()
{
    $locale = $this->get('sylius.context.locale')->getLocaleCode();
}

The locale context can be injected into any of your services and give you access to the currently used locale.

Available Locales Provider

The Locale Provider service (sylius.locale_provider) is responsible for returning all languages available for the current user. By default, returns all configured locales. You can easily modify this logic by overriding this service.

public function fooAction()
{
    $locales = $this->get('sylius.locale_provider')->getAvailableLocalesCodes();

    foreach ($locales as $locale) {
        echo $locale;
    }
}

To get all languages configured in the store, regardless of your availability logic, use the locales repository:

$locales = $this->get('sylius.repository.locale')->findAll();
PreviousChannelsNextCurrencies

Last updated 8 months ago

Was this helpful?