diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-15 14:44:48 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-15 14:44:48 +0200 |
commit | 01d6e6a3df56008d6fe684720e5be6de5f3ef7b2 (patch) | |
tree | 3c2b1c383ae58b585478eebcf265b1ece34b7fa7 /js/app/services | |
parent | cdbafe0555fae50d7ab99f0c95573d2c3cacb97b (diff) |
show real date on hover, more robust check for language support for relative dates
Diffstat (limited to 'js/app/services')
-rw-r--r-- | js/app/services/language.coffee | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/js/app/services/language.coffee b/js/app/services/language.coffee index ac46b0bc4..c8b93cc06 100644 --- a/js/app/services/language.coffee +++ b/js/app/services/language.coffee @@ -26,10 +26,71 @@ angular.module('News').factory 'Language', -> constructor: -> @_language = 'en' + @_langs = [ + 'ar-ma' + 'ar' + 'bg' + 'ca' + 'cs' + 'cv' + 'da' + 'de' + 'el' + 'en-ca' + 'en-gb' + 'eo' + 'es' + 'et' + 'eu' + 'fi' + 'fr-ca' + 'fr' + 'gl' + 'he' + 'hi' + 'hu' + 'id' + 'is' + 'it' + 'ja' + 'ka' + 'ko' + 'lv' + 'ms-my' + 'nb' + 'ne' + 'nl' + 'pl' + 'pt-br' + 'pt' + 'ro' + 'ru' + 'sk' + 'sl' + 'sv' + 'th' + 'tr' + 'tzm-la' + 'tzm' + 'uk' + 'zh-cn' + 'zh-tw' + ] handle: (data) -> - @_language = data.split('_')[0] + # fix broken server locales + data = data.replace('_', '-').toLowerCase() + + # check if the first part is available, if so use this + if not (data in @_langs) + data = data.split('-')[0] + + # if its not available default to english + if not (data in @_langs) + data = 'en' + + @_language = data getLanguage: -> |