diff --git a/app/index.html b/app/index.html index 9fc44278..7d437a38 100644 --- a/app/index.html +++ b/app/index.html @@ -15,7 +15,6 @@ - diff --git a/app/js/filters.js b/app/js/filters.js index f8b30c50..98147557 100644 --- a/app/js/filters.js +++ b/app/js/filters.js @@ -172,13 +172,9 @@ angular.module('myApp.filters', ['myApp.i18n']) } }]) - .filter('relativeTime', ['$rootScope', '$filter', '$locale', '_', function($rootScope, $filter, $locale, _) { - var langMinutes = $rootScope.$eval( - _('relative_time_pluralize_minutes_ago') - ), - langHours = $rootScope.$eval( - _('relative_time_pluralize_hours_ago') - ); + .filter('relativeTime', ['$filter', '_', function($filter, _) { + var langMinutesPluralize = _.pluralize('relative_time_pluralize_minutes_ago'), + langHoursPluralize = _.pluralize('relative_time_pluralize_hours_ago'); return function (timestamp) { var ticks = timestamp * 1000, @@ -189,11 +185,11 @@ angular.module('myApp.filters', ['myApp.i18n']) } if (diff < 3000000) { var minutes = Math.ceil(diff / 60000); - return (langMinutes[$locale.pluralCat(minutes)] || '').replace('{}', minutes); + return langMinutesPluralize(minutes); } if (diff < 10000000) { var hours = Math.ceil(diff / 3600000); - return (langHours[$locale.pluralCat(hours)] || '').replace('{}', hours); + return langHoursPluralize(hours); } return $filter('dateOrTime')(timestamp); } diff --git a/app/js/i18n.js b/app/js/i18n.js index d80aabf9..4e02f554 100644 --- a/app/js/i18n.js +++ b/app/js/i18n.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('myApp.i18n', ['izhukov.utils']) - .factory('_', [function() { + .factory('_', ['$rootScope', '$locale', function($rootScope, $locale) { var locale = Config.I18n.locale; var messages = Config.I18n.messages; var fallbackMessages = Config.I18n.fallback_messages; @@ -79,6 +79,13 @@ angular.module('myApp.i18n', ['izhukov.utils']) return locale; }; + _.pluralize = function (msgid) { + var categories = $rootScope.$eval(_(msgid + '_raw')); + return function (count) { + return (categories[$locale.pluralCat(count)] || '').replace('{}', count); + } + }; + return _; }]) diff --git a/app/js/locales/en-us.json b/app/js/locales/en-us.json index 45b9ebb3..2ab7348d 100644 --- a/app/js/locales/en-us.json +++ b/app/js/locales/en-us.json @@ -47,6 +47,8 @@ "settings_modal_follow_us_twitter": "Follow us on Twitter!", "settings_modal_recent_updates": "Recent updates (ver. {version})", + "page_title_pluralize_notifications": "{'0': 'No notifications', 'one': '1 notification', 'other': '{} notifications'}", + "profile_edit_modal_title": "Edit profile", "profile_edit_first_name": "First name", "profile_edit_last_name": "Last name", diff --git a/app/js/services.js b/app/js/services.js index 091d960c..1dcbe977 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -3468,7 +3468,7 @@ angular.module('myApp.services', ['myApp.i18n']) }) -.service('NotificationsManager', function ($rootScope, $window, $timeout, $interval, $q, MtpApiManager, AppPeersManager, IdleManager, Storage, AppRuntimeManager) { +.service('NotificationsManager', function ($rootScope, $window, $timeout, $interval, $q, _, MtpApiManager, AppPeersManager, IdleManager, Storage, AppRuntimeManager) { navigator.vibrate = navigator.vibrate || navigator.mozVibrate || navigator.webkitVibrate; @@ -3478,8 +3478,9 @@ angular.module('myApp.services', ['myApp.i18n']) var notificationsCount = 0; var vibrateSupport = !!navigator.vibrate; var peerSettings = {}; - var faviconBackupEl = $('link[rel="icon"]'), + var faviconBackupEl = $('link[rel="icon"]:first'), faviconNewEl = $(''); + var langNotificationsPluralize = _.pluralize('page_title_pluralize_notifications'); var titleBackup = document.title, titlePromise; @@ -3490,7 +3491,7 @@ angular.module('myApp.services', ['myApp.i18n']) if (!newVal) { document.title = titleBackup; - $('link[rel="icon"]').replaceWith(faviconBackupEl); + $('link[rel="icon"]:first').replaceWith(faviconBackupEl); notificationsClear(); } else { titleBackup = document.title; @@ -3499,16 +3500,13 @@ angular.module('myApp.services', ['myApp.i18n']) var time = tsNow(); if (!notificationsCount || time % 2000 > 1000) { document.title = titleBackup; - var curFav = $('link[rel="icon"]'); + var curFav = $('link[rel="icon"]:first'); if (curFav.attr('href').indexOf('favicon_unread') != -1) { curFav.replaceWith(faviconBackupEl); } } else { - document.title = notificationsCount > 1 - ? (notificationsCount + ' notifications') - : '1 notification'; - - $('link[rel="icon"]').replaceWith(faviconNewEl); + document.title = langNotificationsPluralize(notificationsCount); + $('link[rel="icon"]:first').replaceWith(faviconNewEl); } }, 1000); } diff --git a/app/webogram.appcache b/app/webogram.appcache index aaf55703..f32aa44a 100644 --- a/app/webogram.appcache +++ b/app/webogram.appcache @@ -1,6 +1,6 @@ CACHE MANIFEST -# 38 +# 39 NETWORK: *