master

laravel/framework

Last updated at: 29/12/2023 09:21

Loader.php

TLDR

The Loader.php file contains the interface for a translation loader. It defines methods for loading messages for a given locale, adding namespaces to the loader, adding JSON paths to the loader, and getting all registered namespaces.

Methods

load($locale, $group, $namespace = null)

Loads the messages for the given locale, group, and namespace. Returns an array of messages.

addNamespace($namespace, $hint)

Adds a new namespace to the loader. The namespace and hint parameters specify how to map the namespace to a path.

addJsonPath($path)

Adds a new JSON path to the loader. The path parameter specifies the path where JSON translation files are located.

namespaces()

Returns an array of all the registered namespaces.

<?php

namespace Illuminate\Contracts\Translation;

interface Loader
{
    /**
     * Load the messages for the given locale.
     *
     * @param  string  $locale
     * @param  string  $group
     * @param  string|null  $namespace
     * @return array
     */
    public function load($locale, $group, $namespace = null);

    /**
     * Add a new namespace to the loader.
     *
     * @param  string  $namespace
     * @param  string  $hint
     * @return void
     */
    public function addNamespace($namespace, $hint);

    /**
     * Add a new JSON path to the loader.
     *
     * @param  string  $path
     * @return void
     */
    public function addJsonPath($path);

    /**
     * Get an array of all the registered namespaces.
     *
     * @return array
     */
    public function namespaces();
}