Skip to content

Commit 76655bb

Browse files
committed
Switch to locale-independent sorting
Fixes #57
1 parent 9043b4b commit 76655bb

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

lib/extract.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ function mkAttrRegex(startDelim, endDelim, attribute) {
2727
return new RegExp(start + '\\s*(\'|"|"|')(.*?)\\1\\s*\\|\\s*' + attribute + '\\s*(' + end + '|\\|)', 'g');
2828
}
2929

30-
function localeCompare(a, b) {
31-
return a.localeCompare(b);
30+
function stringCompare(a, b) {
31+
return a === b ? 0 : a > b ? 1 : -1;
3232
}
3333

3434
function comments2String(comments) {
@@ -136,7 +136,7 @@ var Extractor = (function () {
136136
refString += ':' + reference.location.start.line;
137137
}
138138
}
139-
var refIndex = search(item.references, refString, localeCompare);
139+
var refIndex = search(item.references, refString, stringCompare);
140140
if (refIndex < 0) { // don't add duplicate references
141141
// when not found, binary-search returns -(index_where_it_should_be + 1)
142142
item.references.splice(Math.abs(refIndex + 1), 0, refString);
@@ -154,7 +154,7 @@ var Extractor = (function () {
154154
item.msgstr = ['', ''];
155155
}
156156
if (extractedComment) {
157-
var commentIndex = search(item.extractedComments, extractedComment, localeCompare);
157+
var commentIndex = search(item.extractedComments, extractedComment, stringCompare);
158158
if (commentIndex < 0) { // don't add duplicate comments
159159
item.extractedComments.splice(Math.abs(commentIndex + 1), 0, extractedComment);
160160
}
@@ -396,7 +396,7 @@ var Extractor = (function () {
396396
}
397397

398398
catalog.items.sort(function (a, b) {
399-
return a.msgid.localeCompare(b.msgid);
399+
return stringCompare(a.msgid, b.msgid);
400400
});
401401

402402
this.options.postProcess(catalog);

0 commit comments

Comments
 (0)