Skip to content

Commit

Permalink
[#117] WIP: Change Language
Browse files Browse the repository at this point in the history
  • Loading branch information
javieriserte committed Aug 9, 2024
1 parent 8398797 commit dfd0e3d
Show file tree
Hide file tree
Showing 6 changed files with 452 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/home/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ angular
.controller('errorController', ['$scope', 'errorService', 'alertService', ErrorController])
.controller('headerController', ['$scope', 'userService', '$location', '$modal', 'hotkeys','appConf', HeaderController])
.service('notificationsService', ['$log','$rootScope', 'cryptoService', 'userService', NotificationsService])
.controller('notificationsController', [ '$scope', '$log', 'notificationsService', 'userService', 'inboxService', NotificationsController])
.controller('notificationsController', [ '$scope', '$log', '$i18next', 'notificationsService', 'userService', 'inboxService', NotificationsController])
.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/configuracion', {templateUrl: '/assets/javascripts/home/views/configuracion.html'});
Expand Down
17 changes: 16 additions & 1 deletion app/assets/javascripts/home/notificationsController.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
define([], function() {
'use strict';

function NotificationsController($scope, $log, notificationsService, userService, inboxService) {
function NotificationsController($scope, $log, $i18next, notificationsService, userService, inboxService) {

$scope.notiCount = 0;
$scope.stall = true;
Expand Down Expand Up @@ -52,6 +52,21 @@ function NotificationsController($scope, $log, notificationsService, userService
$scope.$apply();
});

$scope.getLanguage = function(){
return $i18next.options.lng;
};

$scope.changeLanguage = function(lang){
var nextLang = "";
if ($scope.getLanguage() === "en") {
nextLang = "es-AR";
}
if ($scope.getLanguage() === "es-AR") {
nextLang = "en";
}
$i18next.options.lng = nextLang;
};

}

return NotificationsController;
Expand Down
9 changes: 9 additions & 0 deletions app/assets/javascripts/home/views/notifications.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<ul class="nav navbar-nav" data-ng-controller="notificationsController">

<div class="centered-text" title="Cambio de Idioma">
<span
href="#/home"
ng-click="changeLanguage()">
<i class="bold" ng-if="getLanguage() === 'en'" title="English">EN</i>
<i class="bold" ng-if="getLanguage() === 'es-AR'" title="Español">ES</i>
</span>
</div>

<div class="not-profile" title="Notificaciones">

<a href="#/home" class="dropdown-toggle icon-stack" data-ng-class="{'noti-counter' : notiCount > 0 }">
Expand Down
10 changes: 10 additions & 0 deletions app/assets/stylesheets/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -538,4 +538,14 @@ fieldset[disabled] .btn-link-border {
//border-radius: 3px;
//margin-right: 5px;
color: #0d9564;
}

.centered-text {
display: flex;
justify-content: center; /* Centers horizontally */
align-items: center; /* Centers vertically */
}

.centered-text:hover {
cursor: pointer; /* Changes the cursor to a hand icon */
}
Loading

0 comments on commit dfd0e3d

Please sign in to comment.