-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve translation handling in JavaScript and TypeScript (#2036)
* Introduce i18n for JS/TS using Django's javascript catalog * Extract sortable_form.js.html to sortable_form.js --------- Co-authored-by: Richard Ebeling <dev@richardebeling.de>
- Loading branch information
1 parent
de8abc2
commit 431077a
Showing
21 changed files
with
185 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# EvaP translation | ||
# This file is distributed under the same license as the EvaP project. | ||
# | ||
#, fuzzy | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: EvaP\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2023-10-30 17:26+0100\n" | ||
"PO-Revision-Date: 2023-10-30 17:26+0100\n" | ||
"Last-Translator: Johannes Wolf <janno42@posteo.de>\n" | ||
"Language-Team: Johannes Wolf (janno42)\n" | ||
"Language: de\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
"X-Generator: Poedit 3.3.2\n" | ||
|
||
#: evap/static/js/notebook.js:30 evap/static/ts/src/notebook.ts:39 | ||
msgid "The server is not responding." | ||
msgstr "" | ||
|
||
#: evap/static/js/sortable_form.js:19 | ||
msgid "Delete" | ||
msgstr "" | ||
|
||
#: evap/static/js/sortable_form.js:20 | ||
msgid "add another" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# ignore the typescript output, but still track the libraries | ||
*.js | ||
!*.min.js | ||
!sortable_form.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
function makeFormSortable(tableId, prefix, rowChanged, rowAdded, tolerance, removeAsButton, usesTemplate) { | ||
|
||
function applyOrdering() { | ||
$(document).find('tr').each(function(i) { | ||
if (rowChanged($(this))) { | ||
$(this).find('input[id$=-order]').val(i); | ||
} | ||
else { | ||
// if the row is empty (has no text in the input fields) set the order to -1 (default), | ||
// so that the one extra row doesn't change its initial value | ||
$(this).find('input[id$=-order]').val(-1); | ||
} | ||
}); | ||
} | ||
|
||
$('#' + tableId + ' tbody tr').formset({ | ||
prefix: prefix, | ||
deleteCssClass: removeAsButton ? 'btn btn-danger btn-sm' : 'delete-row', | ||
deleteText: removeAsButton ? '<span class="fas fa-trash"></span>' : gettext('Delete'), | ||
addText: gettext('add another'), | ||
added: function(row) { | ||
row.find('input[id$=-order]').val(row.parent().children().length); | ||
|
||
// We have to empty the formset, otherwise sometimes old contents from | ||
// invalid forms are copied (#644). | ||
// Checkboxes with 'data-keep' need to stay checked. | ||
row.find("input:checkbox:not([data-keep]),:radio").removeAttr("checked"); | ||
|
||
row.find("input:text,textarea").val(""); | ||
|
||
row.find("select").each(function(){ | ||
$(this).find('option:selected').removeAttr("selected"); | ||
$(this).find('option').first().attr("selected", "selected"); | ||
}); | ||
|
||
//Check the first item in every button group | ||
row.find(".btn-group").each(function() { | ||
var inputs = $(this).find("input"); | ||
$(inputs[0]).prop("checked", true); | ||
}); | ||
|
||
//Remove all error messages | ||
row.find(".error-label").remove(); | ||
|
||
rowAdded(row); | ||
}, | ||
formTemplate: (usesTemplate ? ".form-template" : null) | ||
}); | ||
|
||
new Sortable($('#' + tableId + " tbody").get(0), { | ||
handle: ".fa-up-down", | ||
draggable: ".sortable", | ||
scrollSensitivity: 70 | ||
}); | ||
|
||
$('form').submit(function() { | ||
applyOrdering(); | ||
return true; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.