Skip to content

Commit

Permalink
Added RTL Locale support (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersevenrud committed Sep 8, 2016
1 parent d0528fb commit f379057
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/client/javascript/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,20 @@
* @param {String} s Locale name
*/
API.setLocale = function _apiSetLocale(l) {
var RTL = API.getConfig('LocaleOptions.RTL', []);

if ( OSjs.Locales[l] ) {
CurrentLocale = l;
} else {
console.warn('API::setLocale()', 'Invalid locale', l, '(Using default)');
CurrentLocale = DefaultLocale;
}

var major = CurrentLocale.split('_')[0];
var html = document.querySelector('html');
if ( html ) {
html.setAttribute('lang', l);
html.setAttribute('dir', RTL.indexOf(major) !== -1 ? 'rtl' : 'ltr');
}

console.info('API::setLocale()', CurrentLocale);
Expand Down
2 changes: 1 addition & 1 deletion src/client/javascript/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@
var curLocale = API.getConfig('Locale');
var detectedLocale = Utils.getUserLocale();

if ( API.getConfig('LocaleDetect', true) && detectedLocale ) {
if ( API.getConfig('LocaleOptions.AutoDetect', true) && detectedLocale ) {
console.info('Auto-detected user locale via browser', detectedLocale);
curLocale = detectedLocale;
}
Expand Down
9 changes: 9 additions & 0 deletions src/client/stylesheets/gui.css
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,15 @@ gui-menu.gui-root-menu {
top : 0;
bottom : 0;
}
html[dir="rtl"] gui-menu > .gui-menu-expand:after {
right : auto;
left : 0;

-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg);
}

/*gui-menu > gui-menu-entry:hover {
}*/
Expand Down
29 changes: 26 additions & 3 deletions src/client/stylesheets/theme.less
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ corewm-panel .PanelItemWindowList li.Focused {
corewm-panel .PanelItemWindowList li img {
margin-right : @gui_base_padding;
}
html[dir="rtl"] corewm-panel .PanelItemWindowList li img {
margin-right : 0;
margin-left : @gui_base_padding;
}

/* Notifications */
application-splash {
Expand Down Expand Up @@ -384,9 +388,9 @@ application-window-top {
width: @window_top_height;
}
}
application-window-content {
overflow : hidden;
}

/* application-window-content {overflow : hidden;}*/

application-window-top:active {
cursor : move;
cursor : pointer;
Expand Down Expand Up @@ -1078,6 +1082,12 @@ gui-menu {
gui-menu > gui-menu-entry.gui-menu-expand {
padding-right : 16px;
}
html[dir="rtl"] gui-menu > gui-menu-entry.gui-menu-expand {
padding-right : 0;
}
html[dir="rtl"] gui-menu > gui-menu-entry[data-icon] {
padding-right : 16px;
}
gui-menu > gui-menu-entry.gui-menu-expand:after {
content : '';
font-family : sans-serif;
Expand All @@ -1096,6 +1106,9 @@ gui-menu {
gui-menu > gui-menu-entry {
background-position : @gui_base_padding center;
}
html[dir="rtl"] gui-menu > gui-menu-entry {
background-position : right @gui_base_padding center;
}
gui-menu > gui-menu-entry > label.gui-has-image {
padding-left : 22px;
}
Expand Down Expand Up @@ -1207,9 +1220,19 @@ gui-list-view {
padding-left : 24px;
background-position : @gui_base_padding;
}
html[dir="rtl"] gui-list-view gui-list-view-column.gui-has-image {
padding-left : 0;
padding-right : 24px;
background-position : right @gui_base_padding center;
}

gui-list-view[data-icon-size="32"] gui-list-view-column.gui-has-image {
padding-left : 40px;
}
html[dir="rtl"] gui-list-view[data-icon-size="32"] gui-list-view-column.gui-has-image {
padding-left : 0;
padding-right : 40px;
}

gui-list-view-row.gui-active {
background-color: @gui_selected_blur_background_color;
Expand Down
5 changes: 4 additions & 1 deletion src/conf/110-languages.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"client" : {
"Locale": "en_EN",
"LocaleDetect": true,
"LocaleOptions" : {
"AutoDetect": true,
"RTL": ["az", "he", "uz", "zh"]
},
"Languages": {
"en_EN": "English",
"bg_BG": "Bulgarian (Bulgaria)",
Expand Down

0 comments on commit f379057

Please sign in to comment.