October\Rain\Translation\Translator

Source: ~/vendor/october/rain/src/Translation/Translator.php

Implements:

  • Illuminate\Contracts\Translation\Translator

October translator class.

Protected properties

protected October\Rain\Translation\LoaderInterface $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 array $keyParserCache

A cache of the parsed items.

Public methods

public void __construct(October\Rain\Translation\LoaderInterface $loader, string $locale)

Create a new translator instance.

Parameters

public void addNamespace(string $namespace, string $hint)

Add a new namespace to the loader.

Parameters
  • string $namespace
  • string $hint

public string choice(string $key, int $number, array $replace=array(), string $locale=NULL)

Get a translation according to an integer value.

Parameters
  • string $key
  • int $number
  • array $replace
  • string $locale

public string get(string $key, array $replace=array(), string $locale=NULL)

Get the translation for the given key.

Parameters
  • string $key
  • array $replace
  • string $locale

public string getFallback()

Get the fallback locale being used.

public October\Rain\Translation\LoaderInterface getLoader()

Get the language line loader implementation.

public string getLocale()

Get the default locale being used.

public Symfony\Component\Translation\MessageSelector getSelector()

Get the message selector instance.

public bool has(string $key, string $locale=NULL)

Determine if a translation exists.

Parameters
  • string $key
  • string $locale

public void load(string $namespace, string $group, string $locale)

Load the specified language group.

Parameters
  • string $namespace
  • string $group
  • string $locale

public string locale()

Get the default locale being used.

public array parseKey(string $key)

Parse a key into namespace, group, and item.

Parameters
  • string $key

public void setFallback(string $fallback)

Set the fallback locale being used.

Parameters
  • string $fallback

public void setLocale(string $locale)

Set the default locale.

Parameters
  • string $locale

public void setParsedKey(string $key, array $parsed)

Set the parsed value of a key.

Parameters
  • string $key
  • array $parsed

public void setSelector(Symfony\Component\Translation\MessageSelector $selector)

Set the message selector instance.

Parameters
  • Symfony\Component\Translation\MessageSelector $selector

public string trans(string $id, array $parameters=array(), string $domain='messages', string $locale=NULL)

Get the translation for a given key.

Parameters
  • string $id
  • array $parameters
  • string $domain
  • string $locale

public string transChoice(string $id, int $number, array $parameters=array(), string $domain='messages', string $locale=NULL)

Get a translation according to an integer value.

Parameters
  • string $id
  • int $number
  • array $parameters
  • string $domain
  • string $locale

Protected methods

protected string|null getLine(string $namespace, string $group, string $locale, string $item, array $replace)

Retrieve a language line out the loaded array.

Parameters
  • string $namespace
  • string $group
  • string $locale
  • string $item
  • array $replace

protected string getValidationSpecific(string $key, array $replace, string $locale)

Check the system namespace by default for "validation" keys.

Parameters
  • string $key
  • array $replace
  • string $locale

protected bool isLoaded(string $namespace, string $group, string $locale)

Determine if the given group has been loaded.

Parameters
  • string $namespace
  • string $group
  • string $locale

protected array keyParserParseBasicSegments(array $segments)

Parse an array of basic segments.

Parameters
  • array $segments

protected array keyParserParseSegments(string $key)

Parse an array of namespaced segments.

Parameters
  • string $key

protected string makeReplacements(string $line, array $replace)

Make the place-holder replacements on a line.

Parameters
  • string $line
  • array $replace

protected array parseLocale(string|null $locale)

Get the array of locales to be checked.

Parameters
  • string|null $locale

protected array sortReplacements(array $replace)

Sort the replacements array.

Parameters
  • array $replace