CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 4.2 Strawberry API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 4.2
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • Http
    • I18n
      • Exception
      • Formatter
      • Middleware
      • Parser
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

Class Translator

Translator to translate the message.

Namespace: Cake\I18n

Constants

  • string
    PLURAL_PREFIX ¶
    'p:'

Property Summary

  • $fallback protected
    Cake\I18n\Translator|null

    A fallback translator.

  • $formatter protected
    Cake\I18n\FormatterInterface

    The formatter to use when translating messages.

  • $locale protected
    string

    The locale being used for translations.

  • $package protected
    Cake\I18n\Package

    The Package containing keys and translations.

Method Summary

  • __construct() public

    Constructor

  • getMessage() protected

    Gets the message translation by its key.

  • getPackage() public

    Returns the translator package

  • resolveContext() protected

    Resolve a message's context structure.

  • translate() public

    Translates the message formatting any placeholders

Method Detail

__construct() ¶ public

__construct(string $locale, Cake\I18n\Package $package, Cake\I18n\FormatterInterface $formatter, Cake\I18n\Translator $fallback = null)

Constructor

Parameters
string $locale

The locale being used.

Cake\I18n\Package $package

The Package containing keys and translations.

Cake\I18n\FormatterInterface $formatter

A message formatter.

Cake\I18n\Translator $fallback optional

A fallback translator.

getMessage() ¶ protected

getMessage(string $key): mixed

Gets the message translation by its key.

Parameters
string $key

The message key.

Returns
mixed

getPackage() ¶ public

getPackage(): Cake\I18n\Package

Returns the translator package

Returns
Cake\I18n\Package

resolveContext() ¶ protected

resolveContext(string $key, array $message, array $vars): string|array

Resolve a message's context structure.

Parameters
string $key

The message key being handled.

array $message

The message content.

array $vars

The variables containing the _context key.

Returns
string|array

translate() ¶ public

translate(string $key, array $tokensValues = []): string

Translates the message formatting any placeholders

Parameters
string $key

The message key.

array $tokensValues optional

Token values to interpolate into the message.

Returns
string

Property Detail

$fallback ¶ protected

A fallback translator.

Type
Cake\I18n\Translator|null

$formatter ¶ protected

The formatter to use when translating messages.

Type
Cake\I18n\FormatterInterface

$locale ¶ protected

The locale being used for translations.

Type
string

$package ¶ protected

The Package containing keys and translations.

Type
Cake\I18n\Package
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs