Email recording now translates correctly (#809)

This commit is contained in:
Ahmad Farhat 2019-10-10 15:08:55 -04:00 committed by Jesus Federico
parent 073400b51b
commit 4a791ae0b5
2 changed files with 13 additions and 7 deletions

View File

@ -28,9 +28,15 @@ function getLocalizedString(key) {
var translated = I18n
// Search current language for the key
keyArr.forEach(function(k) {
translated = translated[k]
})
try {
keyArr.forEach(function(k) {
translated = translated[k]
})
} catch (e) {
// Key is missing in selected language so default to english
translated = undefined;
}
// If key is not found, search the fallback language for the key
if (translated === undefined) {

View File

@ -26,10 +26,10 @@ $(document).on('turbolinks:load', function(){
// Handle recording emails.
$('.email-link').each(function(){
$(this).click(function(){
var subject = $(".username").text() + " " + t('room.mailer.subject');
var body = t('room.mailer.body') + "\n\n" + $(this).attr("data-pres-link");
var autogenerated = t('room.mailer.autogenerated') + "\n";
var footer = t('room.mailer.footer');
var subject = $(".username").text() + " " + getLocalizedString('javascript.room.mailer.subject');
var body = getLocalizedString('javascript.room.mailer.body') + "\n\n" + $(this).attr("data-pres-link");
var autogenerated = getLocalizedString('javascript.room.mailer.autogenerated') + "\n";
var footer = getLocalizedString('javascript.room.mailer.footer');
var url = "mailto:?subject=" + encodeURIComponent(subject) + "&body=" + encodeURIComponent(body) + encodeURIComponent(autogenerated) + encodeURIComponent(footer);
var win = window.open(url, '_blank');