1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

added web client localization

This commit is contained in:
Luke Pulverenti 2014-03-30 22:33:10 -04:00
parent 1f1dcf80c1
commit 371dd1454a
13 changed files with 158 additions and 36 deletions

View file

@ -18,11 +18,6 @@
<form class="advancedServerSettingsForm"> <form class="advancedServerSettingsForm">
<ul data-role="listview" class="ulForm"> <ul data-role="listview" class="ulForm">
<li>
<label for="txtServerName">Friendly server name:</label>
<input id="txtServerName" data-mini="true" />
<div class="fieldDescription">This name will be used to identify this server. If left blank, the computer name will be used.</div>
</li>
<li> <li>
<label for="txtPortNumber">Http server port number: </label> <label for="txtPortNumber">Http server port number: </label>
<input type="number" id="txtPortNumber" name="txtPortNumber" pattern="[0-9]*" required="required" min="1" data-mini="true" /> <input type="number" id="txtPortNumber" name="txtPortNumber" pattern="[0-9]*" required="required" min="1" data-mini="true" />

View file

@ -11,6 +11,7 @@
<div data-role="controlgroup" data-type="horizontal" class="localnav" data-mini="true"> <div data-role="controlgroup" data-type="horizontal" class="localnav" data-mini="true">
<a href="#" data-role="button" class="ui-btn-active">Home</a> <a href="#" data-role="button" class="ui-btn-active">Home</a>
<a href="dashboardgeneral.html" data-role="button">General</a>
<a href="dashboardinfopage.html" data-role="button">Info</a> <a href="dashboardinfopage.html" data-role="button">Info</a>
</div> </div>

View file

@ -0,0 +1,56 @@
<!DOCTYPE html>
<html>
<head>
<title>Dashboard</title>
</head>
<body>
<div id="dashboardGeneralPage" data-role="page" class="page type-interior adminPage dashboardHomePage">
<div data-role="content">
<div class="content-primary">
<div data-role="controlgroup" data-type="horizontal" class="localnav" data-mini="true">
<a href="dashboard.html" data-role="button">Home</a>
<a href="#" data-role="button" class="ui-btn-active">General</a>
<a href="dashboardinfopage.html" data-role="button">Info</a>
</div>
<form class="dashboardGeneralForm">
<ul data-role="listview" class="ulForm">
<li>
<label for="txtServerName">Friendly server name:</label>
<input id="txtServerName" data-mini="true" />
<div class="fieldDescription">This name will be used to identify this server. If left blank, the computer name will be used.</div>
</li>
<li>
<label for="selectLocalizationLanguage">Preferred display language</label>
<select id="selectLocalizationLanguage" data-mini="true">
</select>
<div class="fieldDescription">Translating Media Browser is an ongoing project. Read about how <a href="http://mediabrowser3.com/community/index.php?/topic/5727-join-our-translation-team/" target="_blank">you can contribute</a>.</div>
</li>
</ul>
<ul data-role="listview" class="ulForm">
<li>
<button type="submit" data-theme="b" data-icon="check" data-mini="true">
Save
</button>
<button type="button" onclick="Dashboard.navigate('dashboard.html');" data-icon="delete" data-mini="true">
Cancel
</button>
</li>
</ul>
</form>
</div>
</div>
<script type="text/javascript">
$('.dashboardGeneralForm').off('submit', DashboardGeneralPage.onSubmit).on('submit', DashboardGeneralPage.onSubmit);
</script>
</div>
</body>
</html>

View file

@ -12,6 +12,7 @@
<div data-role="controlgroup" data-type="horizontal" class="localnav" data-mini="true"> <div data-role="controlgroup" data-type="horizontal" class="localnav" data-mini="true">
<a href="dashboard.html" data-role="button">Home</a> <a href="dashboard.html" data-role="button">Home</a>
<a href="dashboardgeneral.html" data-role="button">General</a>
<a href="#" data-role="button" class="ui-btn-active">Info</a> <a href="#" data-role="button" class="ui-btn-active">Info</a>
</div> </div>

View file

@ -14,7 +14,6 @@
$('#txtPortNumber', page).val(config.HttpServerPortNumber); $('#txtPortNumber', page).val(config.HttpServerPortNumber);
$('#txtDdns', page).val(config.WanDdns || ''); $('#txtDdns', page).val(config.WanDdns || '');
$('#txtServerName', page).val(config.ServerName || '');
$('#chkEnableUpnp', page).checked(config.EnableUPnP).checkboxradio('refresh'); $('#chkEnableUpnp', page).checked(config.EnableUPnP).checkboxradio('refresh');
@ -53,7 +52,6 @@
config.EnableUPnP = $('#chkEnableUpnp', form).checked(); config.EnableUPnP = $('#chkEnableUpnp', form).checked();
config.WanDdns = $('#txtDdns', form).val(); config.WanDdns = $('#txtDdns', form).val();
config.ServerName = $('#txtServerName', form).val();
ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult); ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult);
}); });

