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);
|
||||
},
|
||||
update_description: function() {
|
||||
var count, description;
|
||||
var count;
|
||||
count = App.Globalize.enabled_locales().length;
|
||||
description = App.I18n.pluralize($(".globalize-languages").data("languages-description"), count);
|
||||
|
||||
$(".js-languages-description").text(description);
|
||||
App.I18n.set_pluralize($(".js-languages-description"), count);
|
||||
},
|
||||
initialize: function() {
|
||||
$(".js-add-language").on("change", function() {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
(function() {
|
||||
"use strict";
|
||||
App.I18n = {
|
||||
set_pluralize: function(element, count) {
|
||||
element.text(this.pluralize(element.data("texts"), count));
|
||||
},
|
||||
pluralize: function(texts, count) {
|
||||
return this.raw_text(texts, count).replace("%{count}", count);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user