Skip to content

Commit

Permalink
Enable copy-to-clipboard
Browse files Browse the repository at this point in the history
Also used the UI to confirm base EN-US string
for many IT-IT strings.
  • Loading branch information
henrygab committed Jan 20, 2025
1 parent 5d384d2 commit e04bf10
Show file tree
Hide file tree
Showing 2 changed files with 410 additions and 324 deletions.
32 changes: 19 additions & 13 deletions src/translation/editor/translation_editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,20 @@ <h2>Languages</h2>
}, 4);
}

function copy_export_json_to_clipboard(translation_id) {
const export_maps = get_export_data(translation_id);
console.log('Exporting data for ' + translation_id, export_maps);
const jsonified_data = map_to_json(export_maps);
console.log('JSONified data: ', jsonified_data);
navigator.clipboard.writeText(jsonified_data).then(function() {
console.log('Copied to clipboard');
// should have some sort of overlay that fades away
// that confirms the export was successful....
}, function() {
console.log('Failed to copy to clipboard');
});
}

$(document).ready(function() {

let promises_of_loaded_data = [];
Expand All @@ -197,12 +211,8 @@ <h2>Languages</h2>
$('#tabs').append($('<div>').attr('id', $section));
let $tabdata = $(`#${$section}`);
// Add a button to tabdata to export the data
$tabdata.append(
$('<button>').text('Export').click(function() {
let export_data = get_export_data(value);
console.log('Exporting data for ' + value, export_data);
let jsonified_data = map_to_json(export_data);
console.log('JSONified data: ', jsonified_data);
$tabdata.append($('<button>').text('Export to clipboard').click(function() {
copy_export_json_to_clipboard(value);
}));

let $table = $('<table>').attr('id', `translation-${value}`);
Expand All @@ -213,13 +223,9 @@ <h2>Languages</h2>
$('#tab_labels').append($('<li>').append($('<a>').attr('href', "#tabs-new").text('New')));
$('#tabs').append($('<div>').attr('id', 'tabs-new'));
let $tabdata = $('#tabs-new');
$tabdata.append(
$('<button>').text('Export').click(function() {
let export_data = get_export_data('new');
console.log('Exporting data for new', export_data);
let jsonified_data = map_to_json(export_data);
console.log('JSONified data: ', jsonified_data);
}));
$tabdata.append($('<button>').text('Export to clipboard').click(function() {
copy_export_json_to_clipboard('new');
}));

let $table = $('<table>').attr('id', 'translation-new');
add_table_structure($table);
Expand Down
Loading

0 comments on commit e04bf10

Please sign in to comment.