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
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.5 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.5
      • 4.2
      • 4.1
      • 4.0
      • 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

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
      • Validator
    • Network
      • Email
      • Http
    • Routing
      • Filter
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • I18n
  • L10n
  • Multibyte

Class I18n

I18n handles translation of Text and time format strings.

Package: Cake\I18n
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Location: Cake/I18n/I18n.php

Constants summary

  • integer
    LC_ALL ¶
    0
  • integer
    LC_COLLATE ¶
    1
  • integer
    LC_CTYPE ¶
    2
  • integer
    LC_MESSAGES ¶
    6
  • integer
    LC_MONETARY ¶
    3
  • integer
    LC_NUMERIC ¶
    4
  • integer
    LC_TIME ¶
    5

Properties summary

  • $_categories protected
    array
    Translation categories
  • $_domains protected
    array
    Translation strings for a specific domain read from the .mo or .po files
  • $_escape protected
    string
    Escape string
  • $_lang protected
    string
    Current language used for translations
  • $_noLocale protected
    boolean

    Set to true when I18N::_bindTextDomain() is called for the first time. If a translation file is found it is set to false again

  • $category public
    string
    Current category of translation
  • $defaultDomain public static
    string
    Default domain of translation
  • $domain public
    string
    Current domain of translation
  • $l10n public
    L10n
    Instance of the L10n class for localization

Method Summary

  • __construct() public
    Constructor, use I18n::getInstance() to get the i18n translation object.
  • _bindTextDomain() protected
    Binds the given domain to a file in the specified directory.
  • _parseLiteralValue() protected
    Auxiliary function to parse a symbol from a locale definition file
  • _pluralGuess() protected
    Attempts to find the plural form of a string.
  • _translateTime() protected
    Returns a Time format definition from corresponding domain
  • clear() public static
    Clears the domains internal data array. Useful for testing i18n.
  • domains() public static
    Get the loaded domains cache.
  • getInstance() public static
    Return a static instance of the I18n class
  • loadLocaleDefinition() public static
    Parses a locale definition file following the POSIX standard
  • loadMo() public static
    Loads the binary .mo file and returns array of translations
  • loadPo() public static
    Loads the text .po file and returns array of translations
  • translate() public static

    Used by the translation functions in basics.php Returns a translated string based on current language and translation files stored in locale folder

Method Detail

__construct() public ¶

__construct( )

Constructor, use I18n::getInstance() to get the i18n translation object.

_bindTextDomain() protected ¶

_bindTextDomain( string $domain )

Binds the given domain to a file in the specified directory.

Parameters
string $domain
Domain to bind
Returns
string
Domain binded

_parseLiteralValue() protected ¶

_parseLiteralValue( string $string )

Auxiliary function to parse a symbol from a locale definition file

Parameters
string $string
Symbol to be parsed
Returns
string
parsed symbol

_pluralGuess() protected ¶

_pluralGuess( string $header , integer $n )

Attempts to find the plural form of a string.

Parameters
string $header
Type
integer $n
Number
Returns
integer
plural match
Link
http://localization-guide.readthedocs.org/en/latest/l10n/pluralforms.html
https://developer.mozilla.org/en-US/docs/Mozilla/Localization/Localization_and_Plurals#List_of_Plural_Rules

_translateTime() protected ¶

_translateTime( string $format , string $domain )

Returns a Time format definition from corresponding domain

Parameters
string $format
Format to be translated
string $domain
Domain where format is stored
Returns
mixed
translated format string if only value or array of translated strings for corresponding format.

clear() public static ¶

clear( )

Clears the domains internal data array. Useful for testing i18n.

domains() public static ¶

domains( )

Get the loaded domains cache.

Returns
array

getInstance() public static ¶

getInstance( )

Return a static instance of the I18n class

Returns
I18n

loadLocaleDefinition() public static ¶

loadLocaleDefinition( string $filename )

Parses a locale definition file following the POSIX standard

Parameters
string $filename
Locale definition filename
Returns
mixed
Array of definitions on success or false on failure

loadMo() public static ¶

loadMo( string $filename )

Loads the binary .mo file and returns array of translations

Parameters
string $filename
Binary .mo file to load
Returns
mixed
Array of translations on success or false on failure

loadPo() public static ¶

loadPo( string $filename )

Loads the text .po file and returns array of translations

Parameters
string $filename
Text .po file to load
Returns
mixed
Array of translations on success or false on failure

translate() public static ¶

translate( string $singular , string $plural = null , string $domain = null , string $category = self::LC_MESSAGES , integer $count = null , string $language = null )

Used by the translation functions in basics.php Returns a translated string based on current language and translation files stored in locale folder

Parameters
string $singular
String to translate
string $plural optional null
Plural string (if any)
string $domain optional null

Domain The domain of the translation. Domains are often used by plugin translations. If null, the default domain will be used.

string $category optional self::LC_MESSAGES
Category The integer value of the category to use.
integer $count optional null
Count Count is used with $plural to choose the correct plural form.
string $language optional null

Language to translate string to. If null it checks for language in session followed by Config.language configuration variable.

Returns
string
translated string.
Throws
CakeException
When '' is provided as a domain.

Properties detail

$_categories ¶

protected array

Translation categories

array(
    'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', 'LC_MESSAGES'
)

$_domains ¶

protected array

Translation strings for a specific domain read from the .mo or .po files

array()

$_escape ¶

protected string

Escape string

null

$_lang ¶

protected string

Current language used for translations

null

$_noLocale ¶

protected boolean

Set to true when I18N::_bindTextDomain() is called for the first time. If a translation file is found it is set to false again

false

$category ¶

public string

Current category of translation

'LC_MESSAGES'

$defaultDomain ¶

public static string

Default domain of translation

'default'

$domain ¶

public string

Current domain of translation

null

$l10n ¶

public L10n

Instance of the L10n class for localization

null
OpenHub
Rackspace
Rackspace
  • 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
  • Slack
  • Paid Support

Generated using CakePHP API Docs