"symfony : these messages are not available for the given locale and cannot be found in the fallback locales" Code Answer

4

a locale consists of 2 parts (language and country) combined with an underscore: eg. it_it or en_en

for example switzerland has 3 spoken languages:

  • de_ch
  • ch_ch
  • fr_ch

the filenames of your translation-files should be like:

  • messages.en_en.yml
  • messages.it_it.yml
  • ...

the translation-keys should be unique, dot-separated and equal in each single translation-file. first comes translation-key and after the colon comes the translated content.

# messages.it_it.yml
navigation.home: clicca per casa
navigation.help: clicca per aiuto

# messages.en_en.yml
navigation.home: click for home
navigation.help: click for help

now you can use the navigation-keys in your application and a good ide will help you by selecting them. when using different files for the different parts of your application, you have to address them in twig like:

{{ 'navigation.home'|trans({}, 'application') }}
{{ 'navigation.help'|trans({}, 'application') }}

<div class="error-message">
    the following error occured: {{ 'error.login'|trans({}, 'messages') }}
</div>
By Dicky Tsang on February 12 2022

Answers related to “symfony : these messages are not available for the given locale and cannot be found in the fallback locales”

Only authorized users can answer the Search term. Please sign in first, or register a free account.