working on asynch translation handling
This commit is contained in:
parent
1649ff34f5
commit
9deaed9406
4 changed files with 29 additions and 22 deletions
|
@ -93,7 +93,7 @@
|
|||
"Anonymous":
|
||||
"Anonym",
|
||||
"Avatar generated from IP address":
|
||||
"Anvatar (generiert aus der IP-Adresse)",
|
||||
"Avatar (generiert aus der IP-Adresse)",
|
||||
"Add comment":
|
||||
"Kommentar hinzufügen",
|
||||
"Optional nickname…":
|
||||
|
|
|
@ -416,7 +416,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
}
|
||||
|
||||
// if no translation string cannot be found (in translations object)
|
||||
if (!translations.hasOwnProperty(messageId)) {
|
||||
if (!translations.hasOwnProperty(messageId) || language === null) {
|
||||
// if language is still loading and we have an elemt assigned
|
||||
if (language === null && $element !== null) {
|
||||
// handle the error by attaching the language loaded event
|
||||
|
@ -432,9 +432,9 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
// file is loaded
|
||||
}
|
||||
|
||||
// for all other langauges than English for which thsi behaviour
|
||||
// for all other langauges than English for which this behaviour
|
||||
// is expected as it is built-in, log error
|
||||
if (language !== 'en') {
|
||||
if (language !== null && language !== 'en') {
|
||||
console.error('Missing translation for: \'' + messageId + '\' in language ' + language);
|
||||
// fallback to English
|
||||
}
|
||||
|
@ -463,7 +463,13 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
|
||||
// if $element is given, apply text to element
|
||||
if ($element !== null) {
|
||||
$element.text(output);
|
||||
// get last text node of element
|
||||
var content = $element.contents();
|
||||
if (content.length > 1) {
|
||||
content[content.length - 1].nodeValue = ' ' + output;
|
||||
} else {
|
||||
$element.text(output);
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -1070,13 +1076,10 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
|
||||
// show text
|
||||
if (args !== null) {
|
||||
// get last text node of element
|
||||
var content = $element.contents();
|
||||
if (content.length > 1) {
|
||||
content[content.length - 1].nodeValue = ' ' + I18n._(args);
|
||||
} else {
|
||||
$element.text(I18n._(args));
|
||||
}
|
||||
// add jQuery object to it as first parameter
|
||||
args.unshift($element);
|
||||
// pass it to I18n
|
||||
I18n._.apply(this, args);
|
||||
}
|
||||
|
||||
// show notification
|
||||
|
@ -1144,7 +1147,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
*/
|
||||
me.showRemaining = function(message)
|
||||
{
|
||||
console.error('remaining message shown: ', message);
|
||||
console.log('remaining message shown: ', message);
|
||||
handleNotification(1, $remainingTime, message);
|
||||
}
|
||||
|
||||
|
@ -1360,7 +1363,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
'This document will expire in %d ' + expiration[1] + 's.'
|
||||
];
|
||||
|
||||
Alert.showRemaining(expirationLabel, expiration[0]);
|
||||
Alert.showRemaining([expirationLabel, expiration[0]]);
|
||||
$remainingTime.removeClass('foryoureyesonly')
|
||||
} else {
|
||||
// never expires
|
||||
|
@ -2283,10 +2286,11 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
Helper.urls2links($commentEntryData);
|
||||
|
||||
// set nickname
|
||||
if (nickname.length > 0){
|
||||
if (nickname.length > 0) {
|
||||
$commentEntry.find('span.nickname').text(nickname);
|
||||
} else {
|
||||
$commentEntry.find('span.nickname').html('<i>' + I18n._('Anonymous') + '</i>');
|
||||
$commentEntry.find('span.nickname').html('<i></i>');
|
||||
I18n._($commentEntry.find('span.nickname i'), 'Anonymous');
|
||||
}
|
||||
|
||||
// set date
|
||||
|
@ -2297,10 +2301,13 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
// if an avatar is available, display it
|
||||
if (comment.meta.vizhash) {
|
||||
$commentEntry.find('span.nickname')
|
||||
.before(
|
||||
'<img src="' + comment.meta.vizhash + '" class="vizhash" title="' +
|
||||
I18n._('Avatar generated from IP address') + '" /> '
|
||||
);
|
||||
.before(
|
||||
'<img src="' + comment.meta.vizhash + '" class="vizhash" /> '
|
||||
);
|
||||
$(document).on('languageLoaded', function () {
|
||||
$commentEntry.find('img.vizhash')
|
||||
.prop('title', I18n._('Avatar generated from IP address'));
|
||||
});
|
||||
}
|
||||
|
||||
// finally append comment
|
||||
|
|
|
@ -69,7 +69,7 @@ if ($MARKDOWN):
|
|||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-Twits2in/YkEGNmhvYLmBl6zBKLtymFOzwAqxcJHQ0zJBpXCvxxmbIoW0LUWnzTq2hUtPgjAMZznSU2xkMPjjQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYpK88nUEIgIruOud+YW0LKt+V+PVZZ1OEuO6SF49Yo6Dl0q/DCjJlHQ+RhSgkuexdSnpE9+ira9GJ1wih+e5A==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
|
|
|
@ -47,7 +47,7 @@ if ($MARKDOWN):
|
|||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-Twits2in/YkEGNmhvYLmBl6zBKLtymFOzwAqxcJHQ0zJBpXCvxxmbIoW0LUWnzTq2hUtPgjAMZznSU2xkMPjjQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYpK88nUEIgIruOud+YW0LKt+V+PVZZ1OEuO6SF49Yo6Dl0q/DCjJlHQ+RhSgkuexdSnpE9+ira9GJ1wih+e5A==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
|
|
Loading…
Reference in a new issue