Hello,
I am trying to figure out how to setup the Angular routing for a multi language webpage/app. In this app different languages should be accessible with a language prefix such as /en /fr etc.
Examples:
www.myapp.com <-- should redirect to the appropriate language (/en or /fr) according to some logic in a controller
www.myapp.com/some-content <-- should redirect to the appropriate language (/en/some-content or /fr/some-content) according to some logic in a controller
I guess I could do the routing this way
$routeProvider.
when('/', {
controller: 'MyController',
templateUrl: '/views/welcome.html'
}).
when('/en', {
controller: 'MyController',
templateUrl: '/views/welcome.html'
}).
when('/fr', {
controller: 'MyController',
templateUrl: '/views/welcome.html'
}).
when('/:language/some-content, {
controller: 'MyController',
templateUrl: '/views/some-content.html'
}).
when('/some-content', {
controller: 'MyController',
templateUrl: '/views/some-content.html'
}).
...
Where :language is extracted with $routeParams in MyController and used as parameter for some translation directive. But this routing doesn't feel right and gets very ugly when the number of languages and sub pages grow. How can I setup the routing in another better way?