View file

@ -0,0 +1,55 @@
(function ($, document, window) {
function loadPage(page, config, languageOptions) {
$('#txtServerName', page).val(config.ServerName || '');
$('#selectLocalizationLanguage', page).html(languageOptions.map(function (l) {
return '<option value="' + l.Value + '">' + l.Name + '</option>';
})).val(config.UICulture).selectmenu('refresh');
Dashboard.hideLoadingMsg();
}
$(document).on('pageshow', "#dashboardGeneralPage", function () {
Dashboard.showLoadingMsg();
var page = this;
var promise1 = ApiClient.getServerConfiguration();
var promise2 = $.getJSON(ApiClient.getUrl("Localization/Options"));
$.when(promise1, promise2).done(function (response1, response2) {
loadPage(page, response1[0], response2[0]);
});
});
window.DashboardGeneralPage = {
onSubmit: function () {
Dashboard.showLoadingMsg();
var form = this;
ApiClient.getServerConfiguration().done(function (config) {
config.ServerName = $('#txtServerName', form).val();
config.UICulture = $('#selectLocalizationLanguage', form).val();
ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission
return false;
}
};
})(jQuery, document, window);

View file

@ -36,7 +36,7 @@ $.fn.checked = function (value) {
} }
}; };
$.fn.buttonEnabled = function(enabled) { $.fn.buttonEnabled = function (enabled) {
return enabled ? this.attr('disabled', '').removeAttr('disabled') : this.attr('disabled', 'disabled'); return enabled ? this.attr('disabled', '').removeAttr('disabled') : this.attr('disabled', 'disabled');
}; };
@ -133,7 +133,7 @@ var WebNotifications = {
} }
}, },
supported: function() { supported: function () {
return window.Notification || window.webkitNotifications; return window.Notification || window.webkitNotifications;
} }
}; };
@ -461,3 +461,19 @@ function ticks_to_human(str) {
}); });
})(); })();
(function (window) {
// Mimic Globalize api
// https://github.com/jquery/globalize
// Maybe later switch to it
window.Globalize = {
translate: function (key) {
return window.localizationGlossary[key] || key;
}
};
})(window);

View file

@ -12,7 +12,7 @@
$('#featureAccessFields', page).show(); $('#featureAccessFields', page).show();
} }
Dashboard.setPageTitle(user.Name || "Add User"); Dashboard.setPageTitle(user.Name || Globalize.translate("AddUser"));
$('#txtUserName', page).val(user.Name); $('#txtUserName', page).val(user.Name);
@ -40,7 +40,7 @@
Dashboard.validateCurrentUser(page); Dashboard.validateCurrentUser(page);
if (userId) { if (userId) {
Dashboard.alert("Settings saved."); Dashboard.alert(Globalize.translate("SettingsSaved"));
} else { } else {
Dashboard.navigate("userprofiles.html"); Dashboard.navigate("userprofiles.html");
} }

View file

