CC-1960: Internationalize Airtime / Support translations

-added i18n jquery library
-created a Locale controller that returns a js dictionary of translations needed in js
-added jquery i18n wrapper function to all strings in js
This commit is contained in:
denise 2012-11-20 11:16:10 -05:00
parent b801235c99
commit 57fdab0ddf
25 changed files with 472 additions and 209 deletions

View file

@ -53,7 +53,7 @@ function findHosts(request, callback) {
var noResult = new Array();
noResult[0] = new Array();
noResult[0]['value'] = $("#add_show_hosts_autocomplete").val();
noResult[0]['label'] = "No result found";
noResult[0]['label'] = $.i18n._("No result found");
noResult[0]['index'] = null;
$.post(url,
@ -226,7 +226,7 @@ function setAddShowEvents() {
form.find(".airtime_auth_help_icon").qtip({
content: {
text: "This follows the same security pattern for the shows: only users assigned to the show can connect."
text: $.i18n._("This follows the same security pattern for the shows: only users assigned to the show can connect.")
},
hide: {
delay: 500,
@ -246,7 +246,7 @@ function setAddShowEvents() {
});
form.find(".custom_auth_help_icon").qtip({
content: {
text: "Specify custom authentication which will work only for this show."
text: $.i18n._("Specify custom authentication which will work only for this show.")
},
hide: {
delay: 500,
@ -266,7 +266,7 @@ function setAddShowEvents() {
});
form.find(".stream_username_help_icon").qtip({
content: {
text: "If your live streaming client does not ask for a username, this field should be 'source'."
text: $.i18n._("If your live streaming client does not ask for a username, this field should be 'source'.")
},
hide: {
delay: 500,
@ -628,7 +628,7 @@ $(document).ready(function() {
//Alert the error and reload the page
//this function is used to resolve concurrency issue
function alertShowErrorAndReload(){
alert("The show instance doesn't exist anymore!");
alert($.i18n._("The show instance doesn't exist anymore!"));
window.location.reload();
}

View file

@ -6,7 +6,7 @@
function scheduleRefetchEvents(json) {
if(json.show_error == true){
alert("The show instance doesn't exist anymore!");
alert($.i18n._("The show instance doesn't exist anymore!"));
}
if(json.show_id) {
var dialog_id = parseInt($("#add_show_id").val(), 10);
@ -41,7 +41,7 @@ function openAddShowForm() {
function makeAddShowButton(){
$('.fc-header-left')
.append('<span class="fc-header-space"></span>')
.append('<span class="fc-button"><a href="#" class="add-button"><span class="add-icon"></span>Show</a></span>')
.append('<span class="fc-button"><a href="#" class="add-button"><span class="add-icon"></span>'+$.i18n._("Show")+'</a></span>')
.find('span.fc-button:last > a')
.click(function(){
openAddShowForm();
@ -154,12 +154,12 @@ function viewDisplay( view ) {
var calendarEl = this;
var select = $('<select class="schedule_change_slots input_select"/>')
.append('<option value="1">1m</option>')
.append('<option value="5">5m</option>')
.append('<option value="10">10m</option>')
.append('<option value="15">15m</option>')
.append('<option value="30">30m</option>')
.append('<option value="60">60m</option>')
.append('<option value="1">'+$.i18n._("1m").'</option>')
.append('<option value="5">'+$.i18n._("5m").'</option>')
.append('<option value="10">'+$.i18n._("10m").'</option>')
.append('<option value="15">'+$.i18n._("15m").'</option>')
.append('<option value="30">'+$.i18n._("30m").'</option>')
.append('<option value="60">'+$.i18n._("60m").'</option>')
.change(function(){
var slotMin = $(this).val();
var opt = view.calendar.options;
@ -261,7 +261,7 @@ function eventRender(event, element, view) {
if (event.soundcloud_id === -1) {
$(element)
.find(".fc-event-time")
.before('<span id="'+event.id+'" title="Show is empty" class="small-icon show-empty"></span>');
.before('<span id="'+event.id+'" title="'+$.i18n._("Show is empty")+'" class="small-icon show-empty"></span>');
} else if (event.soundcloud_id > 0) {
} else if (event.soundcloud_id === -2) {
@ -275,7 +275,7 @@ function eventRender(event, element, view) {
if (event.soundcloud_id === -1) {
$(element)
.find(".fc-event-title")
.after('<span id="'+event.id+'" title="Show is empty" class="small-icon show-empty"></span>');
.after('<span id="'+event.id+'" title="'+$.i18n._("Show is empty")+'" class="small-icon show-empty"></span>');
} else if (event.soundcloud_id > 0) {
} else if (event.soundcloud_id === -2) {
@ -424,7 +424,7 @@ function addQtipToSCIcons(ele){
if($(ele).hasClass("progress")){
$(ele).qtip({
content: {
text: "Uploading in progress..."
text: $.i18n.("Uploading in progress...")
},
position:{
adjust: {
@ -442,13 +442,13 @@ function addQtipToSCIcons(ele){
}else if($(ele).hasClass("soundcloud")){
$(ele).qtip({
content: {
text: "Retreiving data from the server...",
text: $.i18n.("Retreiving data from the server..."),
ajax: {
url: baseUrl+"/Library/get-upload-to-soundcloud-status",
type: "post",
data: ({format: "json", id : id, type: "file"}),
success: function(json, status){
this.set('content.text', "The soundcloud id for this file is: "+json.sc_id);
this.set('content.text', $.i18n.("The soundcloud id for this file is: ")+json.sc_id);
}
}
},
@ -468,14 +468,14 @@ function addQtipToSCIcons(ele){
}else if($(ele).hasClass("sc-error")){
$(ele).qtip({
content: {
text: "Retreiving data from the server...",
text: $.i18n.("Retreiving data from the server..."),
ajax: {
url: baseUrl+"/Library/get-upload-to-soundcloud-status",
type: "post",
data: ({format: "json", id : id, type: "show"}),
success: function(json, status){
this.set('content.text', "There was error while uploading to soundcloud.<br>"+"Error code: "+json.error_code+
"<br>"+"Error msg: "+json.error_msg+"<br>");
this.set('content.text', $.i18n.("There was error while uploading to soundcloud.")+"<br>"+$.i18n._("Error code: ")+json.error_code+
"<br>"+$.i18n._("Error msg: ")+json.error_msg+"<br>");
}
}
},
@ -495,7 +495,7 @@ function addQtipToSCIcons(ele){
}else if ($(ele).hasClass("show-empty")){
$(ele).qtip({
content: {
text: "This show has no scheduled content."
text: $.i18n._("This show has no scheduled content.")
},
position:{
adjust: {
@ -548,7 +548,7 @@ function checkEmptyShowStatus(e) {
//Alert the error and reload the page
//this function is used to resolve concurrency issue
function alertShowErrorAndReload(){
alert("The show instance doesn't exist anymore!");
alert($.i18n.("The show instance doesn't exist anymore!"));
window.location.reload();
}

View file

@ -22,7 +22,7 @@ function checkShowLength(json) {
if (percent > 100){
$("#show_time_warning")
.text("Shows longer than their scheduled time will be cut off by a following show.")
.text($.i18n._("Shows longer than their scheduled time will be cut off by a following show."))
.show();
}
else {
@ -33,7 +33,7 @@ function checkShowLength(json) {
}
function confirmCancelShow(show_instance_id){
if (confirm('Cancel Current Show?')) {
if (confirm($.i18n._('Cancel Current Show?'))) {
var url = baseUrl+"/Schedule/cancel-current-show";
$.ajax({
url: url,
@ -46,7 +46,7 @@ function confirmCancelShow(show_instance_id){
}
function confirmCancelRecordedShow(show_instance_id){
if (confirm('Stop recording current show?')) {
if (confirm($.i18n._('Stop recording current show?'))) {
var url = baseUrl+"/Schedule/cancel-current-show";
$.ajax({
url: url,
@ -165,7 +165,7 @@ function buildScheduleDialog (json) {
close: closeDialog,
buttons: [
{
text: "Ok",
text: $.i18n._("Ok"),
"class": "btn",
click: function() {
$(this).dialog("close");
@ -207,14 +207,14 @@ function buildContentDialog (json){
dialog.dialog({
autoOpen: false,
title: "Contents of Show \"" + json.showTitle + "\"",
title: $.i18n._("Contents of Show") +" '" + json.showTitle + "'",
width: width,
height: height,
modal: true,
close: closeDialog,
buttons: [
{
text: "Ok",
text: $.i18n._("Ok"),
"class": "btn",
click: function() {
dialog.remove();
@ -283,7 +283,7 @@ function createFullCalendar(data){
//Alert the error and reload the page
//this function is used to resolve concurrency issue
function alertShowErrorAndReload(){
alert("The show instance doesn't exist anymore!");
alert($.i18n._("The show instance doesn't exist anymore!"));
window.location.reload();
}
@ -324,7 +324,7 @@ $(document).ready(function() {
if (oItems.clear !== undefined) {
callback = function() {
if (confirm("Remove all content?")) {
if (confirm($.i18n._("Remove all content?"))) {
$.post(oItems.clear.url, {format: "json", id: data.id}, function(json){
scheduleRefetchEvents(json);
});