Skip to content

Commit efe82f5

Browse files
committed
Localize VTS
1 parent 359ba86 commit efe82f5

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

scripts/vts.js

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
this.vtsLang = this.lang;
2525

2626
// Inject a heading
27-
$heading = $('<h2>').text('Video Transcript Sorter'); // TODO: Localize; intelligently assign proper heading level
27+
let heading = this.translate( 'vtsHeading', 'Video Transcript Sorter' );
28+
$heading = $('<h2>').text( heading ); // TODO: intelligently assign proper heading level
2829
$('#able-vts').append($heading);
2930

3031
// Inject an empty div for writing messages
@@ -39,19 +40,19 @@
3940
$instructions = $('<div>',{
4041
'id': 'able-vts-instructions'
4142
});
42-
$p1 = $('<p>').text('Use the Video Transcript Sorter to modify text tracks:');
43+
$p1 = $('<p>').text( this.translate( 'vtsInstructions1', 'Use the Video Transcript Sorter to modify text tracks:' ) );
4344
$ul = $('<ul>');
44-
$li1 = $('<li>').text('Reorder chapters, descriptions, captions, and/or subtitles so they appear in the proper sequence in Able Player\'s auto-generated transcript.');
45-
$li2 = $('<li>').text('Modify content or start/end times (all are directly editable within the table).');
46-
$li3 = $('<li>').text('Add new content, such as chapters or descriptions.');
47-
$p2 = $('<p>').text('After editing, click the "Save Changes" button to generate new content for all relevant timed text files. The new text can be copied and pasted into new WebVTT files.');
45+
$li1 = $('<li>').text( this.translate( 'vtsInstructions2', 'Reorder chapters, descriptions, captions, and/or subtitles so they appear in the proper sequence in Able Player\'s auto-generated transcript.' ) );
46+
$li2 = $('<li>').text( this.translate( 'vtsInstructions3', 'Modify content or start/end times (all are directly editable within the table).' ) );
47+
$li3 = $('<li>').text( this.translate( 'vtsInstructions4', 'Add new content, such as chapters or descriptions.' ) );
48+
$p2 = $('<p>').text( this.translate( 'vtsInstructions5', 'After editing, click the "Save Changes" button to generate new content for all relevant timed text files. The new text can be copied and pasted into new WebVTT files.' ) );
4849
$ul.append($li1,$li2,$li3);
4950
$instructions.append($p1,$ul,$p2);
5051
$('#able-vts').append($instructions);
5152

5253
// Inject a fieldset with radio buttons for each language
5354
$fieldset = $('<fieldset>');
54-
$legend = $('<legend>').text('Select a language'); // TODO: Localize this
55+
$legend = $('<legend>').text( this.translate( 'vtsSelectLanguage', 'Select a language' ) );
5556
$fieldset.append($legend);
5657
$fieldWrapper = $( '<div class="vts-lang-selector"></div>' );
5758
for (i in this.langs) {
@@ -86,12 +87,12 @@
8687
$fieldset.append( $fieldWrapper );
8788
$('#able-vts').append($fieldset);
8889

89-
// Inject a 'Save Changes' button
90+
// Inject a button to generate new files.
9091
$saveButton = $('<button>',{
9192
'type': 'button',
9293
'id': 'able-vts-save',
9394
'value': 'save'
94-
}).text('Save Changes'); // TODO: Localize this
95+
}).text( this.translate( 'vtsSave', 'Generate new .vtt files' ) );
9596
$('#able-vts').append($saveButton);
9697

9798
// Inject a table with one row for each cue in the default language
@@ -140,7 +141,7 @@
140141
e.stopPropagation();
141142
if ($(this).attr('value') == 'save') {
142143
// replace table with WebVTT output in textarea fields (for copying/pasting)
143-
$(this).attr('value','cancel').text('Return to Editor'); // TODO: Localize this
144+
$(this).attr('value','cancel').text( this.translate( 'vtsReturn', 'Return to Editor' ) );
144145
$savedTable = $('#able-vts table');
145146
$('#able-vts-instructions').hide();
146147
$('#able-vts > fieldset').hide();
@@ -149,13 +150,13 @@
149150
thisObj.parseVtsOutput($savedTable);
150151
} else {
151152
// cancel saving, and restore the table using edited content
152-
$(this).attr('value','save').text('Save Changes'); // TODO: Localize this
153+
$(this).attr('value','save').text(this.translate( 'vtsSave', 'Generate new .vtt files' ) );
153154
$('#able-vts-output').remove();
154155
$('#able-vts-instructions').show();
155156
$('#able-vts > fieldset').show();
156157
$('#able-vts').append($savedTable);
157158
$('#able-vts').append(thisObj.getIconCredit());
158-
thisObj.showVtsAlert('Cancelling saving. Any edits you made have been restored in the VTS table.'); // TODO: Localize this
159+
thisObj.showVtsAlert( this.translate( 'vtsCancel', 'Cancelling saving. Any edits you made have been restored in the VTS table.' ) );
159160
}
160161
});
161162
}
@@ -299,10 +300,14 @@
299300
'lang': lang
300301
});
301302
$thead = $('<thead>');
302-
$tr = $('<tr>',{
303-
'lang': 'en' // TEMP, until header row is localized
304-
});
305-
headers = ['Row','Kind','Start','End','Content','Actions']; // TODO: Localize this
303+
headers = [
304+
this.translate( 'vtsRow', 'Row' ),
305+
this.translate( 'vtsKind', 'Kind' ),
306+
this.translate( 'vtsStart', 'Start' ),
307+
this.translate( 'vtsEnd', 'End' ),
308+
this.translate( 'vtsContent', 'Content' ),
309+
this.translate( 'vtsActions', 'Actions' )
310+
];
306311
for (i=0; i < headers.length; i++) {
307312
$th = $('<th>', {
308313
'scope': 'col'
@@ -702,7 +707,8 @@
702707
this.adjustTimes(newRowNum);
703708

704709
// Announce the insertion
705-
this.showVtsAlert('A new row ' + newRowNum + ' has been inserted'); // TODO: Localize this
710+
let newAlert = this.translate( 'vtsNewRow', 'A new row %1 has been inserted.', [ newRowNum ] );
711+
this.showVtsAlert( newAlert );
706712

707713
// Place focus in new select field
708714
$select.trigger('focus');
@@ -728,7 +734,8 @@
728734
}
729735

730736
// Announce the deletion
731-
this.showVtsAlert('Row ' + rowNum + ' has been deleted'); // TODO: Localize this
737+
let newAlert = this.translate( 'vtsDeletedRow', 'Row %1 has been deleted.', [ rowNum ] );
738+
this.showVtsAlert( newAlert );
732739

733740
};
734741

@@ -759,9 +766,8 @@
759766
// auto-adjust times
760767
this.adjustTimes(otherRowNum);
761768

762-
// Announce the move (TODO: Localize this)
763-
msg = 'Row ' + rowNum + ' has been moved ' + direction;
764-
msg += ' and is now Row ' + otherRowNum;
769+
// Announce the move
770+
msg = this.translate( 'vtsMovedRow', 'Row %1 has been moved %2 and is now Row %3.', [ rowNum, direction, otherRowNum ] );
765771
this.showVtsAlert(msg);
766772
};
767773

0 commit comments

Comments
 (0)