Last active
August 29, 2015 14:10
-
-
Save gsans/84d783ad514e20fda82a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//language module | |
angular.module(‘myapp.language’, [‘pascalprecht.translate’]) | |
.config(function($httpProvider, $translateProvider) { | |
… //seen before | |
}) | |
// Service definition | |
.factory(‘Language’, function ($translate) { | |
//add the languages you support here. ar stands for arabic | |
var rtlLanguages = [‘ar’]; | |
var isRtl = function() { | |
var languageKey = $translate.proposedLanguage() || $translate.use(); | |
for (var i=0; i<rtlLanguages.length; i+=1) { | |
// You may need to change this logic depending on your supported languages (possible languageKey values) | |
// This code will match both "ar", "ar-XXX" locales. It won't match any other languages as we only support en, es, ar. | |
if (languageKey.indexOf(rtlLanguages[i])>-1) | |
return true; | |
} | |
return false; | |
}; | |
//public api | |
return { | |
isRtl: isRtl | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment