Feature: Localization Restructuring to follow a stricter pattern
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\Localization\Services;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Spatie\TranslationLoader\LanguageLine;
|
||||
|
||||
class TranslationReader
|
||||
{
|
||||
private const DEFAULT_GROUP = 'storefront';
|
||||
|
||||
/**
|
||||
* All labels in a group for the given (or current) locale, keyed by their
|
||||
* dot-notation key — e.g. ['nav.cart' => 'Cart', 'nav.home' => 'Home'].
|
||||
* Backed by LanguageLine's own forever-cache, so this is a cache hit after
|
||||
* the first call for a given group+locale.
|
||||
*/
|
||||
public function group(string $group = self::DEFAULT_GROUP, ?string $locale = null): array
|
||||
{
|
||||
return LanguageLine::getTranslationsForGroup($locale ?? App::getLocale(), $group);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user