Cleaned up RTL support, added RTL support to language select screen

This commit is contained in:
Rick Falkvinge
2015-02-06 19:34:25 +01:00
parent 772f59f1b6
commit 1c87439e16
7 changed files with 64 additions and 19 deletions
+1 -1
View File
@@ -114,7 +114,7 @@
</script>
</head>
<body>
<body class='<asp:Literal ID="LiteralBodyClass" runat="server" />'>
<form id="form1" runat="server">
<script type="text/javascript">
//Put your JavaScript code here.
+9
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Runtime.Serialization;
@@ -169,6 +170,14 @@ namespace Swarmops
{
this.LiteralDocumentReadyHook.Text = string.Empty;
}
// Enable support for RTL languages
if (Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft)
{
this.LiteralBodyClass.Text = "rtl";
}
}
private void SetupDropboxes()
+18 -1
View File
@@ -64,6 +64,23 @@
height: 48px;
}
div.divLanguageEncapsulation {
direction: ltr;
}
div.divLanguageEncapsulation.rtl {
direction: rtl;
}
div.divLanguageEncapsulation.rtl div.divLanguageFlag {
float: right;
background-position: right;
padding-left: inherit;
padding-right: 2px;
margin-left: inherit;
margin-right: 4px;
}
div.spanLanguageNativeName {
padding-top: 10px;
font-size: 24px;
@@ -79,7 +96,7 @@
<hr/>
<asp:Repeater runat="server" ID="RepeaterLanguages">
<ItemTemplate>
<div class="divLanguageEncapsulation" onclick="document.location='/Pages/v5/User/SetCulture.aspx?CultureId=<%# Eval("CultureId") %>';">
<div class='divLanguageEncapsulation <%#Eval("Rtl") %>' onclick="document.location='/Pages/v5/User/SetCulture.aspx?CultureId=<%# Eval("CultureId") %>';">
<div class="divLanguageFlag" style="background-image:url('<%# Eval("IconUrl")%>')" ></div>
<div class="spanLanguageNativeName"><%# Eval("DisplayName") %></div>
</div>
+10 -4
View File
@@ -28,7 +28,7 @@ namespace Swarmops.Frontend.Pages.v5.User
private void PopulateRepeater()
{
string[] availableCultures = {"ar-SA", "sv-SE", "nl-NL", "ru-RU"};
string[] availableCultures = {"ar-AE", "sv-SE", "nl-NL", "ru-RU"};
Array.Sort (availableCultures);
// sort by locale string, and that's ok, that happens to give the same result as sorting on country name
@@ -44,16 +44,21 @@ namespace Swarmops.Frontend.Pages.v5.User
newLanguage.DisplayName = Char.ToUpperInvariant (newLanguage.DisplayName[0]) +
newLanguage.DisplayName.Substring (1); // Capitalize
if (cultureId.StartsWith ("en"))
if (cultureId.StartsWith("en"))
{
newLanguage.IconUrl = "/Images/Flags/uk-64px.png";
// use "uk" for en-GB and en-US rather than "gb" or "us"
}
else if (cultureId.StartsWith ("ar"))
if (cultureId.StartsWith("ar"))
{
newLanguage.IconUrl = "/Images/Flags/ae-64px.png";
// The culture is ar-SA but we're not giving Saudi Arabia the light of day here
// crowdin's generic culture is ar-SA but we're not showing the SA flag
}
if (culture.TextInfo.IsRightToLeft)
{
newLanguage.Rtl = "rtl";
}
availableLanguages.Add (newLanguage);
}
@@ -63,6 +68,7 @@ namespace Swarmops.Frontend.Pages.v5.User
private class LanguageParameters
{
public string Rtl { get; set; }
public string IconUrl { get; set; }
public string CultureId { get; set; }
public string DisplayName { get; set; }
+7
View File
@@ -10,6 +10,13 @@ namespace Swarmops.Frontend.Pages.v5.User
protected void Page_Load (object sender, EventArgs e)
{
string cultureId = Request.QueryString["CultureId"];
// Arabic: We present ar-AE but need to set ar-SA for dumb reasons
if (cultureId == "ar-AE")
{
cultureId = "ar-SA";
}
Response.SetCookie(new HttpCookie("PreferredCulture", cultureId));
AuthenticationData authenticationData = GetAuthenticationDataAndCulture();
+12 -6
View File
@@ -49,6 +49,12 @@ strong
}
/* RTL */
body.rtl {
direction: rtl;
}
/* MAIN WRAPPERY */
@@ -80,7 +86,7 @@ div.break
width: 400px;
}
[style*="rtl"] .logoimage
body.rtl .logoimage
{
float: right;
}
@@ -115,7 +121,7 @@ div.currentuserinfo
font-size:14px;
}
[style*="rtl"] div.currentuserinfo {
body.rtl div.currentuserinfo {
float: left;
}
@@ -160,7 +166,7 @@ img
left:-5px;
}
[style*="rtl"] .searchbox {
body.rtl .searchbox {
float: left;
left: 5px;
}
@@ -182,7 +188,7 @@ img
font-family: Ubuntu, Liberation Sans, Arial, Helvetica, Sans-Serif;
}
[style*="rtl"] .searchbox input {
body.rtl .searchbox input {
padding-left: inherit;
padding-right: 26px;
background-position-x: right;
@@ -209,7 +215,7 @@ img
width: 700px;
}
[style*="rtl"] .mainbar {
body.rtl .mainbar {
float: right;
}
@@ -220,7 +226,7 @@ img
margin-left: 20px;
}
[style*="rtl"] .sidebar {
body.rtl .sidebar {
float: left;
}
+7 -7
View File
@@ -16,7 +16,7 @@
z-index: 9990;
}
[style*="rtl"] .sf-menu ul { /* RTL override */
body.rtl .sf-menu ul { /* RTL override */
left: inherit;
right: 0;
}
@@ -25,7 +25,7 @@
float: left;
}
[style*="rtl"] .sf-menu > li { /* RTL override */
body.rtl .sf-menu > li { /* RTL override */
float: right;
}
@@ -48,7 +48,7 @@
left: 100%;
}
[style*="rtl"] .sf-menu ul ul { /* RTL override*/
body.rtl .sf-menu ul ul { /* RTL override*/
left: inherit;
right: 100%;
}
@@ -62,7 +62,7 @@
margin-left: 14px;
}
[style*="rtl"] .sf-menu {
body.rtl .sf-menu {
float: right;
margin-left: inherit;
margin-right: 14px;
@@ -89,7 +89,7 @@
padding: 2px 10px 8px 12px;
}
[style*="rtl"] .sf-menu ul a
body.rtl .sf-menu ul a
{
padding: 2px 12px 8px 10px;
}
@@ -125,7 +125,7 @@
left: -4px;
}
[style*="rtl"] .sf-menu ul li img
body.rtl .sf-menu ul li img
{
left: 4px;
}
@@ -147,7 +147,7 @@
padding-left: 20px; /* no icon */
}
[style*="rtl"] .sf-menu li.Submenu li.Submenu { /* Right-to-left override */
body.rtl .sf-menu li.Submenu li.Submenu { /* Right-to-left override */
background: #FF0044 url('/Style/submenu-leftarrow.png') no-repeat right top; /* testing selector */
padding-left: inherit;
padding-right: 20px; /* no icon */