Comments (11)
I have a potential fix for this here: https://github.com/cywolf/localize-router/tree/fix-151
from localize-router.
Hi @dragorwyin that is strange your case is very similar with mine and the solution by @CyWolf worked for me, did you check your routing configuration to see if there is something wrong? are you able to create a example to reproduce your problem?
from localize-router.
Hi @CyWolf just tested that changes and it seems to fix the problem that I described. Did you reported this problem previously on this repository? Asking to see if there is more discussion about the problem reported.
Did you try to create a pull request of your change to this greentube/localize-router? I verified that your solution fix my problem but I don't know if it will break something else.
from localize-router.
@JoseCMRocha Hiya, I haven't reported the issue separately, and haven't created a PR as I don't have time to add unit test(s) as the moment.
from localize-router.
@CyWolf Your solution not working for me when I have translated first slug in path, for example: /en/register/token and /pl/rejestracja/token. After language change it moves me into /pl/rejestracja without handling :token parameter. Even if I did fork and just copied your file. It's huge bug for me actually :?
from localize-router.
@JoseCMRocha Here is a reproduction:
I have a app-routing.module.ts file with simple configuration:
import { Routes } from '@angular/router';
import { FullComponent } from './core/layouts/full/full.component';
import { BlankComponent } from './core/layouts/blank/blank.component';
import { NotFoundComponent } from './modules/not-found/not-found.component';
import { LoginComponent } from './modules/login/login.component';
import { AuthGuardConfirmed } from './core/guard/auth-guard-confirmed.service';
export const routes: Routes = [
{
path: '',
component: FullComponent,
canLoad: [AuthGuardConfirmed],
}, {
path: '',
component: BlankComponent,
children: [{
path: 'login',
component: LoginComponent
}, {
path: 'register',
loadChildren: './modules/register/register.module#RegisterModule',
}]
},
{ path: '404', component: NotFoundComponent },
{ path: '**', redirectTo: '/404' }
];
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { FullComponent } from './core/layouts/full/full.component';
import { BlankComponent } from './core/layouts/blank/blank.component';
import { NotFoundComponent } from './modules/not-found/not-found.component';
import { LoginComponent } from './modules/login/login.component';
import { AuthGuardConfirmed } from './core/guard/auth-guard-confirmed.service';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { HttpClientModule, HttpClient } from '@angular/common/http';
import { TranslateModule, TranslateService, TranslateLoader } from '@ngx-translate/core';
import { LocalizeRouterModule, LocalizeRouterSettings, LocalizeParser } from 'localize-router';
import { LocalizeRouterHttpLoader } from 'localize-router-http-loader';
import { routes } from './app-routing.module';
import { RouterModule } from '@angular/router';
import { Location } from '@angular/common';
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http);
}
@NgModule({
declarations: [
AppComponent,
BlankComponent,
NotFoundComponent,
FullComponent,
LoginComponent,
],
imports: [
BrowserModule,
BrowserAnimationsModule,
HttpClientModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
LocalizeRouterModule.forRoot(routes, {
parser: {
provide: LocalizeParser,
useFactory: (translate, location, settings, http) =>
new LocalizeRouterHttpLoader(translate, location, settings, http),
deps: [TranslateService, Location, LocalizeRouterSettings, HttpClient]
}
}),
RouterModule.forRoot(routes)
],
providers: [
AuthGuardConfirmed,
],
bootstrap: [AppComponent]
})
export class AppModule { }
register.routing.ts:
import { Routes, RouterModule } from '@angular/router';
import { RegisterComponent } from './register.component';
import { ConfirmComponent } from './confirm/confirm.component';
export const routes: Routes = [
{
path: '',
children: [{
path: '',
component: RegisterComponent
}, {
path: ':token',
component: ConfirmComponent
}]
}
];
export const RegisterRoutes = RouterModule.forChild(routes);
register.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { routes } from './register.routing';
import { MaterialModule } from '../../shared/material.module';
import { SharedModule } from '../../shared/shared.module';
import { ComponentsModule } from '../../components/components.module';
import { RegisterComponent } from './register.component';
import { ConfirmComponent } from './confirm/confirm.component';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { LocalizeRouterModule } from 'localize-router';
import { RouterModule } from '@angular/router';
@NgModule({
imports: [
CommonModule,
SharedModule,
MaterialModule,
ComponentsModule,
TranslateModule,
LocalizeRouterModule.forChild(routes),
RouterModule.forChild(routes)
],
declarations: [
RegisterComponent,
ConfirmComponent,
],
})
export class RegisterModule { }
I have translations in assets/i18n (pl.json and en.json):
- pl.json: "{ ROUTES.register": "rejestracja" }",
- en.json: "{ ROUTES.register": "register" }",
I have an locales.json in assets:
{
"locales": [
"en",
"pl"
],
"prefix": "ROUTES."
}
I hope there will be any solution and will be implemented soon in this library ;P
There is also another problem: I cannot translate child name, for example: /pl/rejestracja/potwierdz is an translation of /en/register/confirm. I tried translate confirm
slug without any success. Tried use
- { ROUTES.confirm: "potwierdz" },
- { ROUTES.register.confirm: "potwierdz" } and
- { ROUTES.register.confirm: "rejestracja/potwierdz" } without success.
from localize-router.
Hi, just wondering when @CyWolf is going to be merged to fix this issue?
from localize-router.
@MarcARoberge as @CyWolf does not have time for tests, I just created a PR from his fork. We need this fix.
from localize-router.
any news on this?
from localize-router.
Are there any plans for this?
from localize-router.
for a patch see #159 (comment)
from localize-router.
Related Issues (20)
- localize-router not working as expected with Angular Universal: server-side rendering HOT 6
- Localize router unable to pass data params on an empty path HOT 2
- Out of sync localize pipe HOT 1
- changeLanguage does not work for route with parameters HOT 6
- After language is switch, back button redirect into 404
- InitialNavigation enabled crashes Routing HOT 7
- Lazy loaded component is not bootstrapping HOT 4
- can't trigger window.load
- Angular 8 + IVy support HOT 1
- Can't make it, need tutorial. HOT 1
- Angular recognize only the default lang in SSR. HOT 4
- Angular 8 support HOT 6
- Extra slash translating root route
- LazyLoad Child Componenter onPage Refresh re-directs:Home Page HOT 1
- Unhandled promise rejection HOT 6
- Custom Cookies expiration
- Children routes issue lazy load module HOT 5
- Problem with Initial Navigation in RouterModule HOT 4
- LocalizeRouterModule.forRoot returns a ModuleWithProviders type without a generic type argument HOT 20
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 localize-router.