Hi, we also have to implement this feature. 
We're using angular-translate and ngRoute.

How would be the best way to change the language specified in the route? 
Maybe listen to routeChange and then call the angular-translate to change 
the language, is that the a reasonable way to deal with this?
Why do I have to deal this in the controller, like you suggested?

On Sunday, May 25, 2014 3:07:45 AM UTC-3, Daphne Maddox wrote:
>
> I'm going to sound like a broken record here, but this seems like a 
> perfect use case for a combination of ui-router and angular-translate. 
>  (Maybe you can do this with ngRoute, I don't know, never used it).  I do 
> know that in ui-router it's really easy to set up the path segment that 
> represents the language as a parameter in the url matcher (e.g. 
> '/mypath/:lang/mypage'.  From there, you have the chosen language available 
> in your controller as a value of the $params service, and can easily set 
> the preferred language for angular-translate to provide the correct text...
>
>
> On Friday, May 23, 2014 3:51:20 PM UTC-7, Mahmoud Abdel-Fattah wrote:
>>
>> Hey Adrian, it is almost one year but I could not find any resource 
>> online for the same question. So, may I ask how did you solve this issue?
>>
>> On Friday, August 30, 2013 5:00:41 PM UTC+2, Adrian wrote:
>>>
>>> Thanks! Will check it out
>>>
>>> Den fredagen den 30:e augusti 2013 kl. 16:58:23 UTC+2 skrev Martin Alix:
>>>>
>>>> BTW, with Node, I use https://github.com/jeresig/i18n-node-2 to manage 
>>>> my translations...
>>>>
>>>> On Friday, August 30, 2013 10:55:48 AM UTC-4, Adrian wrote:
>>>>>
>>>>> Thank you everyone. Server side seems like a good way to go. Not the 
>>>>> least to be able to bootstrap angular with the language files already 
>>>>> loaded (as they are retrieved from a backend). 
>>>>>
>>>>> Best
>>>>> Adrian
>>>>>
>>>>>
>>>>> Den onsdagen den 28:e augusti 2013 kl. 09:07:03 UTC+2 skrev Adrian:
>>>>>>
>>>>>> 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/en <--- welcome page in English
>>>>>> www.myapp.com/fr <-- welcome page in French
>>>>>> www.myapp.com <-- should redirect to the appropriate language (/en 
>>>>>> or /fr) according to some logic in a controller
>>>>>>
>>>>>> www.myapp.com/en/some-content <-- a sub page in English
>>>>>> www.myapp.com/fr/some-content <-- the same subpage in French
>>>>>> 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?
>>>>>>
>>>>>>
>>>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to