Erdem Çetin Erdem Çetin - 1 year ago 153
AngularJS Question

AngularJS how to use browser language detection?

Hi I get text from database with http.get .How to get with browser detection ? How to use if clause ? I don't want to use translate.toogle()

var mainCtrl = function ($scope, $http, $sce, $location,$timeout,$routeParams, toastr) {

$scope.showPage = false;
$scope.showPage = true;

$scope.trustedHtml = function (plainText) {
return $sce.trustAsHtml(plainText);


##### if browser En_en
$scope.about = r.text_en;

##### if browser De_de
$scope.about = r.text_de;


Answer Source

You can get the browser language using navigator.language:

var lang = $window.navigator.language || $window.navigator.userLanguage; 
if (lang === 'en-US') {
  console.log("language is english");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download