mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Override default number locale in Tables and Infolists
This commit is contained in:
@@ -163,6 +163,7 @@ trait CanFormatState
|
||||
}
|
||||
|
||||
$currency = $component->evaluate($currency) ?? Infolist::$defaultCurrency;
|
||||
$locale = $component->evaluate($locale) ?? Infolist::$defaultNumberLocale ?? config('app.locale');
|
||||
|
||||
if ($divideBy) {
|
||||
$state /= $divideBy;
|
||||
@@ -203,7 +204,9 @@ trait CanFormatState
|
||||
);
|
||||
}
|
||||
|
||||
return Number::format($state, $decimalPlaces, $component->evaluate($maxDecimalPlaces), $component->evaluate($locale) ?? config('app.locale'));
|
||||
$locale = $component->evaluate($locale) ?? Infolist::$defaultNumberLocale ?? config('app.locale');
|
||||
|
||||
return Number::format($state, $decimalPlaces, $component->evaluate($maxDecimalPlaces), $locale);
|
||||
});
|
||||
|
||||
return $this;
|
||||
|
||||
@@ -14,6 +14,8 @@ class Infolist extends ComponentContainer
|
||||
|
||||
public static string $defaultTimeDisplayFormat = 'H:i:s';
|
||||
|
||||
public static ?string $defaultNumberLocale = null;
|
||||
|
||||
public function name(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
@@ -163,12 +163,13 @@ trait CanFormatState
|
||||
}
|
||||
|
||||
$currency = $column->evaluate($currency) ?? Table::$defaultCurrency;
|
||||
$locale = $column->evaluate($locale) ?? Table::$defaultNumberLocale ?? config('app.locale');
|
||||
|
||||
if ($divideBy) {
|
||||
$state /= $divideBy;
|
||||
}
|
||||
|
||||
return Number::currency($state, $currency, $column->evaluate($locale) ?? config('app.locale'));
|
||||
return Number::currency($state, $currency, $locale);
|
||||
});
|
||||
|
||||
return $this;
|
||||
@@ -203,7 +204,9 @@ trait CanFormatState
|
||||
);
|
||||
}
|
||||
|
||||
return Number::format($state, $decimalPlaces, $column->evaluate($maxDecimalPlaces), locale: $column->evaluate($locale) ?? config('app.locale'));
|
||||
$locale = $column->evaluate($locale) ?? Table::$defaultNumberLocale ?? config('app.locale');
|
||||
|
||||
return Number::format($state, $decimalPlaces, $column->evaluate($maxDecimalPlaces), locale: $locale);
|
||||
});
|
||||
|
||||
return $this;
|
||||
|
||||
@@ -64,6 +64,8 @@ class Table extends ViewComponent
|
||||
|
||||
public static string $defaultDateTimeDisplayFormat = 'M j, Y H:i:s';
|
||||
|
||||
public static ?string $defaultNumberLocale = null;
|
||||
|
||||
public static string $defaultTimeDisplayFormat = 'H:i:s';
|
||||
|
||||
final public function __construct(HasTable $livewire)
|
||||
|
||||
Reference in New Issue
Block a user