[ Index ] |
PHP Cross Reference of YOURLS |
[Source view] [Print] [Project Stats]
YOURLS Translation API YOURLS modification of a small subset from WordPress' Translation API implementation. GPL License
File Size: | 1129 lines (40 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
YOURLS_Locale_Formats:: (16 methods):
init()
get_weekday()
get_weekday_initial()
get_weekday_abbrev()
get_month()
get_month_abbrev()
get_meridiem()
register_globals()
__construct()
is_rtl()
yourls_load_custom_textdomain()
yourls_is_rtl()
yourls_l10n_weekday_abbrev()
yourls_l10n_weekday_initial()
yourls_l10n_month_abbrev()
yourls_l10n_months()
Class: YOURLS_Locale_Formats - X-Ref
Class that loads the calendar locale.init() X-Ref |
Sets up the translated strings and object properties. The method creates the translatable strings for various calendar elements. Which allows for specifying locale specific calendar names and text direction. return: void since: 1.6 |
get_weekday( $weekday_number ) X-Ref |
Retrieve the full translated weekday word. Week starts on translated Sunday and can be fetched by using 0 (zero). So the week starts with 0 (zero) and ends on Saturday with is fetched by using 6 (six). return: string Full translated weekday param: int|string $weekday_number 0 for Sunday through 6 Saturday since: 1.6 |
get_weekday_initial( $weekday_name ) X-Ref |
Retrieve the translated weekday initial. The weekday initial is retrieved by the translated full weekday word. When translating the weekday initial pay attention to make sure that the starting letter does not conflict. return: string param: string $weekday_name since: 1.6 |
get_weekday_abbrev( $weekday_name ) X-Ref |
Retrieve the translated weekday abbreviation. The weekday abbreviation is retrieved by the translated full weekday word. return: string Translated weekday abbreviation param: string $weekday_name Full translated weekday word since: 1.6 |
get_month( $month_number ) X-Ref |
Retrieve the full translated month by month number. The $month_number parameter has to be a string because it must have the '0' in front of any number that is less than 10. Starts from '01' and ends at '12'. You can use an integer instead and it will add the '0' before the numbers less than 10 for you. return: string Translated full month name param: string|int $month_number '01' through '12' since: 1.6 |
get_month_abbrev( $month_name ) X-Ref |
Retrieve translated version of month abbreviation string. The $month_name parameter is expected to be the translated or translatable version of the month. return: string Translated abbreviated month param: string $month_name Translated month to get abbreviated version since: 1.6 |
get_meridiem( $meridiem ) X-Ref |
Retrieve translated version of meridiem string. The $meridiem parameter is expected to not be translated. return: string Translated version param: string $meridiem Either 'am', 'pm', 'AM', or 'PM'. Not translated version. since: 1.6 |
register_globals() X-Ref |
Global variables are deprecated. For backwards compatibility only. return: void since: 1.6 |
__construct() X-Ref |
Constructor which calls helper methods to set up object variables return: YOURLS_Locale_Formats since: 1.6 |
is_rtl() X-Ref |
Checks if current locale is RTL. return: bool Whether locale is RTL. since: 1.6 |
yourls_load_custom_textdomain( $domain, $path ) X-Ref |
Loads a custom translation file (for a plugin, a theme, a public interface...) if locale is defined The .mo file should be named based on the domain with a dash, and then the locale exactly, eg 'myplugin-pt_BR.mo' return: mixed Returns nothing if locale undefined, otherwise return bool: true on success, false on failure param: string $domain Unique identifier (the "domain") for retrieving translated strings param: string $path Full path to directory containing MO files. since: 1.6 |
yourls_is_rtl() X-Ref |
Checks if current locale is RTL. Stolen from WP. return: bool Whether locale is RTL. since: 1.6 |
yourls_l10n_weekday_abbrev( $weekday = '' ) X-Ref |
Return translated weekday abbreviation (3 letters, eg 'Fri' for 'Friday') The $weekday var can be a textual string ('Friday'), a integer (0 to 6) or an empty string If $weekday is an empty string, the function returns an array of all translated weekday abbrev return: mixed Translated weekday abbreviation, eg "Ven" (abbrev of "Vendredi") for "Friday" or 5, or array of all weekday abbrev param: mixed $weekday A full textual weekday, eg "Friday", or an integer (0 = Sunday, 1 = Monday, .. 6 = Saturday) since: 1.6 |
yourls_l10n_weekday_initial( $weekday = '' ) X-Ref |
Return translated weekday initial (1 letter, eg 'F' for 'Friday') The $weekday var can be a textual string ('Friday'), a integer (0 to 6) or an empty string If $weekday is an empty string, the function returns an array of all translated weekday initials return: mixed Translated weekday initial, eg "V" (initial of "Vendredi") for "Friday" or 5, or array of all weekday initials param: mixed $weekday A full textual weekday, eg "Friday", an integer (0 = Sunday, 1 = Monday, .. 6 = Saturday) or empty string since: 1.6 |
yourls_l10n_month_abbrev( $month = '' ) X-Ref |
Return translated month abbrevation (3 letters, eg 'Nov' for 'November') The $month var can be a textual string ('November'), a integer (1 to 12), a two digits strings ('01' to '12), or an empty string If $month is an empty string, the function returns an array of all translated abbrev months ('January' => 'Jan', ...) return: mixed Translated month abbrev (eg "Nov"), or array of all translated abbrev months param: mixed $month Empty string, a full textual weekday, eg "November", or an integer (1 = January, .., 12 = December) since: 1.6 |
yourls_l10n_months() X-Ref |
Return array of all translated months return: array Array of all translated months since: 1.6 |
yourls_get_locale() X-Ref |
Gets the current locale. If the locale is set, then it will filter the locale in the 'get_locale' filter hook and return the value. If the locale is not set already, then the YOURLS_LANG constant is used if it is defined. Then it is filtered through the 'get_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 'get_locale' hook. return: string The locale of the YOURLS instance since: 1.6 |
yourls_translate( $text, $domain = 'default' ) X-Ref |
Retrieves the translation of $text. If there is no translation, or the domain isn't loaded, the original text is returned. return: string Translated text param: string $text Text to translate. param: string $domain Domain to retrieve the translated text. since: 1.6 |
yourls_translate_with_context( $text, $context, $domain = 'default' ) X-Ref |
Retrieves the translation of $text with a given $context. If there is no translation, or the domain isn't loaded, the original text is returned. 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. return: string Translated text param: string $text Text to translate. param: string $context Context. param: string $domain Domain to retrieve the translated text. since: 1.6 |
yourls__( $text, $domain = 'default' ) X-Ref |
Retrieves the translation of $text. If there is no translation, or the domain isn't loaded, the original text is returned. return: string Translated text param: string $text Text to translate param: string $domain Optional. Domain to retrieve the translated text since: 1.6 |
yourls_s( $pattern ) X-Ref |
Return a translated sprintf() string (mix yourls__() and sprintf() in one func) Instead of doing sprintf( yourls__( 'string %s' ), $arg ) you can simply use: yourls_s( 'string %s', $arg ) This function accepts an arbitrary number of arguments: - first one will be the string to translate, eg "hello %s my name is %s" - following ones will be the sprintf arguments, eg "world" and "Ozh" - if there are more arguments passed than needed, the last one will be used as the translation domain return: string Translated text param: mixed ...$pattern Text to translate, then $arg1: optional sprintf tokens, and $arg2: translation domain since: 1.6 |
yourls_se( $pattern ) X-Ref |
Echo a translated sprintf() string (mix yourls__() and sprintf() in one func) Instead of doing printf( yourls__( 'string %s' ), $arg ) you can simply use: yourls_se( 'string %s', $arg ) This function accepts an arbitrary number of arguments: - first one will be the string to translate, eg "hello %s my name is %s" - following ones will be the sprintf arguments, eg "world" and "Ozh" - if there are more arguments passed than needed, the last one will be used as the translation domain return: void Translated text param: string ...$pattern Text to translate, then optional sprintf tokens, and optional translation domain since: 1.6 |
yourls_esc_attr__( $text, $domain = 'default' ) X-Ref |
Retrieves the translation of $text and escapes it for safe use in an attribute. If there is no translation, or the domain isn't loaded, the original text is returned. return: string Translated text param: string $text Text to translate param: string $domain Optional. Domain to retrieve the translated text since: 1.6 |
yourls_esc_html__( $text, $domain = 'default' ) X-Ref |
Retrieves the translation of $text and escapes it for safe use in HTML output. If there is no translation, or the domain isn't loaded, the original text is returned. return: string Translated text param: string $text Text to translate param: string $domain Optional. Domain to retrieve the translated text since: 1.6 |
yourls_e( $text, $domain = 'default' ) X-Ref |
Displays the returned translated text from yourls_translate(). return: void param: string $text Text to translate param: string $domain Optional. Domain to retrieve the translated text since: 1.6 |
yourls_esc_attr_e( $text, $domain = 'default' ) X-Ref |
Displays translated text that has been escaped for safe use in an attribute. return: void param: string $text Text to translate param: string $domain Optional. Domain to retrieve the translated text since: 1.6 |
yourls_esc_html_e( $text, $domain = 'default' ) X-Ref |
Displays translated text that has been escaped for safe use in HTML output. return: void param: string $text Text to translate param: string $domain Optional. Domain to retrieve the translated text since: 1.6 |
yourls_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. return: string Translated context string param: string $text Text to translate param: string $context Context information for the translators param: string $domain Optional. Domain to retrieve the translated text since: 1.6 |
yourls_xe( $text, $context, $domain = 'default' ) X-Ref |
Displays translated string with gettext context return: void Echoes translated context string param: string $text Text to translate param: string $context Context information for the translators param: string $domain Optional. Domain to retrieve the translated text since: 1.7.1 |
yourls_esc_attr_x( $single, $context, $domain = 'default' ) X-Ref |
Return translated text, with context, that has been escaped for safe use in an attribute return: string param: string $single param: string $context param: string $domain Optional. Domain to retrieve the translated text since: 1.6 |
yourls_esc_html_x( $single, $context, $domain = 'default' ) X-Ref |
Return translated text, with context, that has been escaped for safe use in HTML output return: string param: string $single param: string $context param: string $domain Optional. Domain to retrieve the translated text since: 1.6 |
yourls_n( $single, $plural, $number, $domain = 'default' ) X-Ref |
Retrieve the plural or single form based on the amount. If the domain is not set in the $yourls_l10n list, then a comparison will be made and either $plural or $single parameters returned. If the domain does exist, then the parameters $single, $plural, and $number will first be passed to the domain's ngettext method. Then it will be passed to the 'translate_n' filter hook along with the same parameters. The expected type will be a string. return: string Either $single or $plural translated text 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. The domain identifier the text should be retrieved in since: 1.6 |
yourls_nx($single, $plural, $number, $context, $domain = 'default') X-Ref |
A hybrid of yourls_n() and yourls_x(). It supports contexts and plurals. return: string Either $single or $plural translated text 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. The domain identifier the text should be retrieved in since: 1.6 |
yourls_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: $messages = array( 'post' => yourls_n_noop('%s post', '%s posts'), 'page' => yourls_n_noop('%s pages', '%s pages') ); ... $message = $messages[$type]; $usable_text = sprintf( yourls_translate_nooped_plural( $message, $count ), $count ); return: array array($singular, $plural) param: string $singular Single form to be i18ned param: string $plural Plural form to be i18ned param: string $domain Optional. The domain identifier the text will be retrieved in since: 1.6 |
yourls_nx_noop( $singular, $plural, $context, $domain = null ) X-Ref |
Register plural strings with context in POT file, but don't translate them. return: array array($singular, $plural) param: string $singular Single form to be i18ned param: string $plural Plural form to be i18ned param: string $context Context information for the translators param: string $domain Optional. The domain identifier the text will be retrieved in since: 1.6 |
yourls_translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) X-Ref |
Translate the result of yourls_n_noop() or yourls_nx_noop() return: string param: array $nooped_plural Array with singular, plural and context keys, usually the result of yourls_n_noop() or yourls_nx_noop() param: int $count Number of objects param: string $domain Optional. The domain identifier the text should be retrieved in. If $nooped_plural contains since: 1.6 |
yourls_load_textdomain( $domain, $mofile ) X-Ref |
Loads a MO file into the domain $domain. If the 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 $yourls_l10n global by $domain and will be a MO object. return: bool True on success, false on failure param: string $domain Unique identifier for retrieving translated strings param: string $mofile Path to the .mo file since: 1.6 |
yourls_unload_textdomain( $domain ) X-Ref |
Unloads translations for a domain return: bool Whether textdomain was unloaded param: string $domain Textdomain to be unloaded since: 1.6 |
yourls_load_default_textdomain() X-Ref |
Loads default translated strings based on locale. Loads the .mo file in YOURLS_LANG_DIR constant path from YOURLS root. The translated (.mo) file is named based on the locale. return: bool True on success, false on failure since: 1.6 |
yourls_get_translations_for_domain( $domain ) X-Ref |
Returns the Translations instance for a domain. If there isn't one, returns empty Translations instance. return: NOOPTranslations An NOOPTranslations translation instance param: string $domain |
yourls_is_textdomain_loaded( $domain ) X-Ref |
Whether there are translations for the domain return: bool Whether there are translations param: string $domain since: 1.6 |
yourls_translate_user_role( $name ) X-Ref |
Translates role name. Unused. Unused function for the moment, we'll see when there are roles. From the WP source: 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. return: string Translated role name param: string $name The role name since: 1.6 |
yourls_get_available_languages( $dir = null ) X-Ref |
Get all available languages (*.mo files) in a given directory. The default directory is YOURLS_LANG_DIR. return: array 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. param: string $dir A directory in which to search for language files. The default directory is YOURLS_LANG_DIR. since: 1.6 |
yourls_number_format_i18n( $number, $decimals = 0 ) X-Ref |
Return integer number to format based on the locale. return: string Converted number in string format. param: int $number The number to convert based on locale. param: int $decimals Precision of the number of decimal places. since: 1.6 |
yourls_date_i18n( $dateformatstring, $timestamp = false ) X-Ref |
Return the date in localized format, based on timestamp. If the locale specifies the locale month and weekday, then the locale will take over the format for the date. If it isn't, then the date format string will be used instead. return: string The date, translated if locale specifies it. param: string $dateformatstring Format to display the date. param: bool|int $timestamp Optional, Unix timestamp, default to current timestamp (with offset if applicable) since: 1.6 |
Generated: Sat Feb 22 05:10:06 2025 | Cross-referenced by PHPXref 0.7.1 |