[ Index ]

WordPress Cross Reference

title

Body

[close]

/wp-includes/ -> l10n.php (summary)

WordPress Translation API

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

Defines 32 functions

  get_locale()
  translate()
  before_last_bar()
  translate_with_gettext_context()
  __()
  esc_attr__()
  esc_html__()
  _e()
  esc_attr_e()
  esc_html_e()
  _x()
  _ex()
  esc_attr_x()
  esc_html_x()
  _n()
  _nx()
  _n_noop()
  _nx_noop()
  translate_nooped_plural()
  load_textdomain()
  unload_textdomain()
  load_default_textdomain()
  load_plugin_textdomain()
  load_muplugin_textdomain()
  load_theme_textdomain()
  load_child_theme_textdomain()
  get_translations_for_domain()
  is_textdomain_loaded()
  translate_user_role()
  get_available_languages()
  wp_get_installed_translations()
  wp_get_pomo_file_data()

Functions
Functions that are not part of a class:

get_locale()   X-Ref
Get the current locale.

If the locale is set, then it will filter the locale in the 'locale' filter
hook and return the value.

If the locale is not set already, then the WPLANG constant is used if it is
defined. Then it is filtered through the 'locale' filter hook and the value
for the locale global set and the locale is returned.

The process to get the locale should only be done once, but the locale will
always be filtered using the 'locale' hook.

return: string The locale of the blog or from the 'locale' hook.

translate( $text, $domain = 'default' )   X-Ref
Retrieve the translation of $text.

If there is no translation, or the text domain isn't loaded, the original text is returned.

<strong>Note:</strong> Don't use translate() directly, use __() or related functions.

param: string $text   Text to translate.
param: string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
return: string Translated text

before_last_bar( $string )   X-Ref
Remove last item on a pipe-delimited string.

Meant for removing the last item in a string, such as 'Role name|User role'. The original
string will be returned if no pipe '|' characters are found in the string.

param: string $string A pipe-delimited string.
return: string Either $string or everything before the last pipe.

translate_with_gettext_context( $text, $context, $domain = 'default' )   X-Ref
Retrieve the translation of $text in the context defined in $context.

If there is no translation, or the text domain isn't loaded the original
text is returned.

param: string $text    Text to translate.
param: string $context Context information for the translators.
param: string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
return: string Translated text on success, original text on failure.

__( $text, $domain = 'default' )   X-Ref
Retrieve the translation of $text. If there is no translation,
or the text domain isn't loaded, the original text is returned.

param: string $text   Text to translate.
param: string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
return: string Translated text.

esc_attr__( $text, $domain = 'default' )   X-Ref
Retrieve the translation of $text and escapes it for safe use in an attribute.

If there is no translation, or the text domain isn't loaded, the original text is returned.

param: string $text   Text to translate.
param: string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
return: string Translated text on success, original text on failure.

esc_html__( $text, $domain = 'default' )   X-Ref
Retrieve the translation of $text and escapes it for safe use in HTML output.

If there is no translation, or the text domain isn't loaded, the original text is returned.

param: string $text   Text to translate.
param: string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
return: string Translated text

_e( $text, $domain = 'default' )   X-Ref
Display translated text.

param: string $text   Text to translate.
param: string $domain Optional. Text domain. Unique identifier for retrieving translated strings.

esc_attr_e( $text, $domain = 'default' )   X-Ref
Display translated text that has been escaped for safe use in an attribute.

param: string $text   Text to translate.
param: string $domain Optional. Text domain. Unique identifier for retrieving translated strings.

esc_html_e( $text, $domain = 'default' )   X-Ref
Display translated text that has been escaped for safe use in HTML output.

param: string $text   Text to translate.
param: string $domain Optional. Text domain. Unique identifier for retrieving translated strings.

_x( $text, $context, $domain = 'default' )   X-Ref
Retrieve translated string with gettext context.

Quite a few times, there will be collisions with similar translatable text
found in more than two places, but with different translated context.

By including the context in the pot file, translators can translate the two
strings differently.

param: string $text    Text to translate.
param: string $context Context information for the translators.
param: string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
return: string Translated context string without pipe.

_ex( $text, $context, $domain = 'default' )   X-Ref
Display translated string with gettext context.

param: string $text    Text to translate.
param: string $context Context information for the translators.
param: string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
return: string Translated context string without pipe.

esc_attr_x( $text, $context, $domain = 'default' )   X-Ref
Translate string with gettext context, and escapes it for safe use in an attribute.

param: string $text    Text to translate.
param: string $context Context information for the translators.
param: string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
return: string Translated text

esc_html_x( $text, $context, $domain = 'default' )   X-Ref
Translate string with gettext context, and escapes it for safe use in HTML output.

param: string $text    Text to translate.
param: string $context Context information for the translators.
param: string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
return: string Translated text.

_n( $single, $plural, $number, $domain = 'default' )   X-Ref
Retrieve the plural or single form based on the supplied amount.

If the text domain is not set in the $l10n list, then a comparison will be made
and either $plural or $single parameters returned.

If the text domain does exist, then the parameters $single, $plural, and $number
will first be passed to the text domain's ngettext method. Then it will be passed
to the 'ngettext' filter hook along with the same parameters. The expected
type will be a string.

param: string $single The text that will be used if $number is 1.
param: string $plural The text that will be used if $number is not 1.
param: int    $number The number to compare against to use either $single or $plural.
param: string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
return: string Either $single or $plural translated text.

_nx($single, $plural, $number, $context, $domain = 'default')   X-Ref
Retrieve the plural or single form based on the supplied amount with gettext context.

