Laravel 5: Views – language: translations

Views: language translations

Laravel multi-language capacity is not revolutionary, but very comfortable to use.

Laravel multi-lingual translation files directory

If you group your files in subfolders, dot notation would not work. You have to use slashes, e.g.:

Languages directory structure

How to add another language

To add language, just duplicate one of existing folders, e.g. ‘en’ and translate it.
Then add language to config/app ‘languages’ => [‘en’, ‘pl’].
And do not forget to add langiage names to proper language file (languages.php) for all languages … and you are done.

Language files content

Accessing language file translation
standard PHP notation

Laravel blade syntax

Laravel @lang() directive

Access path explained

What goes inside of brackets is a dot.notation written path to translation inside of language folder.

e.g. if translation file messages  is in directory: resources/lang/en and we are trying to access element with key welcome, then dot.notation expressed path looks like this: messages.welcome.

Parameters in translations
simple params
Translation file



size letters


Simple pluralization is useless, since different languages have different ways of dealing with multiple quantities.

But complex approach offered via Symfony Translation component could be useful.


English language

Polish language

There are still problems for many languages.
Problems that make use of this … problematic.
Pity, ranges do no allow for wildcards,  so I could have this:

Above would allow:

  • single
  • plural fitting wildcard
  • rest of plural

Without above, it is better to write your own multiple translator.