[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/l10n/ -> class-wp-translation-controller.php (summary)

I18N: WP_Translation_Controller class.

File Size: 455 lines (13 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 15 functions

  get_instance()
  get_locale()
  set_locale()
  load_file()
  unload_file()
  unload_textdomain()
  is_textdomain_loaded()
  translate()
  translate_plural()
  get_headers()
  normalize_header()
  get_entries()
  locate_translation()
  get_files()
  has_translation()

Functions
Functions that are not part of a class:

get_instance()   X-Ref
Utility method to retrieve the main instance of the class.

The instance will be created if it does not exist yet.

return: WP_Translation_Controller

get_locale()   X-Ref
Returns the current locale.

return: string Locale.

set_locale( string $locale )   X-Ref
Sets the current locale.

param: string $locale Locale.

load_file( string $translation_file, string $textdomain = 'default', ?string $locale = null )   X-Ref
Loads a translation file for a given text domain.

param: string $translation_file Translation file.
param: string $textdomain       Optional. Text domain. Default 'default'.
param: string $locale           Optional. Locale. Default current locale.
return: bool True on success, false otherwise.

unload_file( $file, string $textdomain = 'default', ?string $locale = null )   X-Ref
Unloads a translation file for a given text domain.

param: WP_Translation_File|string $file       Translation file instance or file name.
param: string                     $textdomain Optional. Text domain. Default 'default'.
param: string                     $locale     Optional. Locale. Defaults to all locales.
return: bool True on success, false otherwise.

unload_textdomain( string $textdomain = 'default', ?string $locale = null )   X-Ref
Unloads all translation files for a given text domain.

param: string $textdomain Optional. Text domain. Default 'default'.
param: string $locale     Optional. Locale. Defaults to all locales.
return: bool True on success, false otherwise.

is_textdomain_loaded( string $textdomain = 'default', ?string $locale = null )   X-Ref
Determines whether translations are loaded for a given text domain.

param: string $textdomain Optional. Text domain. Default 'default'.
param: string $locale     Optional. Locale. Default current locale.
return: bool True if there are any loaded translations, false otherwise.

translate( string $text, string $context = '', string $textdomain = 'default', ?string $locale = null )   X-Ref
Translates a singular string.

param: string $text       Text to translate.
param: string $context    Optional. Context for the string. Default empty string.
param: string $textdomain Optional. Text domain. Default 'default'.
param: string $locale     Optional. Locale. Default current locale.
return: string|false Translation on success, false otherwise.

translate_plural( array $plurals, int $number, string $context = '', string $textdomain = 'default', ?string $locale = null )   X-Ref
Translates plurals.

Checks both singular+plural combinations as well as just singulars,
in case the translation file does not store the plural.

param: array       $plurals {
param: int         $number     Number of items.
param: string      $context    Optional. Context for the string. Default empty string.
param: string      $textdomain Optional. Text domain. Default 'default'.
param: string|null $locale     Optional. Locale. Default current locale.
return: string|false Translation on success, false otherwise.

get_headers( string $textdomain = 'default' )   X-Ref
Returns all existing headers for a given text domain.

param: string $textdomain Optional. Text domain. Default 'default'.
return: array<string, string> Headers.

normalize_header( string $header )   X-Ref
Normalizes header names to be capitalized.

param: string $header Header name.
return: string Normalized header name.

get_entries( string $textdomain = 'default' )   X-Ref
Returns all entries for a given text domain.

param: string $textdomain Optional. Text domain. Default 'default'.
return: array<string, string> Entries.

locate_translation( string $singular, string $textdomain = 'default', ?string $locale = null )   X-Ref
Locates translation for a given string and text domain.

param: string $singular   Singular translation.
param: string $textdomain Optional. Text domain. Default 'default'.
param: string $locale     Optional. Locale. Default current locale.
return: array{source: WP_Translation_File, entries: string[]}|false {

get_files( string $textdomain = 'default', ?string $locale = null )   X-Ref
Returns all translation files for a given text domain.

param: string $textdomain Optional. Text domain. Default 'default'.
param: string $locale     Optional. Locale. Default current locale.
return: WP_Translation_File[] List of translation files.

has_translation( string $singular, string $textdomain = 'default', ?string $locale = null )   X-Ref
Returns a boolean to indicate whether a translation exists for a given string with optional text domain and locale.

param: string  $singular   Singular translation to check.
param: string  $textdomain Optional. Text domain. Default 'default'.
param: ?string $locale     Optional. Locale. Default current locale.
return: bool  True if the translation exists, false otherwise.



Generated : Thu Nov 21 08:20:01 2024 Cross-referenced by PHPXref