Comments (4)
@sanathpathiraja if you want to globally include translate
pipe, add it to APPLICATION_PIPES
array in src\platform\browser\pipes.ts
. In this case, you won't need to import and explicitly register the pipe in each component.
from ngx-admin.
yes i did that.
app/index.ts
// App
import {AppState} from "./app.state";
import {TRANSLATE_PROVIDERS,
TranslateService,
TranslateLoader,
TranslateStaticLoader} from 'ng2-translate/ng2-translate';
import {provide} from '@angular/core';
import {Http} from '@angular/http';
export * from './app.component';
// Application wide providers
export const APP_PROVIDERS = [
AppState,
provide(TranslateLoader, {
useFactory: (http: Http) => new TranslateStaticLoader(http, 'assets/i18n', '.json'),
deps: [Http]
}),
TRANSLATE_PROVIDERS,
TranslateService
];
app.component.ts
import {TRANSLATE_PROVIDERS, TranslateService, TranslatePipe, TranslateLoader, TranslateStaticLoader} from 'ng2-translate/ng2-translate';
export class App {
isMenuCollapsed:boolean = false;
constructor(private _state:AppState, private _imageLoader:BaImageLoaderService, private _spinner:BaThemeSpinner, translate: TranslateService) {
translate.setDefaultLang('en');
but translate not working.
can you help me?
from ngx-admin.
@sanathpathiraja still you haven't loaded the pipe globally, here the minimal steps:
- install the module
- in
src/platform/broswers/pipes.ts
addtranslate
pipe like this:
import {TranslatePipe} from 'ng2-translate/ng2-translate';
// application_pipes: pipes that are global through out the application
export const APPLICATION_PIPES = [
TranslatePipe // <----- add the pipe HERE
];
// the rest of the code
- in
src/platform/broswers/providers.ts
addTRANSLATE_PROVIDERS
like this:
import {TRANSLATE_PROVIDERS} from 'ng2-translate/ng2-translate';
/*
* Application Providers/Directives/Pipes
* providers/directives/pipes that only live in our browser environment
*/
export const APPLICATION_PROVIDERS = [
...FORM_PROVIDERS,
...HTTP_PROVIDERS,
...ROUTER_PROVIDERS,
TRANSLATE_PROVIDERS, // <--- HERE the providers
{provide: LocationStrategy, useClass: HashLocationStrategy }
];
// the rest of the code
- now use it in any template you need to
from ngx-admin.
yes, I added that after I change
src/main.browser.js
`export function main(initialHmrState?: any): Promise {
return bootstrap(App, [
...PROVIDERS,
...ENV_PROVIDERS,
...DIRECTIVES,
...PIPES,
...APP_PROVIDERS,
HTTP_PROVIDERS,
provide(TranslateLoader, {
useFactory: (http: Http) => new TranslateStaticLoader(http, 'assets/i18n', '.json'),
deps: [Http]
}),
// use TranslateService here, and not TRANSLATE_PROVIDERS (which will define a default TranslateStaticLoader)
TranslateService
])
.catch(err => console.error(err));`
after run it perfectly.
thanks @nnixaa
from ngx-admin.
Related Issues (20)
- Ngx admin install - Version: 10 with Angular 14+ installation error - FIX HOT 10
- Tests are hanging indefinitely
- Unable to scroll for calendar where datepicker is towards end of page HOT 2
- Template ionic Angular
- how to add new links or items in sidebar HOT 1
- - 🔫 I ...
- updated the ngx-admin to the latest version and added nx workspace to it
- where is the cash icon? HOT 1
- Repository state and engagement with the community HOT 2
- while installing i am getting an error. please help asap HOT 4
- How to implement table with row detail?
- Upgrade to Angular 16
- Upgrade to Angular 16 HOT 4
- NbOAuth2AuthStrategy show errors from login response
- 01
- my starter-kit [is not an issue]
- Failing to build HOT 1
- Failing to build HOT 1
- 如何食用ngx-admin
- How to change the left-side menu default language? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-admin.