laravel

Determining if a Translation Exists

Determining if a Translation Exists

Problem

You want to determine if a translation exists for a particular key.

Solution

Use the Lang::has() method.

To check if a translation exists for the current locale pass a single argument to the method. The argument is the key you're checking.

if (Lang::has('message.welcome'))

echo "The welcome message translation exists for the current locale";

Discussion

You can specify the locale to check with the second argument.

if (Lang::has('message.welcome', 'es'))

echo "The welcome message translation exists for Spanish";

If the second argument isn't used then the current locale is used.

Mus Så här ändrar du muspekare och markörstorlek, färg och schema på Windows 10
Så här ändrar du muspekare och markörstorlek, färg och schema på Windows 10
Muspekaren och markören i Windows 10 är mycket viktiga aspekter av operativsystemet. Detta kan också sägas för andra operativsystem, så i sanning är d...
Gratis och öppen källkodsmotorer för utveckling av Linux-spel
Den här artikeln kommer att täcka en lista över gratis motorer med öppen källkod som kan användas för att utveckla 2D- och 3D-spel på Linux. Det finns...
Shadow of the Tomb Raider for Linux Tutorial
Shadow of the Tomb Raider är det tolfte tillskottet till Tomb Raider-serien - en action-äventyrsspelfranchise skapad av Eidos Montreal. Spelet mottogs...