Skip to content

Commit 1bb96c7

Browse files
committed
Added localization support for href attributes on <a> tags.
Closes #34.
1 parent 578e2c0 commit 1bb96c7

6 files changed

+25
-3
lines changed

dist/jquery.localize.js

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ http://keith-wood.name/localisation.html
128128
};
129129
localizeForSpecialKeys = function(elem, value) {
130130
setAttrFromValueForKey(elem, "title", value);
131+
setAttrFromValueForKey(elem, "href", value);
131132
return setTextFromValueForKey(elem, "text", value);
132133
};
133134
localizeOptgroupElement = function(elem, key, value) {

dist/jquery.localize.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/jquery.localize.coffee

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ do ($ = jQuery) ->
9696

9797
localizeForSpecialKeys = (elem, value) ->
9898
setAttrFromValueForKey(elem, "title", value)
99+
setAttrFromValueForKey(elem, "href", value)
99100
setTextFromValueForKey(elem, "text", value)
100101

101102
localizeOptgroupElement = (elem, key, value) ->

test/lang/test-ja.json

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"src": "ruby_round.gif",
1313
"alt": "a round ruby",
1414
"title": "A Round Ruby"
15+
},
16+
"link": {
17+
"text": "success",
18+
"href": "http://success"
1519
}
1620
},
1721
"basic": "basic success",

test/localize_test.coffee

+6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ do ($ = jQuery) ->
8282
equal t.attr("alt"), "a round ruby"
8383
equal t.attr("title"), "A Round Ruby"
8484

85+
test "link tag href substitution", ->
86+
t = localizableTagWithRel("a", "test.link", href: "http://fail", text: "fail")
87+
t.localize("test", @testOpts)
88+
equal t.attr("href"), "http://success"
89+
equal t.text(), "success"
90+
8591
test "chained call", ->
8692
t = localizableTagWithRel("p", "basic", text: "basic fail")
8793
t.localize("test", @testOpts).localize("test", @testOpts)

test/localize_test.js

+10
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@
128128
equal(t.attr("alt"), "a round ruby");
129129
return equal(t.attr("title"), "A Round Ruby");
130130
});
131+
test("link tag href substitution", function() {
132+
var t;
133+
t = localizableTagWithRel("a", "test.link", {
134+
href: "http://fail",
135+
text: "fail"
136+
});
137+
t.localize("test", this.testOpts);
138+
equal(t.attr("href"), "http://success");
139+
return equal(t.text(), "success");
140+
});
131141
test("chained call", function() {
132142
var t;
133143
t = localizableTagWithRel("p", "basic", {

0 commit comments

Comments
 (0)