Suite à cette discussion sur le groupe Drupal France, je viens de modifier le module l10n_server afin de mieux gérer les espaces insécables.
Attention c'est du quick & dirty !
$str = str_replace(" ", chr(0xc2) . chr(0xa0), $str);
// A toolbox which displays action icons on each string editor fieldset. $value_str = '<div class="toolbox">'. ($string->has_suggestion ? theme('l10n_community_button', 'has-suggestion', 'l10n-has-suggestion', 'title="'. t('Has suggestions.') .'"') : theme('l10n_community_button', 'has-no-suggestion', 'l10n-has-no-suggestion', 'title="'. t('Has no suggestions.') .'"') ) ; $value_str .= theme('l10n_community_button', 'space', 'copy', 'onclick="return l10nCommunity.insertSpace('.$string->sid.');" title="'. t('Insert unbreakable space.') .'"') ; $value_str .= '</div><div class="messagebox"></div>'; $form[$string->sid]['toolbox'] = array( '#type' => 'markup', '#value' => $value_str );
Ajout de la méthode insertSpace()
l10nCommunity.insertSpace = function(sid){ $("#l10n-community-translation-" + sid).replaceSelection(" "); }
/* * jQuery plugin: fieldSelection - v0.1.0 - last change: 2006-12-16 * (c) 2006 Alex Brem <alex@0xab.cd> - <a href="http://blog.0xab.cd<br /> " title="http://blog.0xab.cd<br /> ">http://blog.0xab.cd<br /> </a> */ (function() { var fieldSelection = { getSelection: function() { var e = this.jquery ? this[0] : this; turn ( /* mozilla / dom 3.0 */ ('selectionStart' in e && function() { var l = e.selectionEnd - e.selectionStart; return { start: e.selectionStart, end: e.selectionEnd, length: l, text: e.value.substr(e.selectionStart, l) }; }) || /* exploder */ (document.selection && function() { e.focus(); var r = document.selection.createRange(); if (r == null) { return { start: 0, end: e.value.length, length: 0 } } var re = e.createTextRange(); var rc = re.duplicate(); re.moveToBookmark(r.getBookmark()); rc.setEndPoint('EndToStart', re); return { start: rc.text.length, end: rc.text.length + r.text.length, length: r.text.length, text: r.text }; }) || /* browser not supported */ function() { return { start: 0, end: e.value.length, length: 0 }; } )(); }, replaceSelection: function() { var e = this.jquery ? this[0] : this; var text = arguments[0] || ''; return ( /* mozilla / dom 3.0 */ ('selectionStart' in e && function() { e.value = e.value.substr(0, e.selectionStart) + text + e.value.substr(e.selectionEnd, e.value.length); return this; }) || /* exploder */ (document.selection && function() { e.focus(); document.selection.createRange().text = text; return this; }) || /* browser not supported */ function() { e.value += text; return this; } )(); } }; jQuery.each(fieldSelection, function(i) { jQuery.fn[i] = this; }); })();
| Attachment | Size |
|---|---|
| l10n_server-5.x-1.0-alpha3-espace-insecable.tar_.gz | 364.52 Ko |
Poster un nouveau commentaire