/** * Return the localized version of some deferred translatable text (dtt) * * @param string $key - the key to the translatable text - which may be the actual text * @return string $l10n - the translated text - which may end up as the untranslated text or even the key. * * **?** Does it matter what textdomain we use for subsequent translations? * */ function bw_tt($key) { global $bw_l10n; $l10n = bw_array_get($bw_l10n, $key, null); if ($l10n) { // It's already been translated, return this } else { $i18n = bw_get_dtt($key); $l10n = bw_translate($i18n); // $textdomain = bw_context( "textdomain" ); $bw_l10n[$key] = $l10n; } //bw_trace2( $bw_l10n ); return $l10n; }
/** * Create an optional textarea * * If the _cb field is present we use this value. otherwise we default to "on" * * Similar to this but the checkbox appears in the label for the textarea * bw_checkbox_arr( $option, "Include?", $options, 'intro_cb' ); * bw_textarea_arr( $option, "Introduction", $text, 'intro', 60, 5 ); * * @TODO: In this version the checkbox appears next to the label. It might be nicer to have it next to the textarea. * Note: We need to call bw_translate() here since the modified text won't be recognised when it reaches the label() function * as it will have had the nbsp and checkbox HTML added by then. * * @param string $name field name * @param string $text field label * @param array $array * @param integer $index * @param integer $len * @param integer $rows */ function bw_textarea_cb_arr($name, $text, $array, $index, $len, $rows = 5) { $name_index = $name . '[' . $index . '_cb]'; $cb_value = bw_array_get($array, $index . '_cb', "on"); $cb_text = bw_translate($text); $cb_text .= " "; $cb_text .= icheckbox($name_index, $cb_value); bw_textarea_arr($name, $cb_text, $array, $index, $len, $rows); }
/** * Append some non-translatable text to translatable text once it's been translated * * This is similar to using sprintf( __( "translatable_text %1$s", $non_translatable_text ) ); * BUT it doesn't require the translator to have to worry about the position of the variable * AS this isn't in the text they translate. */ function _bwtnt($translatable_text, $non_translatable_text) { $tnt = bw_translate($translatable_text); $tnt .= $non_translatable_text; return $tnt; }