Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Fixing Translations.js + kilo.js 🐤

Cette révision appartient à :
akuma06 2017-07-07 02:25:36 +02:00
Parent 2dd0e2ced8
révision 59a9aa6ad9
2 fichiers modifiés avec 14 ajouts et 5 suppressions

Voir le fichier

@ -3,10 +3,13 @@
function Translations() {
var translations = {};
this.Add = function(tr, val) {
trans = {}
if (val != undefined) {
tr[tr] = val;
trans[tr] = val;
} else {
trans = tr
}
Object.assign(translations, tr);
Object.assign(translations, trans);
};
this.r = function(string, ...args) {
if ((string != undefined) && (translations[string] != undefined)) {

Voir le fichier

@ -55,7 +55,7 @@
{{end}}
<a href="{{ URL.Parse("/search?c="+.Category+"_"+ .SubCategory) }}" title="{{ T(CategoryName(.Category, .SubCategory)) }}" class="category">
{{if .Languages[0] != "" }}
<a href="{{ URL.Parse("/search?c="+.Category+"_"+ .SubCategory +"&lang=" }} {{ range key, language := .Languages }}{{ flagCode(language) }}{{ if len(.Languages) > 1 && (key+1) < len(.Languages) }},{{ end }}{{ end }}">
<a href="{{ URL.Parse("/search?c="+.Category+"_"+ .SubCategory +"&lang=") }}{{ range key, language := .Languages }}{{ language }}{{ if len(.Languages) > 1 && (key+1) < len(.Languages) }},{{ end }}{{ end }}">
<img src="img/blank.gif" alt="{{ LanguageName(.Languages[0], T) }}" class="flag flag-{{ (len(.Languages) == 1) ? FlagCode(.Languages[0]) : "multiple" }}" title=" {{ range key, language := .Languages }}{{ LanguageName(language, T) }}{{ if len(.Languages) > 1 && (key+1) < len(.Languages) }},{{ end }}{{ end }}">
</a>
{{end}}
@ -161,8 +161,8 @@
<script type="text/javascript" src="{{ URL.Parse("/js/query.js") }}"></script>
<script type="text/javascript" src="{{ URL.Parse("/js/modal.js") }}"></script>
<script type="text/javascript" src="{{ URL.Parse("/js/torrents.js") }}"></script>
{{ if User.HasAdmin() }}
<script type="text/javascript" src="{{ URL.Parse("/js/translation.js") }}"></script>
{{ if User.HasAdmin() }}
<script type="text/javascript" src="{{ URL.Parse("/js/torrentsMod.js") }}"></script>
<script type="text/javascript">
// We add translations string
@ -228,6 +228,12 @@
{{end}}
<!-- JS Template for torrents ajax -->
<script type="text/javascript">
{{ range _, cat := GetCategories(false, true) }}
T.Add("{{ cat.ID }}", "{{ T(cat.Name) }}")
{{end}}
{{ range _, language := GetTorrentLanguages() }}
T.Add("{{ language }}", "{{ LanguageName(language, T) }}")
{{end}}
Templates.Add("torrents.item", function(torrent) {
return "<tr id=\"torrent_" + torrent.id + "\" class=\"torrent-info"+ ((torrent.status == 2) ? " remake" : ((torrent.status == 3) ? " trusted" : ((torrent.status == 3) ? " aplus" : "" )))+"\">"+
{{ if User.HasAdmin() }}
@ -242,7 +248,7 @@
"<div class=\"nyaa-cat nyaa-cat-"+ torrent.sub_category +"\">"+
{{end}}
"<a href=\"{{URL.Parse("/search?c=") }}"+ torrent.category + "_" + torrent.sub_category +"\" title=\""+ T.r(torrent.category+"_"+torrent.sub_category)+"\">"+
(torrent.languages[0] != "") ? "<a href=\"{{URL.Parse("/search?c=") }}"+ torrent.category + "_" + torrent.sub_category +"&lang=" + + "\"><img src=\"img/blank.gif\" class=\"flag flag-"+ torrent.languages[1] == "" ? flagCode(torrent.languages[0]) : ("multiple") +"\" title=\"\"></a>" : "") +
((torrent.languages[0] != "") ? "<a href=\"{{URL.Parse("/search?c=") }}"+ torrent.category + "_" + torrent.sub_category +"&lang=" + torrent.languages.join(",") +"\"><img src=\"img/blank.gif\" class=\"flag flag-"+ ((torrent.languages.length == 1) ? flagCode(torrent.languages[0]) : "multiple") +"\" title=\""+torrent.languages.map(function (el, i) { return T.r(el)}).join(",")+"\"></a>" : "") +
"</a>"+
"</div></td>"+
"<td class=\"tr-name home-td\"><a href=\"/view/"+torrent.id+"\">"+Templates.EncodeEntities(torrent.name) +"</a></td>"+