@ -53,15 +53,15 @@
switch (evt.target.error.code) { switch (evt.target.error.code) {
case evt.target.error.NOT_FOUND_ERR: case evt.target.error.NOT_FOUND_ERR:
Dashboard.showError('File Not Found!'); Dashboard.showError(Globalize.translate("FileNotFound"));
break; break;
case evt.target.error.NOT_READABLE_ERR: case evt.target.error.NOT_READABLE_ERR:
Dashboard.showError('File is not readable'); Dashboard.showError(Globalize.translate("FileReadError"));
break; break;
case evt.target.error.ABORT_ERR: case evt.target.error.ABORT_ERR:
break; // noop break; // noop
default: default:
Dashboard.showError('An error occurred reading this file.'); Dashboard.showError(Globalize.translate("FileReadError"));
}; };
} }
@ -73,7 +73,7 @@
function onFileReaderAbort(evt) { function onFileReaderAbort(evt) {
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
Dashboard.showError('File read cancelled'); Dashboard.showError(Globalize.translate("FileReadCancelled"));
} }
function setFiles(page, files) { function setFiles(page, files) {
@ -156,7 +156,7 @@
self.deleteImage = function () { self.deleteImage = function () {
Dashboard.confirm("Are you sure you wish to delete the image?", "Delete Image", function (result) { Dashboard.confirm(Globalize.translate("DeleteImageConfirmation"), Globalize.translate("DeleteImage"), function (result) {
if (result) { if (result) {

View file

@ -134,7 +134,7 @@
Dashboard.validateCurrentUser(page); Dashboard.validateCurrentUser(page);
Dashboard.alert("Settings saved."); Dashboard.alert(Globalize.translate("SettingsSaved"));
} }
function saveUser(user, page) { function saveUser(user, page) {

View file

@ -15,7 +15,7 @@
} else { } else {
$('#btnResetPassword', page).hide(); $('#btnResetPassword', page).hide();
$('#fldCurrentPassword', page).hide(); $('#fldCurrentPassword', page).hide();
$('.formheader', page).html('Create Password').show(); $('.formheader', page).html(Globalize.translate("CreatePassword")).show();
} }
}); });
@ -36,7 +36,7 @@
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
Dashboard.alert("Password saved."); Dashboard.alert(Globalize.translate("PasswordSaved"));
loadUser(page); loadUser(page);
}); });
@ -53,7 +53,7 @@
if ($('#txtNewPassword', page).val() != $('#txtNewPasswordConfirm', page).val()) { if ($('#txtNewPassword', page).val() != $('#txtNewPasswordConfirm', page).val()) {
Dashboard.showError("Password and password confirmation must match."); Dashboard.showError(Globalize.translate("PasswordMatchError"));
return false; return false;
} }
@ -68,11 +68,11 @@
self.resetPassword = function () { self.resetPassword = function () {
var msg = "Are you sure you wish to reset the password?"; var msg = Globalize.translate("PasswordResetConfirmation");
var page = $.mobile.activePage; var page = $.mobile.activePage;
Dashboard.confirm(msg, "Password Reset", function (result) { Dashboard.confirm(msg, Globalize.translate("PasswordResetHeader"), function (result) {
if (result) { if (result) {
var userId = getParameterByName("userId"); var userId = getParameterByName("userId");
@ -84,8 +84,8 @@
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
Dashboard.alert({ Dashboard.alert({
message: "The password has been reset.", message: Globalize.translate("PasswordResetComplete"),
title: "Password Reset" title: Globalize.translate("PasswordResetHeader")
}); });
loadUser(page); loadUser(page);

View file

@ -14,7 +14,7 @@
var html = ""; var html = "";
html += '<li data-role="list-divider"><h3>Users</h3></li>'; html += '<li data-role="list-divider"><h3>' + Globalize.translate("Users") + '</h3></li>';
for (var i = 0, length = users.length; i < length; i++) { for (var i = 0, length = users.length; i < length; i++) {
@ -41,15 +41,15 @@
html += "</h3>"; html += "</h3>";
html += "<p class='ui-li-aside'>"; html += "<p class='ui-li-aside'>";
if (user.Configuration.HasPassword) html += '<img src="css/images/userdata/password.png" alt="Password" title="Password" class="userProfileIcon" />'; if (user.Configuration.HasPassword) html += '<img src="css/images/userdata/password.png" alt="' + Globalize.translate("Password") + '" title="' + Globalize.translate("Password") + '" class="userProfileIcon" />';
if (user.Configuration.IsAdministrator) html += '<img src="css/images/userdata/administrator.png" alt="Administrator" title="Administrator" class="userProfileIcon" />'; if (user.Configuration.IsAdministrator) html += '<img src="css/images/userdata/administrator.png" alt="' + Globalize.translate("Administrator") + '" title="' + Globalize.translate("Administrator") + '" class="userProfileIcon" />';
html += "</p>"; html += "</p>";
html += "</a>"; html += "</a>";
html += "<a onclick='UserProfilesPage.deleteUser(this);' data-userid='" + user.Id + "' data-username='" + user.Name + "' href='#'>Delete</a>"; html += "<a onclick='UserProfilesPage.deleteUser(this);' data-userid='" + user.Id + "' data-username='" + user.Name + "' href='#'>" + Globalize.translate("Delete") + "</a>";
html += "</li>"; html += "</li>";
} }
@ -64,9 +64,9 @@
var page = $.mobile.activePage; var page = $.mobile.activePage;
var name = link.getAttribute('data-username'); var name = link.getAttribute('data-username');
var msg = "Are you sure you wish to delete " + name + "?"; var msg = Globalize.translate("DeleteUserConfirmation").replace('{0}', name);
Dashboard.confirm(msg, "Delete User", function (result) { Dashboard.confirm(msg, Globalize.translate("DeleteUser"), function (result) {
if (result) { if (result) {
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();

View file

@ -29,7 +29,7 @@
Dashboard.validateCurrentUser(page); Dashboard.validateCurrentUser(page);
if (userId) { if (userId) {
Dashboard.alert("Settings saved."); Dashboard.alert(Globalize.translate("SettingsSaved"));
} else { } else {
Dashboard.navigate("userprofiles.html"); Dashboard.navigate("userprofiles.html");
} }