Skip to content

Commit b0806a1

Browse files
Add case-insensitive ordering
1 parent 78f8080 commit b0806a1

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

msgfmt:ui/lib/client.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ Template.mfTransLang.events({
252252
'click #translationShowKey': function(event) {
253253
Session.set('translationShowKey', event.currentTarget.checked);
254254
},
255+
'click #translationCaseInsensitiveOrdering': function(event) {
256+
Session.set('translationCaseInsensitiveOrdering', event.currentTarget.checked);
257+
},
255258
'click .translationSort': function(event) {
256259
var currentSort = Session.get('translationSortField');
257260
var newSort = event.currentTarget.attributes['data-sortField'].value;
@@ -284,16 +287,24 @@ Template.mfTransLang.helpers({
284287
sortOrder = 'asc';
285288
}
286289
return strings().sort(function(a, b) {
290+
var first = a[sortField];
291+
var second = b[sortField];
292+
var caseInsensitiveOrdering = Session.get('translationCaseInsensitiveOrdering');
293+
if (first && caseInsensitiveOrdering) first = first.toLowerCase();
294+
if (second && caseInsensitiveOrdering) second = second.toLowerCase();
287295
if (sortOrder === 'asc') {
288-
return a[sortField] > b[sortField] ? 1 : (a[sortField] < b[sortField] ? -1 : 0);
296+
return first > second ? 1 : (first < second ? -1 : 0);
289297
} else {
290-
return a[sortField] > b[sortField] ? -1 : (a[sortField] < b[sortField] ? 1 : 0);
298+
return first > second ? -1 : (first < second ? 1 : 0);
291299
}
292300
});
293301
},
294302
showKey: function() {
295303
return Session.get('translationShowKey');
296304
},
305+
caseInsensitiveOrdering: function() {
306+
return Session.get('caseInsensitiveOrdering');
307+
},
297308
stateClass: function() {
298309
if (this.fuzzy)
299310
return 'fuzzy';
@@ -330,6 +341,9 @@ Template.mfTransLang.helpers({
330341
if (routeName) str.routeUrl = routePathFromName(routeName);
331342
}
332343
return str || {};
344+
},
345+
isCheckboxChecked: function(value) {
346+
return (value === true ? 'checked' : '');
333347
}
334348
});
335349

msgfmt:ui/lib/ui.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ div.mfTransGraph.untrans { background: #800; border-right: 1px solid black; }
7575
*/
7676
#mfTransPreview table tr.current { background: #5598d7; color: white;}
7777

78+
#mfTransLang .options label { margin-right: 10px; }
7879

7980
#mfTransLang textarea {
8081
font-family: monospace;

msgfmt:ui/lib/ui.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,17 @@ <h2>{{mf 'mf_site_translations' 'Site Translations'}}</h2>
9797
</table>
9898
</div>
9999
</div>
100-
<p><input type="checkbox" id="translationShowKey">Show key, Use ctrl-up and ctrl-down to quickly change keys</p>
100+
<p class='options'>
101+
<label>
102+
<input type="checkbox" id="translationShowKey" {{isCheckboxChecked showKey}}>
103+
Show key
104+
</label>
105+
<label>
106+
<input type='checkbox' id='translationCaseInsensitiveOrdering' {{isCheckboxChecked caseInsensitiveOrdering}}>
107+
Case Insensitive Ordering
108+
</label>
109+
Use ctrl-up and ctrl-down to quickly change keys
110+
</p>
101111
<span><b>{{keyInfo.key}}</b> in {{keyInfo.file}}:{{keyInfo.line
102112
}}{{#if keyInfo.template}} (template
103113
{{#if keyInfo.routeUrl}}

0 commit comments

Comments
 (0)