Skip to content

Commit 49abcd9

Browse files
committed
Added support for localizing "title" attribute on images.
Closes #13
1 parent ea351b1 commit 49abcd9

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

build/jquery.localize.js

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

src/jquery.localize.coffee

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ $.localize = (pkg, options = {}) ->
7878
elem.attr("alt", value) if value?
7979
value = valueForKey("#{key}.src", data)
8080
elem.attr("src", value) if value?
81+
value = valueForKey("#{key}.title", data)
82+
elem.attr("title", value) if value?
8183
else
8284
elem.html(value)
8385

test/lang/test-ja.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"option": "option success",
77
"ruby_image": {
88
"src": "ruby_round.gif",
9-
"alt": "a round ruby"
9+
"alt": "a round ruby",
10+
"title": "A Round Ruby"
1011
}
1112
},
1213
"basic": "basic success"

test/localize_test.coffee

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ test "input tag placeholder substitution", ->
4646
t.localize("test", @testOpts)
4747
equals t.attr("placeholder"), "input success"
4848

49-
test "image tag src and alt substitution", ->
50-
t = localizableTagWithRel("img", "test.ruby_image", src: "ruby_square.gif", alt: "a square ruby")
49+
test "image tag src, alt, and title substitution", ->
50+
t = localizableTagWithRel("img", "test.ruby_image", src: "ruby_square.gif", alt: "a square ruby", title: "A Square Ruby")
5151
t.localize("test", @testOpts)
5252
equals t.attr("src"), "ruby_round.gif"
5353
equals t.attr("alt"), "a round ruby"
54+
equals t.attr("title"), "A Round Ruby"
5455

5556
test "chained call", ->
5657
t = localizableTagWithRel("p", "basic", text: "basic fail")

0 commit comments

Comments
 (0)