Skip to content
This repository was archived by the owner on Oct 23, 2021. It is now read-only.

Commit e91c920

Browse files
committed
Fixing textarea placeholder localization
1 parent 08bc0c5 commit e91c920

File tree

5 files changed

+32
-6
lines changed

5 files changed

+32
-6
lines changed

dist/jquery.localize.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ http://keith-wood.name/localisation.html
102102
});
103103
};
104104
localizeElement = function(elem, key, value) {
105-
if (elem.is('input')) {
105+
if (elem.is('input') || elem.is('textarea')) {
106106
localizeInputElement(elem, key, value);
107107
} else if (elem.is('img')) {
108108
localizeImageElement(elem, key, value);

dist/jquery.localize.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/jquery.localize.coffee

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ do ($ = jQuery) ->
8181
localizeElement(elem, key, value)
8282

8383
localizeElement = (elem, key, value) ->
84-
if elem.is('input') then localizeInputElement(elem, key, value)
85-
else if elem.is('img') then localizeImageElement(elem, key, value)
86-
else if elem.is('optgroup') then localizeOptgroupElement(elem, key, value)
84+
if elem.is('input') || elem.is('textarea') then localizeInputElement(elem, key, value)
85+
else if elem.is('img') then localizeImageElement(elem, key, value)
86+
else if elem.is('optgroup') then localizeOptgroupElement(elem, key, value)
8787
else unless $.isPlainObject(value) then elem.html(value)
8888
localizeForSpecialKeys(elem, value) if $.isPlainObject(value)
8989

test/localize_test.coffee

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ do ($ = jQuery) ->
5454
t.localize("test", @testOpts)
5555
equal t.attr("placeholder"), "input success"
5656

57+
test "textarea tag value substitution", ->
58+
t = localizableTagWithRel("textarea", "test.input", val: "input fail")
59+
t.localize("test", @testOpts)
60+
equal t.val(), "input success"
61+
62+
test "textarea tag placeholder substitution", ->
63+
t = localizableTagWithRel("textarea", "test.input", placeholder: "placeholder fail")
64+
t.localize("test", @testOpts)
65+
equal t.attr("placeholder"), "input success"
66+
5767
test "titled input tag value substitution", ->
5868
t = localizableTagWithRel("input", "test.input_as_obj", val: "input_as_obj fail")
5969
t.localize("test", @testOpts)

test/localize_test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@
8383
t.localize("test", this.testOpts);
8484
return equal(t.attr("placeholder"), "input success");
8585
});
86+
test("textarea tag value substitution", function() {
87+
var t;
88+
t = localizableTagWithRel("textarea", "test.input", {
89+
val: "input fail"
90+
});
91+
t.localize("test", this.testOpts);
92+
return equal(t.val(), "input success");
93+
});
94+
test("textarea tag placeholder substitution", function() {
95+
var t;
96+
t = localizableTagWithRel("textarea", "test.input", {
97+
placeholder: "placeholder fail"
98+
});
99+
t.localize("test", this.testOpts);
100+
return equal(t.attr("placeholder"), "input success");
101+
});
86102
test("titled input tag value substitution", function() {
87103
var t;
88104
t = localizableTagWithRel("input", "test.input_as_obj", {

0 commit comments

Comments
 (0)