Hey there! I'm currently working on an Angularjs application that will be available in both Arabic and English. Below is the logic I have implemented for selecting the language: If the browser's default language is set to Arabic, then the website will display in Arabic. If the browser's default language is not Arabic, then the website will display in English.
In addition, I have included images (one for Arabic and one for English) on the website to allow users to switch between languages.
<div class="language"><a href="#"><img src="images/arabic.png"></a></div>
<div class="language"><a href="#"><img src="images/en-english-language-browser-function-512.png"></a></div>
Currently, there are two anchor tags present. I am working on binding the image to the anchor tag based on the selected language, but I would prefer to have only one anchor tag.
app.controller('RoslpAppController', ['$scope', '$translate', 'toastr', '$window', function ($scope, $translate, toastr, $window) {
debugger;
var lang = $window.navigator.language || $window.navigator.userLanguage;
if (lang === 'ar-sa')
{
$translate.use('de_AR');
//bind arabic.png
}
else
{
$translate.use('de_EN');
//bind english.png
}
}]);
I am fairly new to the world of Angular development. Can anyone provide some guidance on how to accomplish this task? Any assistance would be greatly appreciated. Thank you!