Store texts data in the element using them
This way we can have a generic function we can apply in other places.
This commit is contained in:
@@ -75,11 +75,9 @@
|
|||||||
App.Globalize.display_translations(locale);
|
App.Globalize.display_translations(locale);
|
||||||
},
|
},
|
||||||
update_description: function() {
|
update_description: function() {
|
||||||
var count, description;
|
var count;
|
||||||
count = App.Globalize.enabled_locales().length;
|
count = App.Globalize.enabled_locales().length;
|
||||||
description = App.I18n.pluralize($(".globalize-languages").data("languages-description"), count);
|
App.I18n.set_pluralize($(".js-languages-description"), count);
|
||||||
|
|
||||||
$(".js-languages-description").text(description);
|
|
||||||
},
|
},
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
$(".js-add-language").on("change", function() {
|
$(".js-add-language").on("change", function() {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
(function() {
|
(function() {
|
||||||
"use strict";
|
"use strict";
|
||||||
App.I18n = {
|
App.I18n = {
|
||||||
|
set_pluralize: function(element, count) {
|
||||||
|
element.text(this.pluralize(element.data("texts"), count));
|
||||||
|
},
|
||||||
pluralize: function(texts, count) {
|
pluralize: function(texts, count) {
|
||||||
return this.raw_text(texts, count).replace("%{count}", count);
|
return this.raw_text(texts, count).replace("%{count}", count);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
<div class="row globalize-languages column padding-top <%= highlight_translation_html_class %>"
|
<div class="row globalize-languages column padding-top <%= highlight_translation_html_class %>">
|
||||||
data-languages-description="<%= t("shared.translations.languages_in_use").to_json %>">
|
|
||||||
<div class="small-6 large-3 column">
|
<div class="small-6 large-3 column">
|
||||||
<span class="small">
|
<span class="small">
|
||||||
<strong class="js-languages-description"><%= selected_languages_description(resource) %></strong>
|
<strong class="js-languages-description"
|
||||||
|
data-texts="<%= t("shared.translations.languages_in_use").to_json %>">
|
||||||
|
<%= selected_languages_description(resource) %>
|
||||||
|
</strong>
|
||||||
</span>
|
</span>
|
||||||
<%= select_tag :select_language,
|
<%= select_tag :select_language,
|
||||||
options_for_select_language(resource),
|
options_for_select_language(resource),
|
||||||
|
|||||||
Reference in New Issue
Block a user