class Translator extends NamespacedItemResolver implements Translator (View source)
| Macroable | |
| ReflectsClosures |
| protected array | $parsed | A cache of the parsed items. | from NamespacedItemResolver |
| static protected array | $macros | The registered string macros. | from Macroable |
| protected Loader | $loader | The loader implementation. | |
| protected string | $locale | The default locale being used by the translator. | |
| protected string | $fallback | The fallback locale used by the translator. | |
| protected array | $loaded | The array of loaded translation groups. | |
| protected MessageSelector | $selector | The message selector. | |
| protected callable | $determineLocalesUsing | The callable that should be invoked to determine applicable locales. | |
| protected array | $stringableHandlers | The custom rendering callbacks for stringable objects. | |
| protected callable|null | $missingTranslationKeyCallback | The callback that is responsible for handling missing translation keys. | |
| protected bool | $handleMissingTranslationKeys | Indicates whether missing translation keys should be handled. |
| array | parseKey(string $key)
Parse a key into namespace, group, and item. | |
| array | parseBasicSegments(array $segments)
Parse an array of basic segments. | from NamespacedItemResolver |
| array | parseNamespacedSegments(string $key)
Parse an array of namespaced segments. | from NamespacedItemResolver |
| void | setParsedKey(string $key, array $parsed)
Set the parsed value of a key. | from NamespacedItemResolver |
| void | flushParsedKeys()
Flush the cache of parsed keys. | from NamespacedItemResolver |
| static void | macro(string $name, object|callable $macro)
Register a custom macro. | from Macroable |
| static void | mixin(object $mixin, bool $replace = true)
Mix another object into the class. | from Macroable |
| static bool | hasMacro(string $name)
Checks if macro is registered. | from Macroable |
| static void | flushMacros()
Flush the existing macros. | from Macroable |
| static mixed | __callStatic(string $method, array $parameters)
Dynamically handle calls to the class. | from Macroable |
| mixed | __call(string $method, array $parameters)
Dynamically handle calls to the class. | from Macroable |
| string | firstClosureParameterType(Closure $closure)
Get the class name of the first parameter of the given Closure. | from ReflectsClosures |
| array | firstClosureParameterTypes(Closure $closure)
Get the class names of the first parameter of the given Closure, including union types. | from ReflectsClosures |
| array | closureParameterTypes(Closure $closure)
Get the class names / types of the parameters of the given Closure. | from ReflectsClosures |
| void | __construct(Loader $loader, string $locale)
Create a new translator instance. | |
| bool | hasForLocale(string $key, string|null $locale = null)
Determine if a translation exists for a given locale. | |
| bool | has(string $key, string|null $locale = null, bool $fallback = true)
Determine if a translation exists. | |
| mixed | get(string $key, array $replace = [], string|null $locale = null, bool $fallback = true)
Get the translation for the given key. | |
| string | choice(string $key, Countable|int|float|array $number, array $replace = [], string|null $locale = null)
Get a translation according to an integer value. | |
| string | localeForChoice(string|null $locale)
Get the proper locale for a choice operation. | |
| string|array|null | getLine(string $namespace, string $group, string $locale, string $item, array $replace)
Retrieve a language line out the loaded array. | |
| string | makeReplacements(string $line, array $replace)
Make the place-holder replacements on a line. | |
| void | addLines(array $lines, string $locale, string $namespace = '*')
Add translation lines to the given locale. | |
| void | load(string $namespace, string $group, string $locale)
Load the specified language group. | |
| bool | isLoaded(string $namespace, string $group, string $locale)
Determine if the given group has been loaded. | |
| string | handleMissingTranslationKey(string $key, array $replace, string|null $locale, bool $fallback)
Handle a missing translation key. | |
| Translator | handleMissingKeysUsing(callable|null $callback)
Register a callback that is responsible for handling missing translation keys. | |
| void | addNamespace(string $namespace, string $hint)
Add a new namespace to the loader. | |
| void | addJsonPath(string $path)
Add a new JSON path to the loader. | |
| array | localeArray(string|null $locale)
Get the array of locales to be checked. | |
| void | determineLocalesUsing(callable $callback)
Specify a callback that should be invoked to determined the applicable locale array. | |
| MessageSelector | getSelector()
Get the message selector instance. | |
| void | setSelector(MessageSelector $selector)
Set the message selector instance. | |
| Loader | getLoader()
Get the language line loader implementation. | |
| string | locale()
Get the default locale being used. | |
| string | getLocale()
Get the default locale being used. | |
| void | setLocale(string $locale)
Set the default locale. | |
| string | getFallback()
Get the fallback locale being used. | |
| void | setFallback(string $fallback)
Set the fallback locale being used. | |
| void | setLoaded(array $loaded)
Set the loaded translation groups. | |
| void | stringable(callable|string $class, callable|null $handler = null)
Add a handler to be executed in order to format a given class to a string during translation replacements. |
Parse a key into namespace, group, and item.
Parse an array of basic segments.
Parse an array of namespaced segments.
Set the parsed value of a key.
Flush the cache of parsed keys.
Register a custom macro.
Mix another object into the class.
Checks if macro is registered.
Flush the existing macros.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Get the class name of the first parameter of the given Closure.
Get the class names of the first parameter of the given Closure, including union types.
Get the class names / types of the parameters of the given Closure.
Create a new translator instance.
Determine if a translation exists for a given locale.
Determine if a translation exists.
Get the translation for the given key.
Get a translation according to an integer value.
Get the proper locale for a choice operation.
Retrieve a language line out the loaded array.
Make the place-holder replacements on a line.
Add translation lines to the given locale.
Load the specified language group.
Determine if the given group has been loaded.
Handle a missing translation key.
Register a callback that is responsible for handling missing translation keys.
Add a new namespace to the loader.
Add a new JSON path to the loader.
Get the array of locales to be checked.
Specify a callback that should be invoked to determined the applicable locale array.
Get the message selector instance.
Set the message selector instance.
Get the language line loader implementation.
Get the default locale being used.
Get the default locale being used.
Set the default locale.
Get the fallback locale being used.
Set the fallback locale being used.
Set the loaded translation groups.
Add a handler to be executed in order to format a given class to a string during translation replacements.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/11.x/Illuminate/Translation/Translator.html