send translated strings to javascript

This commit is contained in:
Zachary Chai 2016-11-10 12:16:33 -05:00
parent c32b513d6c
commit c7d2c8f27e
7 changed files with 32 additions and 30 deletions

View File

@ -21,12 +21,12 @@
loopJoin();
} else {
sessionStatusRefresh($('.meeting-url').val());
showAlert($('.meeting-started-alert').html(), 4000);
showAlert(I18n.meeting_started, 4000);
}
}
} else if (data.action === 'meeting_ended') {
sessionStatusRefresh($('.meeting-url').val());
showAlert($('.meeting-ended-alert').html(), 4000);
showAlert(I18n.meeting_ended, 4000);
}
}
});

View File

@ -14,12 +14,12 @@
rowData.published = data.published
table.row("#"+data.record_id).data(rowData).draw();
var publish = (data.published) ? 'publish' : 'unpublish';
showAlert($('.recording-'+publish+'-alert').html(), 4000);
var published = (data.published) ? 'published' : 'unpublished';
showAlert(I18n['recording_'+published], 4000);
} else if (data.action === 'delete') {
row.remove().draw();
showAlert($('.recording-delete-alert').html(), 4000);
showAlert(I18n.recording_deleted, 4000);
}
}
});

View File

@ -59,7 +59,7 @@
html: true,
trigger: 'focus',
title: function() {
return $(".delete-popover-title").html();
return I18n.are_you_sure;
},
content: function() {
return $(".delete-popover-body").html();

View File

@ -1,2 +1,17 @@
module ApplicationHelper
def client_translations
locale = I18n.locale
if locale.length < 4
fallback_locale = I18n.fallbacks[locale].second
end
if fallback_locale
I18n.locale = fallback_locale
translations = I18n.t('.')
I18n.locale = locale
else
translations = I18n.t('.')
end
translations[:client]
end
end

View File

@ -29,9 +29,6 @@
</div>
<div hidden class="hidden-elements">
<div class="delete-popover-title">
<%= t('are_you_sure') %>
</div>
<div class="delete-popover-body">
<button type="button" class="btn btn-danger recording-delete">
<%= t('yes') %>
@ -48,19 +45,4 @@
<span class="alert-message"></span>
</div>
</div>
<div class="recording-publish-alert">
<%= t('recording_published') %>
</div>
<div class="recording-unpublish-alert">
<%= t('recording_unpublished') %>
</div>
<div class="recording-delete-alert">
<%= t('recording_deleted') %>
</div>
<div class="meeting-ended-alert">
<%= t('meeting_ended') %>
</div>
<div class="meeting-started-alert">
<%= t('meeting_started') %>
</div>
</div>

View File

@ -49,3 +49,7 @@
<!-- End of Footer -->
</body>
</html>
<script type="text/javascript">
window.I18n = <%= client_translations.to_json.html_safe %>
</script>

View File

@ -22,7 +22,13 @@
en-US:
actions: Actions
are_you: Are you %{name}?
are_you_sure: Are you sure?
client:
are_you_sure: Are you sure?
meeting_ended: Meeting was ended
meeting_started: Meeting was started
recording_deleted: Recording was deleted
recording_published: Recording was published
recording_unpublished: Recording was unpublished
date_recorded: Date Recorded
duration: Duration
end: End
@ -35,17 +41,12 @@ en-US:
join_session_user: Join %{name} session
login: login
logout: logout
meeting_ended: Meeting was ended
meeting_started: Meeting was started
my_room: my room
no: No
oauth_signup: Signup for customized sessions
past_recordings: Past Recordings
powered_bigbluebutton: Powered by BigBlueButton
presentation: Presentation
recording_deleted: Recording was deleted
recording_published: Recording was published
recording_unpublished: Recording was unpublished
refresh_html: <a href="#" class="generate-link">Click refresh</a> to generate a new meeting URL
session_url_explanation: The session will be taking place using the following URL
start: Start