*/
function before_last_bar( $string ) {
$last_bar = strrpos( $string, '|' );
- if ( false === $last_bar )
+ if ( false === $last_bar ) {
return $string;
- else
+ } else {
return substr( $string, 0, $last_bar );
+ }
}
/**
}
/**
- * Registers plural strings in POT file, but don't translate them.
+ * Registers plural strings in POT file, but does not translate them.
*
* Used when you want to keep structures with translatable plural
* strings and use them later when the number is known.
}
/**
- * Register plural strings with gettext context in the POT file, but don't translate them.
+ * Registers plural strings with gettext context in POT file, but does not translate them.
*
* Used when you want to keep structures with translatable plural
* strings and use them later when the number is known.
*
* @param string $singular Singular form to be localized.
* @param string $plural Plural form to be localized.
+ * @param string $context Context information for the translators.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
* Default null.
* @return array {
*/
function get_translations_for_domain( $domain ) {
global $l10n;
- if ( !isset( $l10n[$domain] ) ) {
- $l10n[$domain] = new NOOP_Translations;
+ if ( isset( $l10n[ $domain ] ) ) {
+ return $l10n[ $domain ];
}
- return $l10n[$domain];
+
+ static $noop_translations = null;
+ if ( null === $noop_translations ) {
+ $noop_translations = new NOOP_Translations;
+ }
+
+ return $noop_translations;
}
/**
*/
function is_textdomain_loaded( $domain ) {
global $l10n;
- return isset( $l10n[$domain] );
+ return isset( $l10n[ $domain ] );
}
/**
$language_data = array();
foreach ( $files as $file ) {
- if ( '.' === $file[0] || is_dir( $file ) ) {
+ if ( '.' === $file[0] || is_dir( WP_LANG_DIR . "$dir/$file" ) ) {
continue;
}
if ( substr( $file, -3 ) !== '.po' ) {
* @type array $translations List of available translations. Default result of
* wp_get_available_translations().
* @type string $selected Language which should be selected. Default empty.
- * @type bool|int $echo Whether to echo or return the generated markup. Accepts 0, 1, or their
- * bool equivalents. Default 1.
+ * @type bool|int $echo Whether to echo the generated markup. Accepts 0, 1, or their
+ * boolean equivalents. Default 1.
* @type bool $show_available_translations Whether to show available translations. Default true.
* }
- * @return string HTML content only if 'echo' argument is 0.
+ * @return string HTML content
*/
function wp_dropdown_languages( $args = array() ) {