Skip to content

Commit

Permalink
Merge pull request #3 from deepu105/sendilkumarn-ng2-translate
Browse files Browse the repository at this point in the history
ng2 translate updates
  • Loading branch information
sendilkumarn authored Oct 11, 2016
2 parents 0d8c091 + e6412f2 commit d19d609
Show file tree
Hide file tree
Showing 31 changed files with 318 additions and 270 deletions.
6 changes: 4 additions & 2 deletions generators/client-2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,6 @@ module.exports = JhipsterClientGenerator.extend({

this.template(ANGULAR_DIR + 'shared/model/account.model.ts', ANGULAR_DIR + 'shared/model/account.model.ts', this, {});

this.template(ANGULAR_DIR + 'shared/pipe/translate.pipe.ts', ANGULAR_DIR + 'shared/pipe/translate.pipe.ts', this, {});
this.template(ANGULAR_DIR + 'shared/pipe/keys.pipe.ts', ANGULAR_DIR + 'shared/pipe/keys.pipe.ts', this, {});
this.template(ANGULAR_DIR + 'shared/pipe/filter.pipe.ts', ANGULAR_DIR + 'shared/pipe/filter.pipe.ts', this, {});
this.template(ANGULAR_DIR + 'shared/pipe/order-by.pipe.ts', ANGULAR_DIR + 'shared/pipe/order-by.pipe.ts', this, {});
Expand All @@ -501,7 +500,6 @@ module.exports = JhipsterClientGenerator.extend({
this.template(ANGULAR_DIR + 'shared/directive/maxbytes.directive.ts', ANGULAR_DIR + 'shared/directive/maxbytes.directive.ts', this, {});
this.template(ANGULAR_DIR + 'shared/directive/minbytes.directive.ts', ANGULAR_DIR + 'shared/directive/minbytes.directive.ts', this, {});
this.template(ANGULAR_DIR + 'shared/directive/number-of-bytes.ts', ANGULAR_DIR + 'shared/directive/number-of-bytes.ts', this, {});
this.template(ANGULAR_DIR + 'shared/directive/jhi-translate.ts', ANGULAR_DIR + 'shared/directive/jhi-translate.ts', this, {});

this.template(ANGULAR_DIR + 'shared/service/date-util.service.ts', ANGULAR_DIR + 'shared/service/date-util.service.ts', this, {});
this.template(ANGULAR_DIR + 'shared/service/data-util.service.ts', ANGULAR_DIR + 'shared/service/data-util.service.ts', this, {});
Expand All @@ -515,13 +513,16 @@ module.exports = JhipsterClientGenerator.extend({
this.template(ANGULAR_DIR + 'shared/_shared-common.ng2module.ts', ANGULAR_DIR + 'shared/shared-common.ng2module.ts', this, {});
//components
if (this.enableTranslation) {
this.template(ANGULAR_DIR + 'shared/language/jhi-translate.directive.ts', ANGULAR_DIR + 'shared/language/jhi-translate.directive.ts', this, {});
this.template(ANGULAR_DIR + 'shared/language/translate-partial-loader.provider.ts', ANGULAR_DIR + 'shared/language/translate-partial-loader.provider.ts', this, {});
this.template(ANGULAR_DIR + 'shared/language/_language.pipe.ts', ANGULAR_DIR + 'shared/language/language.pipe.ts', this, {});
this.template(ANGULAR_DIR + 'shared/language/_language.constants.ts', ANGULAR_DIR + 'shared/language/language.constants.ts', this, {});
this.template(ANGULAR_DIR + 'shared/language/_language.service.ts', ANGULAR_DIR + 'shared/language/language.service.ts', this, {});
this.template(ANGULAR_DIR + 'shared/language/_jhi-missing-translation.config.ts', ANGULAR_DIR + 'shared/language/jhi-missing-translation.config.ts', this, {});
}
this.copyHtml(ANGULAR_DIR + 'shared/login/login.html', ANGULAR_DIR + 'shared/login/login.html');
this.template(ANGULAR_DIR + 'shared/login/_login.service.ts', ANGULAR_DIR + 'shared/login/login.service.ts', this, {});
this.template(ANGULAR_DIR + 'shared/login/_login-modal.service.ts', ANGULAR_DIR + 'shared/login/login-modal.service.ts', this, {});
this.template(ANGULAR_DIR + 'shared/login/_login.component.ts', ANGULAR_DIR + 'shared/login/login.component.ts', this, {});

//alert service code
Expand All @@ -535,6 +536,7 @@ module.exports = JhipsterClientGenerator.extend({
// services
this.template(ANGULAR_DIR + 'shared/auth/_auth.service.ts', ANGULAR_DIR + 'shared/auth/auth.service.ts', this, {});
this.template(ANGULAR_DIR + 'shared/auth/_csrf.service.ts', ANGULAR_DIR + 'shared/auth/csrf.service.ts', this, {});
this.template(ANGULAR_DIR + 'shared/auth/_state-storage.service.ts', ANGULAR_DIR + 'shared/auth/state-storage.service.ts', this, {});
this.template(ANGULAR_DIR + 'shared/auth/_principal.service.ts', ANGULAR_DIR + 'shared/auth/principal.service.ts', this, {});
this.template(ANGULAR_DIR + 'shared/auth/_has-authority.directive.ts', ANGULAR_DIR + 'shared/auth/has-authority.directive.ts', this, {});
this.template(ANGULAR_DIR + 'shared/auth/_has-any-authority.directive.ts', ANGULAR_DIR + 'shared/auth/has-any-authority.directive.ts', this, {});
Expand Down
2 changes: 1 addition & 1 deletion generators/client-2/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@angular/platform-browser": "2.0.1",
"@angular/platform-browser-dynamic": "2.0.1",
"@angular/upgrade": "2.0.1",
"@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.6",
"@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.7",
"angular-ui-router": "1.0.0-beta.3",
"core-js": "2.4.1",
"jquery": "3.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { NgModule } from '@angular/core';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { UIRouterModule } from 'ui-router-ng2';

import { <%=angular2AppName%>SharedModule } from '../shared';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, Inject, OnInit } from '@angular/core';
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';

import { Activate } from './activate.service';
import { LoginService } from "../../shared";
import { LoginModalService } from "../../shared";

@Component({
selector: 'activate',
Expand All @@ -13,10 +13,11 @@ export class ActivateComponent implements OnInit {
success: string;
modalRef: NgbModalRef;

constructor(private activate: Activate,
private loginService : LoginService,
@Inject('$stateParams') private $stateParams
) {}
constructor(
private activate: Activate,
private loginModalService : LoginModalService,
@Inject('$stateParams') private $stateParams
) {}

ngOnInit () {
this.activate.get(this.$stateParams.key).subscribe(() => {
Expand All @@ -28,7 +29,7 @@ export class ActivateComponent implements OnInit {
});
}

login(template) {
this.modalRef = this.loginService.open(template);
login() {
this.modalRef = this.loginModalService.open();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h1 translate="activate.title">Activation</h1>

<div class="alert alert-success" *ngIf="success" translate="activate.messages.success" translate-compile>
<strong>Your user has been activated.</strong> Please <a class="alert-link" (click)="login(loginModal)">sign in</a>.
<strong>Your user has been activated.</strong> Please <a class="alert-link" (click)="login()">sign in</a>.
</div>

<div class="alert alert-danger" *ngIf="error" translate="activate.messages.error">
Expand All @@ -14,7 +14,3 @@ <h1 translate="activate.title">Activation</h1>
</div>
</div>
</div>
<!-- this is a workaround untill ng-bootstrap supports components as modal content https://github.com/ng-bootstrap/ng-bootstrap/issues/680 -->
<template #loginModal let-dismiss="dismiss">
<<%=jhiPrefix%>-login-modal [modalRef]="modalRef" [dismiss]="dismiss"></<%=jhiPrefix%>-login-modal>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, OnInit, Inject, Renderer, ElementRef } from '@angular/core';
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';

import { PasswordResetFinish } from './password-reset-finish.service';
import { LoginService } from "../../../shared";
import { LoginModalService } from "../../../shared";

@Component({
selector: 'password-reset-finish',
Expand All @@ -18,7 +18,7 @@ export class PasswordResetFinishComponent implements OnInit {
modalRef: NgbModalRef;

constructor(private passwordResetFinish: PasswordResetFinish,
private loginService : LoginService,
private loginModalService : LoginModalService,
@Inject('$stateParams') private $stateParams,
private elementRef: ElementRef, private renderer: Renderer
) {}
Expand Down Expand Up @@ -49,7 +49,7 @@ export class PasswordResetFinishComponent implements OnInit {
}
}

login(template) {
this.modalRef = this.loginService.open(template);
login() {
this.modalRef = this.loginModalService.open();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1 translate="reset.finish.title">Reset password</h1>
</div>

<div class="alert alert-success" *ngIf="success">
<p translate="reset.finish.messages.success" translate-compile><strong>Your password has been reset.</strong> Please <a class="alert-link" (click)="login(loginModal)">sign in</a>.</p>
<p translate="reset.finish.messages.success" translate-compile><strong>Your password has been reset.</strong> Please <a class="alert-link" (click)="login()">sign in</a>.</p>
</div>

<div class="alert alert-danger" *ngIf="doNotMatch" translate="global.messages.error.dontmatch">
Expand Down Expand Up @@ -74,7 +74,3 @@ <h1 translate="reset.finish.title">Reset password</h1>
</div>
</div>
</div>
<!-- this is a workaround untill ng-bootstrap supports components as modal content https://github.com/ng-bootstrap/ng-bootstrap/issues/680 -->
<template #loginModal let-dismiss="dismiss">
<<%=jhiPrefix%>-login-modal [modalRef]="modalRef" [dismiss]="dismiss"></<%=jhiPrefix%>-login-modal>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, OnInit, Inject, Renderer, ElementRef } from '@angular/core';
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';

import { Register } from './register.service';
import { LoginService } from "../../shared";
import { LoginModalService } from "../../shared";

@Component({
selector: '<%=jhiPrefix%>-register',
Expand All @@ -21,7 +21,7 @@ export class RegisterComponent implements OnInit {

constructor(
@Inject('$translate') private $translate,
private loginService : LoginService,
private loginModalService : LoginModalService,
private registerService: Register,
private elementRef: ElementRef,
private renderer: Renderer) {
Expand Down Expand Up @@ -62,7 +62,7 @@ export class RegisterComponent implements OnInit {
}
}

openLogin(template) {
this.modalRef = this.loginService.open(template);
openLogin() {
this.modalRef = this.loginModalService.open();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ <h1 translate="register.title">Registration</h1>
</form>
<p></p>
<div class="alert alert-warning" translate="global.messages.info.authenticated" translate-compile>
If you want to <a class="alert-link" (click)="openLogin(loginModal)">sign in</a>, you can try the default accounts:<br/>- Administrator (login="admin" and password="admin") <br/>- User (login="user" and password="user").
If you want to <a class="alert-link" (click)="openLogin()">sign in</a>, you can try the default accounts:<br/>- Administrator (login="admin" and password="admin") <br/>- User (login="user" and password="user").
</div>
</div>
<%_ if (enableSocialSignIn) { _%>
Expand All @@ -132,7 +132,3 @@ <h1 translate="register.title">Registration</h1>
<%_ } _%>
</div>
</div>
<!-- this is a workaround untill ng-bootstrap supports components as modal content https://github.com/ng-bootstrap/ng-bootstrap/issues/680 -->
<template #loginModal let-dismiss="dismiss">
<<%=jhiPrefix%>-login-modal [modalRef]="modalRef" [dismiss]="dismiss"></<%=jhiPrefix%>-login-modal>
</template>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { NgModule } from '@angular/core';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { UIRouterModule } from 'ui-router-ng2';

import { <%=angular2AppName%>SharedModule, ParseLinks } from '../shared';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, OnInit, Inject } from '@angular/core';
import { StateService } from "ui-router-ng2";
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';

import { Account, LoginService, Principal } from "../shared";
import { Account, LoginModalService, Principal } from "../shared";

@Component({
selector: 'home',
Expand All @@ -12,9 +12,11 @@ export class HomeComponent implements OnInit {
account: Account;
modalRef: NgbModalRef;

constructor(private principal: Principal,
private $state: StateService,
private loginService : LoginService){}
constructor(
private principal: Principal,
private $state: StateService,
private loginModalService : LoginModalService
) {}

ngOnInit() {
this.principal.identity().then((account) => {
Expand All @@ -30,7 +32,7 @@ export class HomeComponent implements OnInit {
this.$state.go('register');
}

login(template) {
this.modalRef = this.loginService.open(template);
login() {
this.modalRef = this.loginModalService.open();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ export const homeState = {
resolve: [{
token: 'translate',
deps: [JhiLanguageService],
resolveFn: (jhiLanguageService) => jhiLanguageService.setLocation('home')
resolveFn: (jhiLanguageService) => jhiLanguageService.setLocations(['home'])
}]
}
33 changes: 15 additions & 18 deletions generators/client-2/templates/src/main/webapp/app/home/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,40 @@
<span class="hipster img-responsive img-rounded"></span>
</div>
<div class="col-md-8">
<h1 [jhiTranslate]="'home.title' | translate">Welcome, Java Hipster!</h1>
<p class="lead" translate="home.subtitle">This is your homepage</p>
<h1 jhi-translate="home.title">Welcome, Java Hipster!</h1>
<p class="lead" jhi-translate="home.subtitle">This is your homepage</p>

<div [ngSwitch]="isAuthenticated()">
<div class="alert alert-success" *ngSwitchCase="true" translate="home.logged.message">
<span *ngIf="account"> You are logged in as user "{{account.login}}". </span>
<div class="alert alert-success" *ngSwitchCase="true">
<span *ngIf="account" jhi-translate="home.logged.message"
translate-values="{username: &quot;{{account.login}}&quot;}"> You are logged in as user "{{account.login}}". </span>
</div>

<div class="alert alert-warning" *ngSwitchCase="false" translate="global.messages.info.authenticated" translate-compile>
If you want to <a class="alert-link" href="" (click)="login(loginModal)">sign in</a>, you can try the default accounts:<br/>- Administrator (login="admin" and password="admin") <br/>- User (login="user" and password="user").
<div class="alert alert-warning" *ngSwitchCase="false" jhi-translate="global.messages.info.authenticated" translate-compile>
If you want to <a class="alert-link" href="" (click)="login()">sign in</a>, you can try the default accounts:<br/>- Administrator (login="admin" and password="admin") <br/>- User (login="user" and password="user").
</div>


<div class="alert alert-warning" *ngSwitchCase="false" translate="global.messages.info.register" translate-compile>
<div class="alert alert-warning" *ngSwitchCase="false" jhi-translate="global.messages.info.register" translate-compile>
You don't have an account yet? <a class="alert-link" uiSref="register">Register a new account</a>
</div>
</div>

<p translate="home.question">
<p jhi-translate="home.question">
If you have any question on JHipster:
</p>

<ul>
<li><a href="http://jhipster.github.io/" target="_blank" translate="home.link.homepage">JHipster homepage</a></li>
<li><a href="http://stackoverflow.com/tags/jhipster/info" target="_blank" translate="home.link.stackoverflow">JHipster on Stack Overflow</a></li>
<li><a href="https://github.com/jhipster/generator-jhipster/issues?state=open" target="_blank" translate="home.link.bugtracker">JHipster bug tracker</a></li>
<li><a href="https://gitter.im/jhipster/generator-jhipster" target="_blank" translate="home.link.chat">JHipster public chat room</a></li>
<li><a href="https://twitter.com/java_hipster" target="_blank" translate="home.link.follow">follow @java_hipster on Twitter</a></li>
<li><a href="http://jhipster.github.io/" target="_blank" jhi-translate="home.link.homepage">JHipster homepage</a></li>
<li><a href="http://stackoverflow.com/tags/jhipster/info" target="_blank" jhi-translate="home.link.stackoverflow">JHipster on Stack Overflow</a></li>
<li><a href="https://github.com/jhipster/generator-jhipster/issues?state=open" target="_blank" jhi-translate="home.link.bugtracker">JHipster bug tracker</a></li>
<li><a href="https://gitter.im/jhipster/generator-jhipster" target="_blank" jhi-translate="home.link.chat">JHipster public chat room</a></li>
<li><a href="https://twitter.com/java_hipster" target="_blank" jhi-translate="home.link.follow">follow @java_hipster on Twitter</a></li>
</ul>

<p>
<span translate="home.like">If you like JHipster, don't forget to give us a star on </span>&nbsp;<a href="https://github.com/jhipster/generator-jhipster" target="_blank" translate="home.github">Github</a>!
<span jhi-translate="home.like">If you like JHipster, don't forget to give us a star on </span>&nbsp;<a href="https://github.com/jhipster/generator-jhipster" target="_blank" jhi-translate="home.github">Github</a>!
</p>
</div>
</div>
</div>
<!-- this is a workaround untill ng-bootstrap supports components as modal content https://github.com/ng-bootstrap/ng-bootstrap/issues/680 -->
<template #loginModal let-dismiss="dismiss">
<<%=jhiPrefix%>-login-modal [modalRef]="modalRef" [dismiss]="dismiss"></<%=jhiPrefix%>-login-modal>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { StateService } from "ui-router-ng2";
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';

import { ProfileService } from '../profiles/profile.service'; //barrel doesnt work here
import { <% if (enableTranslation){ %><%=jhiPrefixCapitalized%>LanguageService, <% } %>Principal, AuthService, LoginService } from '../../shared';
import { <% if (enableTranslation){ %><%=jhiPrefixCapitalized%>LanguageService, <% } %>Principal, LoginModalService, LoginService } from '../../shared';

@Component({
selector: 'navbar',
Expand All @@ -24,7 +24,7 @@ export class NavbarComponent implements OnInit {
private languageService: <%=jhiPrefixCapitalized%>LanguageService,
<%_ } _%>
private principal: Principal,
private authService: AuthService,
private loginModalService: LoginModalService,
private profileService: ProfileService
) { }

Expand Down Expand Up @@ -55,13 +55,13 @@ export class NavbarComponent implements OnInit {
return this.principal.isAuthenticated();
}

login(template) {
this.modalRef = this.loginService.open(template);
login() {
this.modalRef = this.loginModalService.open();
}

logout() {
this.collapseNavbar();
this.authService.logout();
this.loginService.logout();
this.$state.go('home');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
</a>
</li>
<li *ngSwitchCase="false">
<a (click)="login(loginModal)" id="login">
<a (click)="login()" id="login">
<span class="glyphicon glyphicon-log-in"></span>&nbsp;
<span translate="global.menu.account.login">Sign in</span>
</a>
Expand Down Expand Up @@ -184,7 +184,3 @@
</div>
</div>
</nav>
<!-- this is a workaround untill ng-bootstrap supports components as modal content https://github.com/ng-bootstrap/ng-bootstrap/issues/680 -->
<template #loginModal let-dismiss="dismiss">
<<%=jhiPrefix%>-login-modal [modalRef]="modalRef" [dismiss]="dismiss"></<%=jhiPrefix%>-login-modal>
</template>
Loading

0 comments on commit d19d609

Please sign in to comment.