--- label: 'Configuring language detection and selection' related: - core.translations - language.add --- {% set detection_text %}{% trans %}Detection and selection{% endtrans %}{% endset %} {% set detection_link = render_var(help_route_link(detection_text, 'language.negotiation')) %}

{% trans %}Goal{% endtrans %}

{% trans %}Configure the methods used to decide which language will be used to display text on your site.{% endtrans %}

{% trans %}What is a language detection method?{% endtrans %}

{% trans %}A language detection method is a way for your site to decide what language should be used to display text. This decision is made by evaluating a series of detection methods for languages; the first detection method that gets a result will determine which language is used. If you have more than one language on your site, you can configure the detection methods that are used and the order they are evaluated, for both user interface text and content text. Configuration text always uses the interface text method, and most sites use the same detection methods for all types of text.{% endtrans %}

{% trans %}What language detection methods are available?{% endtrans %}

{% trans %}The available detection methods depend on what modules you have installed. Some of the most commonly-used language detection methods are:{% endtrans %}

{% trans %}URL{% endtrans %}
{% trans %}Use the language from the URL, which can either be in a path prefix like example.com/fr/page_path for French (fr) language, or in a domain like fr.example.com/page_path.{% endtrans %}
{% trans %}User{% endtrans %}
{% trans %}For logged in users, use the language they have set in their profiles.{% endtrans %}
{% trans %}Browser{% endtrans %}
{% trans %}Use the language preferences from the user's browser.{% endtrans %}
{% trans %}Selected language{% endtrans %}
{% trans %}Use the language most recently selected from a Language switcher block.{% endtrans %}
{% trans %}Session{% endtrans %}
{% trans %}Use the language from a session parameter or a request parameter; for example, adding ?language=fr to the end of the URL.{% endtrans %}

{% trans %}Steps{% endtrans %}

  1. {% trans %}In the Manage administrative menu, navigate to Configuration > Regional and language > Languages > {{ detection_link }}.{% endtrans %}
  2. {% trans %}Check the boxes to enable the desired language detection methods, and uncheck boxes for the methods you do not want to use.{% endtrans %}
  3. {% trans %}Drag the methods to change their order, if desired.{% endtrans %}
  4. {% trans %}Click Save settings.{% endtrans %}
  5. {% trans %}Click Configure on each enabled detection method and verify that its configuration is correct (or update the configuration if not).{% endtrans %}