Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get current language with angular-translate

Is there a way to get the current used language in a controller (without $translateProvider)?

Couldn't find anything in the $translate service.

like image 200
jviotti Avatar asked Dec 07 '13 17:12

jviotti


Video Answer


2 Answers

$translate.use() is a getter and setter.

See this demo found in links of docs:

http://jsfiddle.net/PascalPrecht/eUGWJ/7/

like image 141
charlietfl Avatar answered Sep 19 '22 05:09

charlietfl


$translate.use() is the way to go. Also, when an asynchronous loader is executed, you might wanna use $translate.proposedLanguage() which returns the language key of the language that is currently loaded but not finished loaded yet.

like image 30
Pascal Precht Avatar answered Sep 23 '22 05:09

Pascal Precht