This is a hybrid of _n() and _x(). It supports contexts and plurals.

param: string $single  The text that will be used if $number is 1.
param: string $plural  The text that will be used if $number is not 1.
param: int    $number  The number to compare against to use either $single or $plural.
param: string $context Context information for the translators.
param: string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
return: string Either $single or $plural translated text with context.

_n_noop( $singular, $plural, $domain = null )   X-Ref
Register plural strings in POT file, but don't translate them.

Used when you want to keep structures with translatable plural
strings and use them later.

Example:
<code>
$messages = array(
'post' => _n_noop('%s post', '%s posts'),
'page' => _n_noop('%s pages', '%s pages')
);
...
$message = $messages[$type];
$usable_text = sprintf( translate_nooped_plural( $message, $count ), $count );
</code>

param: string $singular Single form to be i18ned.
param: string $plural   Plural form to be i18ned.
param: string $domain   Optional. Text domain. Unique identifier for retrieving translated strings.
return: array array($singular, $plural)

_nx_noop( $singular, $plural, $context, $domain = null )   X-Ref
Register plural strings with context in POT file, but don't translate them.


translate_nooped_plural( $nooped_plural, $count, $domain = 'default' )   X-Ref
Translate the result of _n_noop() or _nx_noop().

param: array  $nooped_plural Array with singular, plural and context keys, usually the result of _n_noop() or _nx_noop()
param: int    $count         Number of objects
param: string $domain        Optional. Text domain. Unique identifier for retrieving translated strings. If $nooped_plural contains
return: string Either $single or $plural translated text.

load_textdomain( $domain, $mofile )   X-Ref
Load a .mo file into the text domain $domain.

If the text domain already exists, the translations will be merged. If both
sets have the same string, the translation from the original value will be taken.

On success, the .mo file will be placed in the $l10n global by $domain
and will be a MO object.

param: string $domain Text domain. Unique identifier for retrieving translated strings.
param: string $mofile Path to the .mo file.
return: bool True on success, false on failure.

unload_textdomain( $domain )   X-Ref
Unload translations for a text domain.

param: string $domain Text domain. Unique identifier for retrieving translated strings.
return: bool Whether textdomain was unloaded.

load_default_textdomain()   X-Ref
Load default translated strings based on locale.

Loads the .mo file in WP_LANG_DIR constant path from WordPress root.
The translated (.mo) file is named based on the locale.


load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path = false )   X-Ref
Load a plugin's translated strings.

If the path is not given then it will be the root of the plugin directory.

The .mo file should be named based on the text domain with a dash, and then the locale exactly.

param: string $domain          Unique identifier for retrieving translated strings
param: string $deprecated      Use the $plugin_rel_path parameter instead.
param: string $plugin_rel_path Optional. Relative path to WP_PLUGIN_DIR where the .mo file resides.

load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' )   X-Ref
Load the translated strings for a plugin residing in the mu-plugins directory.

param: string $domain             Text domain. Unique identifier for retrieving translated strings.
param: string $mu_plugin_rel_path Relative to WPMU_PLUGIN_DIR directory in which the .mo file resides.
return: bool True when textdomain is successfully loaded, false otherwise.

load_theme_textdomain( $domain, $path = false )   X-Ref
Load the theme's translated strings.

If the current locale exists as a .mo file in the theme's root directory, it
will be included in the translated strings by the $domain.

The .mo files must be named based on the locale exactly.

param: string $domain Text domain. Unique identifier for retrieving translated strings.
param: string $path   Optional. Path to the directory containing the .mo file.
return: bool True when textdomain is successfully loaded, false otherwise.

load_child_theme_textdomain( $domain, $path = false )   X-Ref
Load the child themes translated strings.

If the current locale exists as a .mo file in the child themes
root directory, it will be included in the translated strings by the $domain.

The .mo files must be named based on the locale exactly.

param: string $domain Text domain. Unique identifier for retrieving translated strings.
return: bool True when the theme textdomain is successfully loaded, false otherwise.

get_translations_for_domain( $domain )   X-Ref
Return the Translations instance for a text domain.

If there isn't one, returns empty Translations instance.

param: string $domain Text domain. Unique identifier for retrieving translated strings.
return: Translations A Translations instance.

is_textdomain_loaded( $domain )   X-Ref
Whether there are translations for the text domain.

param: string $domain Text domain. Unique identifier for retrieving translated strings.
return: bool Whether there are translations.

translate_user_role( $name )   X-Ref
Translates role name.

Since the role names are in the database and not in the source there
are dummy gettext calls to get them into the POT file and this function
properly translates them back.

The before_last_bar() call is needed, because older installs keep the roles
using the old context format: 'Role name|User role' and just skipping the
content after the last bar is easier than fixing them in the DB. New installs
won't suffer from that problem.

param: string $name The role name.
return: string Translated role name on success, original name on failure.

get_available_languages( $dir = null )   X-Ref
Get all available languages based on the presence of *.mo files in a given directory.

The default directory is WP_LANG_DIR.

param: string $dir A directory to search for language files.
return: array An array of language codes or an empty array if no languages are present. Language codes are formed by stripping the .mo extension from the language file names.

wp_get_installed_translations( $type )   X-Ref
Get installed translations.

Looks in the wp-content/languages directory for translations of
plugins or themes.

param: string $type What to search for. Accepts 'plugins', 'themes', 'core'.
return: array Array of language data.

wp_get_pomo_file_data( $po_file )   X-Ref
Extract headers from a PO file.

param: string $po_file Path to PO file.
return: array PO file headers.



Generated: Tue Mar 25 01:41:18 2014 WordPress honlapkészítés: online1.hu