Tuesday, 15 March 2011

angularjs - Angular Js Ui Routing 404 with language preserved -



angularjs - Angular Js Ui Routing 404 with language preserved -

i building international app, , plan has been language first part of url. of routes have urls "/{lang}/home", or "/{lang}/product/{id}" in them.

i understand otherwise can't perchance seek figure out state variable language because go site munging url after domain etc. otherwise puts them downwards /en/404. hoping if example, user makes typo error "/es/hom" recognize provided language code, can't figure out routing beyond , send them /es/404.

the next stab @ in route configuration, isn't working well.

$urlrouterprovider.otherwise('/en/404');//if url impossible set them in english language 404 $urlrouterprovider.when("/{lang}/*", "/{lang}/404");//attempt lang/404 if can discern language $urlrouterprovider.when('/', '/en/home');//if land @ site en/home

as going right now, land on /en/404 if url invalid. doesn't surprise me, hoping first when statement clever plenty if user browse mysite.com/es/hom @ to the lowest degree recognize trying utilize spanish , send them /es/404.

have tried this?

.config(function($routeprovider, $locationprovider) { $routeprovider .when('/:lang', { templateurl: 'lang.html', controller: 'languagectrl' }).otherwise('/:lang/404.html')}; });

angularjs routing internationalization http-status-code-404 angular-ui-router

No comments:

Post a Comment