Sha256: 6f2f47cc24297d04ff2abc6bc56e3c2d88301818ab3354e3e4465ef87ae7939d
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
# extract i18n keys from a textnode (e.g. "translated text--en.translation.key--") window.I18nViz.extractI18nKeysFromText = (text) -> keys = text.match(window.I18nViz.global_regex) if keys keys.forEach (value, index) -> keys[index] = value.replace(/--/g, "") keys else null # enrich elements with i18n attributes, classes $.fn.enrichWithI18nData = () -> $i18n_element = $(this) i18n_keys = window.I18nViz.extractI18nKeysFromText $i18n_element.text() if i18n_keys != null $i18n_element .addClass("i18n-viz") .data("i18n-keys", i18n_keys) $i18n_element # clear i18n data from element text $.fn.clearI18nText = () -> $(this).textNodes().each () -> $(this).replaceWith $(this).text().replace(I18nViz.global_regex, "") $(this) # custom :i18n selectors $.extend $.expr[':'], { 'i18n-textnode': (el) -> window.I18nViz.regex.test $(el).textNodes().text() , 'i18n-value-placeholder': (el) -> (window.I18nViz.regex.test($(el).val()) || I18nViz.regex.test($(el).attr('placeholder'))) }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
i18n_viz-0.3.1 | app/assets/javascripts/i18n_viz/processing.js.coffee |