Lang::choice PHP Method

choice() public static method

Get a translation according to an integer value.
public static choice ( string $key, integer | array | Countable $number, array $replace = [], string $locale = null ) : string
$key string
$number integer | array | Countable
$replace array
$locale string
return string
        public static function choice($key, $number, $replace = array(), $locale = null)
        {
            return \Illuminate\Translation\Translator::choice($key, $number, $replace, $locale);
        }

Usage Example

 public function format($isNow, $isFuture, $delta, $unit)
 {
     $unitStr = \Lang::choice("localized-carbon::units." . $unit, $delta, array(), 'uk');
     if ($isNow) {
         if ($isFuture) {
             if ($unit == "day" && $delta == 1) {
                 $txt = "завтра";
             } else {
                 if (($unit == "year" || $unit == "hour") && $delta == 1) {
                     $txt = "через " . " " . $unitStr;
                 } else {
                     $txt = "через " . $delta . " " . $unitStr;
                 }
             }
         } else {
             if ($unit == "second" && $delta < 10) {
                 $txt = 'щойно';
             } else {
                 if ($unit == "day" && $delta == 1) {
                     $txt = "вчора";
                 } else {
                     $txt = $delta . " " . $unitStr . " тому";
                 }
             }
         }
     } else {
         if ($isFuture) {
             $txt = $delta . " " . $unitStr . " потому";
         } else {
             $txt = "за " . " " . $delta . " " . $unitStr . " до";
         }
     }
     return $txt;
 }
All Usage Examples Of Lang::choice