From e28e47eae5b1294f43d9d5bcdc04030006526c73 Mon Sep 17 00:00:00 2001 From: Roman Anasal Date: Wed, 10 Sep 2014 17:30:33 +0200 Subject: [PATCH] integrated i18n in all modules every string in the modules to be displayed should now be passed through `_` first --- app/js/controllers.js | 19 +++++++++++-------- app/js/directives.js | 24 ++++++++++++++++-------- app/js/filters.js | 42 +++++++++++++++++++++--------------------- app/js/lib/config.js | 2 +- app/js/services.js | 40 ++++++++++++++++++++-------------------- 5 files changed, 69 insertions(+), 58 deletions(-) diff --git a/app/js/controllers.js b/app/js/controllers.js index f598c59f..40a0a527 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -23,7 +23,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) ChangelogNotifyService.checkUpdate(); }) - .controller('AppLoginController', function ($scope, $rootScope, $location, $timeout, $modal, $modalStack, MtpApiManager, ErrorService, NotificationsManager, ChangelogNotifyService, IdleManager) { + .controller('AppLoginController', function ($scope, $rootScope, $location, $timeout, $modal, $modalStack, MtpApiManager, ErrorService, NotificationsManager, ChangelogNotifyService, IdleManager, _) { $modalStack.dismissAll(); IdleManager.start(); @@ -96,10 +96,10 @@ angular.module('myApp.controllers', ['myApp.i18n']) for (i = 0; i < Config.CountryCodes.length; i++) { country = Config.CountryCodes[i]; if (country[0] == countryIso2) { - return selectCountry({name: country[1], code: country[2]}); + return selectCountry({name: _(country[1] + '_raw'), code: country[2]}); } } - return selectCountry({name: 'United States', code: '+1'}); + return selectCountry({name: _('country_select_modal_country_us_raw'), code: '+1'}); } function selectCountry (country) { @@ -130,7 +130,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) code = Config.CountryCodes[i][j].replace(/\D+/g, ''); if (code.length > maxLength && !phoneNumber.indexOf(code)) { maxLength = code.length; - maxName = Config.CountryCodes[i][1]; + maxName = _(Config.CountryCodes[i][1] + '_raw'); } } } @@ -138,7 +138,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) } $scope.credentials.phone_full = phoneNumber; - $scope.credentials.phone_country_name = maxName || 'Unknown'; + $scope.credentials.phone_country_name = maxName || _('login_controller_unknown_country_raw'); }; $scope.$watch('credentials.phone_country', updateCountry); @@ -2492,7 +2492,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) }) - .controller('CountrySelectModalController', function ($scope, $modalInstance, $rootScope, SearchIndexManager) { + .controller('CountrySelectModalController', function ($scope, $modalInstance, $rootScope, SearchIndexManager, _) { $scope.search = {}; $scope.slice = {limit: 20, limitDelta: 20} @@ -2500,7 +2500,10 @@ angular.module('myApp.controllers', ['myApp.i18n']) var searchIndex = SearchIndexManager.createIndex(); for (var i = 0; i < Config.CountryCodes.length; i++) { - SearchIndexManager.indexObject(i, Config.CountryCodes[i].join(' '), searchIndex); + var searchString = Config.CountryCodes[i][0]; + searchString += ' ' + _(Config.CountryCodes[i][1] + '_raw'); + searchString += ' ' + Config.CountryCodes[i].slice(2).join(' '); + SearchIndexManager.indexObject(i, searchString, searchIndex); } $scope.$watch('search.query', function (newValue) { @@ -2519,7 +2522,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) for (var i = 0; i < Config.CountryCodes.length; i++) { if (!filtered || results[i]) { for (j = 2; j < Config.CountryCodes[i].length; j++) { - $scope.countries.push({name: Config.CountryCodes[i][1], code: Config.CountryCodes[i][j]}); + $scope.countries.push({name: _(Config.CountryCodes[i][1] + '_raw'), code: Config.CountryCodes[i][j]}); } } } diff --git a/app/js/directives.js b/app/js/directives.js index 1c7fc19b..63f96c2b 100644 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -844,7 +844,7 @@ angular.module('myApp.directives', ['myApp.filters']) }) - .directive('mySendForm', function ($timeout, $modalStack, Storage, ErrorService) { + .directive('mySendForm', function ($timeout, $modalStack, Storage, ErrorService, $interpolate) { return { link: link, @@ -868,7 +868,7 @@ angular.module('myApp.directives', ['myApp.filters']) if (richTextarea) { editorElement = richTextarea; $(richTextarea).addClass('form-control'); - $(richTextarea).attr('placeholder', $(messageField).attr('placeholder')); + $(richTextarea).attr('placeholder', $interpolate($(messageField).attr('placeholder'))($scope)); var updatePromise; $(richTextarea) @@ -1198,7 +1198,7 @@ angular.module('myApp.directives', ['myApp.filters']) }) - .directive('myLoadFullPhoto', function(MtpApiFileManager) { + .directive('myLoadFullPhoto', function(MtpApiFileManager, _) { return { link: link, @@ -1263,9 +1263,13 @@ angular.module('myApp.directives', ['myApp.filters']) $scope.progress.enabled = false; if (e && e.type == 'FS_BROWSER_UNSUPPORTED') { - $scope.error = {html: 'Your browser doesn\'t support LocalFileSystem feature which is needed to display this image.
Please, install Google Chrome or use mobile app instead.'}; + $scope.error = {html: _('browser_no_local_file_system_image', { + 'moz-link': '{1}', + 'chrome-link': '{1}', + 'telegram-link': '{1}' + })}; } else { - $scope.error = {text: 'Download failed', error: e}; + $scope.error = {text: _('error_image_download_failed'), error: e}; } }, function (progress) { $scope.progress.percent = Math.max(1, Math.floor(100 * progress.done / progress.total)); @@ -1277,7 +1281,7 @@ angular.module('myApp.directives', ['myApp.filters']) }) - .directive('myLoadVideo', function($sce, MtpApiFileManager) { + .directive('myLoadVideo', function($sce, MtpApiFileManager, _) { return { link: link, @@ -1323,9 +1327,13 @@ angular.module('myApp.directives', ['myApp.filters']) $scope.player.src = ''; if (e && e.type == 'FS_BROWSER_UNSUPPORTED') { - $scope.error = {html: 'Your browser doesn\'t support LocalFileSystem feature which is needed to play this video.
Please, install Google Chrome or use mobile app instead.'}; + $scope.error = {html: _('error_browser_no_local_file_system_video', { + 'moz-link': '{1}', + 'chrome-link': '{1}', + 'telegram-link': '{1}' + })}; } else { - $scope.error = {text: 'Video download failed', error: e}; + $scope.error = {text: _('error_video_download_failed'), error: e}; } }, function (progress) { diff --git a/app/js/filters.js b/app/js/filters.js index 52dd8f11..0f49559e 100644 --- a/app/js/filters.js +++ b/app/js/filters.js @@ -11,41 +11,41 @@ angular.module('myApp.filters', ['myApp.i18n']) - .filter('userName', [function() { + .filter('userName', ['_', function(_) { return function (user) { if (!user || !user.first_name && !user.last_name) { - return 'DELETED'; + return _('user_name_deleted'); } return user.first_name + ' ' + user.last_name; } }]) - .filter('userFirstName', [function() { + .filter('userFirstName', ['_', function(_) { return function (user) { if (!user || !user.first_name && !user.last_name) { - return 'DELETED'; + return _('user_first_name_deleted'); } return user.first_name || user.last_name; } }]) - .filter('userStatus', ['$filter', function($filter) { + .filter('userStatus', ['$filter', '_', function($filter, _) { return function (user) { if (!user || !user.status || user.status._ == 'userStatusEmpty') { - return 'offline'; + return _('user_status_offline'); } if (user.status._ == 'userStatusOnline') { - return 'online'; + return _('user_status_online'); } - return 'last seen ' + $filter('relativeTime')(user.status.was_online); + return _('user_status_last_seen', $filter('relativeTime')(user.status.was_online)); } }]) - .filter('chatTitle', [function() { + .filter('chatTitle', ['_', function(_) { return function (chat) { if (!chat || !chat.title) { - return 'DELETED'; + return _('chat_title_deleted'); } return chat.title; } @@ -153,7 +153,7 @@ angular.module('myApp.filters', ['myApp.i18n']) } }]) - .filter('formatSizeProgress', ['$filter', function ($filter) { + .filter('formatSizeProgress', ['$filter', '_', function ($filter, _) { return function (progress) { var done = $filter('formatSize')(progress.done), doneParts = done.split(' '), @@ -161,9 +161,9 @@ angular.module('myApp.filters', ['myApp.i18n']) totalParts = total.split(' '); if (totalParts[1] === doneParts[1]) { - return doneParts[0] + ' of ' + totalParts[0] + ' ' + (doneParts[1] || ''); + return _('format_size_progress_mulitple', {done: done, total: total, parts: (doneParts[1] || '')}); } - return done + ' of ' + total; + return _('format_size_progress', {done: done, total: total}); } }]) @@ -179,29 +179,29 @@ angular.module('myApp.filters', ['myApp.i18n']) } }]) - .filter('relativeTime', ['$filter', function($filter) { + .filter('relativeTime', ['$filter', '_', function($filter, _) { var langMinutes = { - one: 'minute ago', - many: 'minutes ago' + one: 'relative_time_one_minute', + many: 'relative_time_many_minutes' }, langHours = { - one: 'hour ago', - many: 'hours ago' + one: 'relative_time_one_hour', + many: 'relative_time_many_hours' }; return function (timestamp) { var ticks = timestamp * 1000, diff = Math.abs(tsNow() - ticks); if (diff < 60000) { - return 'just now'; + return _('relative_time_just_now'); } if (diff < 3000000) { var minutes = Math.ceil(diff / 60000); - return minutes + ' ' + langMinutes[minutes > 1 ? 'many' : 'one']; + return _(langMinutes[minutes > 1 ? 'many' : 'one'], {minutes: minutes}); } if (diff < 10000000) { var hours = Math.ceil(diff / 3600000); - return hours + ' ' + langHours[hours > 1 ? 'many' : 'one']; + return _(langHours[hours > 1 ? 'many' : 'one'], {hours: hours}); } return $filter('dateOrTime')(timestamp); } diff --git a/app/js/lib/config.js b/app/js/lib/config.js index 532d90dc..a912b887 100644 --- a/app/js/lib/config.js +++ b/app/js/lib/config.js @@ -59,6 +59,6 @@ Config.EmojiCategories = [[ "1f604", "1f603", "1f600", "1f60a", "263a", "1f609", Config.EmojiCategorySpritesheetDimens = [[7, 27], [4, 29], [7, 33], [3, 34], [6,34]]; -Config.CountryCodes = [["AB", "Abkhazia", "+7 840", "+7 940", "+995 44"], ["AF", "Afghanistan", "+93"], ["AX", "Åland Islands", "+358 18"], ["AL", "Albania", "+355"], ["DZ", "Algeria", "+213"], ["AS", "American Samoa", "+1 684"], ["AD", "Andorra", "+376"], ["AO", "Angola", "+244"], ["AI", "Anguilla", "+1 264"], ["AG", "Antigua and Barbuda", "+1 268"], ["AR", "Argentina", "+54"], ["AM", "Armenia", "+374"], ["AW", "Aruba", "+297"], ["SH", "Ascension", "+247"], ["AU", "Australia", "+61"], ["AU", "Australian External Territories", "+672"], ["AT", "Austria", "+43"], ["AZ", "Azerbaijan", "+994"], ["BS", "Bahamas", "+1 242"], ["BH", "Bahrain", "+973"], ["BD", "Bangladesh", "+880"], ["BB", "Barbados", "+1 246"], ["AG", "Barbuda", "+1 268"], ["BY", "Belarus", "+375"], ["BE", "Belgium", "+32"], ["BZ", "Belize", "+501"], ["BJ", "Benin", "+229"], ["BM", "Bermuda", "+1 441"], ["BT", "Bhutan", "+975"], ["BO", "Bolivia", "+591"], ["BQ", "Bonaire", "+599 7"], ["BA", "Bosnia and Herzegovina", "+387"], ["BW", "Botswana", "+267"], ["BR", "Brazil", "+55"], ["IO", "British Indian Ocean Territory", "+246"], ["VG", "British Virgin Islands", "+1 284"], ["BN", "Brunei Darussalam", "+673"], ["BG", "Bulgaria", "+359"], ["BF", "Burkina Faso", "+226"], ["MY", "Burma", "+95"], ["BI", "Burundi", "+257"], ["KH", "Cambodia", "+855"], ["CM", "Cameroon", "+237"], ["CA", "Canada", "+1"], ["CV", "Cape Verde", "+238"], ["KY", "Cayman Islands", "+1 345"], ["CF", "Central African Republic", "+236"], ["TD", "Chad", "+235"], ["CL", "Chile", "+56"], ["CN", "China", "+86"], ["CX", "Christmas Island", "+61"], ["CC", "Cocos (Keeling) Islands", "+61"], ["CO", "Colombia", "+57"], ["KM", "Comoros", "+269"], ["CG", "Congo", "+242"], ["CD", "Congo, Democratic Republic of the (Zaire)", "+243"], ["CK", "Cook Islands", "+682"], ["CR", "Costa Rica", "+506"], ["CI", "Côte d'Ivoire", "+225"], ["HR", "Croatia", "+385"], ["CU", "Cuba", "+53"], ["CW", "Curaçao", "+599 9"], ["CY", "Cyprus", "+357"], ["CZ", "Czech Republic", "+420"], ["DK", "Denmark", "+45"], ["DG", "Diego Garcia", "+246"], ["DJ", "Djibouti", "+253"], ["DM", "Dominica", "+1 767"], ["DO", "Dominican Republic", "+1 809", "+1 829", "+1 849"], ["TL", "East Timor", "+670"], ["EC", "Ecuador", "+593"], ["EG", "Egypt", "+20"], ["SV", "El Salvador", "+503"], ["GQ", "Equatorial Guinea", "+240"], ["ER", "Eritrea", "+291"], ["EE", "Estonia", "+372"], ["ET", "Ethiopia", "+251"], ["FK", "Falkland Islands", "+500"], ["FO", "Faroe Islands", "+298"], ["FJ", "Fiji", "+679"], ["FI", "Finland", "+358"], ["FR", "France", "+33"], ["GF", "French Guiana", "+594"], ["PF", "French Polynesia", "+689"], ["GA", "Gabon", "+241"], ["GM", "Gambia", "+220"], ["GE", "Georgia", "+995"], ["DE", "Germany", "+49"], ["GH", "Ghana", "+233"], ["GI", "Gibraltar", "+350"], ["GR", "Greece", "+30"], ["GL", "Greenland", "+299"], ["GD", "Grenada", "+1 473"], ["GP", "Guadeloupe", "+590"], ["GU", "Guam", "+1 671"], ["GT", "Guatemala", "+502"], ["GG", "Guernsey", "+44"], ["GN", "Guinea", "+224"], ["GW", "Guinea-Bissau", "+245"], ["GY", "Guyana", "+592"], ["HT", "Haiti", "+509"], ["HN", "Honduras", "+504"], ["HK", "Hong Kong", "+852"], ["HU", "Hungary", "+36"], ["IS", "Iceland", "+354"], ["IN", "India", "+91"], ["ID", "Indonesia", "+62"], ["IR", "Iran", "+98"], ["IQ", "Iraq", "+964"], ["IE", "Ireland", "+353"], ["IL", "Israel", "+972"], ["IT", "Italy", "+39"], ["JM", "Jamaica", "+1 876"], ["SJ", "Jan Mayen", "+47 79"], ["JP", "Japan", "+81"], ["JE", "Jersey", "+44"], ["JO", "Jordan", "+962"], ["KZ", "Kazakhstan", "+7 6", "+7 7"], ["KE", "Kenya", "+254"], ["KI", "Kiribati", "+686"], ["KP", "Korea, North", "+850"], ["KR", "Korea, South", "+82"], ["KW", "Kuwait", "+965"], ["KG", "Kyrgyzstan", "+996"], ["LA", "Laos", "+856"], ["LV", "Latvia", "+371"], ["LB", "Lebanon", "+961"], ["LS", "Lesotho", "+266"], ["LR", "Liberia", "+231"], ["LY", "Libya", "+218"], ["LI", "Liechtenstein", "+423"], ["LT", "Lithuania", "+370"], ["LU", "Luxembourg", "+352"], ["MO", "Macau", "+853"], ["MK", "Macedonia", "+389"], ["MG", "Madagascar", "+261"], ["MW", "Malawi", "+265"], ["MY", "Malaysia", "+60"], ["MV", "Maldives", "+960"], ["ML", "Mali", "+223"], ["MT", "Malta", "+356"], ["MH", "Marshall Islands", "+692"], ["MQ", "Martinique", "+596"], ["MR", "Mauritania", "+222"], ["MU", "Mauritius", "+230"], ["YT", "Mayotte", "+262"], ["MX", "Mexico", "+52"], ["FM", "Micronesia, Federated States of", "+691"], ["MD", "Moldova", "+373"], ["MC", "Monaco", "+377"], ["MN", "Mongolia", "+976"], ["ME", "Montenegro", "+382"], ["MS", "Montserrat", "+1 664"], ["MA", "Morocco", "+212"], ["MZ", "Mozambique", "+258"], ["NA", "Namibia", "+264"], ["NR", "Nauru", "+674"], ["NP", "Nepal", "+977"], ["NL", "Netherlands", "+31"], ["NC", "New Caledonia", "+687"], ["NZ", "New Zealand", "+64"], ["NI", "Nicaragua", "+505"], ["NE", "Niger", "+227"], ["NG", "Nigeria", "+234"], ["NU", "Niue", "+683"], ["NF", "Norfolk Island", "+672"], ["MP", "Northern Mariana Islands", "+1 670"], ["NO", "Norway", "+47"], ["OM", "Oman", "+968"], ["PK", "Pakistan", "+92"], ["PW", "Palau", "+680"], ["PS", "Palestinian territories", "+970"], ["PA", "Panama", "+507"], ["PG", "Papua New Guinea", "+675"], ["PY", "Paraguay", "+595"], ["PE", "Peru", "+51"], ["PH", "Philippines", "+63"], ["PN", "Pitcairn Islands", "+64"], ["PL", "Poland", "+48"], ["PT", "Portugal", "+351"], ["PR", "Puerto Rico", "+1 787", "+1 939"], ["QA", "Qatar", "+974"], ["RE", "Réunion", "+262"], ["RO", "Romania", "+40"], ["RU", "Russia", "+7"], ["RW", "Rwanda", "+250"], ["BL", "Saint Barthélemy", "+590"], ["SH", "Saint Helena", "+290"], ["KN", "Saint Kitts and Nevis", "+1 869"], ["LC", "Saint Lucia", "+1 758"], ["MF", "Saint Martin (France)", "+590"], ["PM", "Saint Pierre and Miquelon", "+508"], ["VC", "Saint Vincent and the Grenadines", "+1 784"], ["WS", "Samoa", "+685"], ["SM", "San Marino", "+378"], ["ST", "São Tomé and Príncipe", "+239"], ["SA", "Saudi Arabia", "+966"], ["SN", "Senegal", "+221"], ["RS", "Serbia", "+381"], ["SC", "Seychelles", "+248"], ["SL", "Sierra Leone", "+232"], ["SG", "Singapore", "+65"], ["BQ", "Sint Eustatius", "+599 3"], ["SX", "Sint Maarten (Netherlands)", "+1 721"], ["SK", "Slovakia", "+421"], ["SI", "Slovenia", "+386"], ["SB", "Solomon Islands", "+677"], ["SO", "Somalia", "+252"], ["ZA", "South Africa", "+27"], ["GS", "South Georgia and the South Sandwich Islands", "+500"], [false, "South Ossetia", "+995 34"], ["SS", "South Sudan", "+211"], ["ES", "Spain", "+34"], ["LK", "Sri Lanka", "+94"], ["SD", "Sudan", "+249"], ["SR", "Suriname", "+597"], ["SJ", "Svalbard", "+47 79"], ["SZ", "Swaziland", "+268"], ["SE", "Sweden", "+46"], ["CH", "Switzerland", "+41"], ["SY", "Syria", "+963"], ["TW", "Taiwan", "+886"], ["TJ", "Tajikistan", "+992"], ["TZ", "Tanzania", "+255"], ["TH", "Thailand", "+66"], ["TG", "Togo", "+228"], ["TK", "Tokelau", "+690"], ["TO", "Tonga", "+676"], ["TT", "Trinidad and Tobago", "+1 868"], ["TN", "Tunisia", "+216"], ["TR", "Turkey", "+90"], ["TM", "Turkmenistan", "+993"], ["TC", "Turks and Caicos Islands", "+1 649"], ["TV", "Tuvalu", "+688"], ["UG", "Uganda", "+256"], ["UA", "Ukraine", "+380"], ["AE", "United Arab Emirates", "+971"], ["UK", "United Kingdom", "+44"], ["US", "United States", "+1"], ["UY", "Uruguay", "+598"], ["VI", "US Virgin Islands", "+1 340"], ["UZ", "Uzbekistan", "+998"], ["VU", "Vanuatu", "+678"], ["VE", "Venezuela", "+58"], ["VA", "Vatican City State (Holy See)", "+39 06 698", "+379"], ["VN", "Vietnam", "+84"], ["WF", "Wallis and Futuna", "+681"], ["YE", "Yemen", "+967"], ["ZM", "Zambia", "+260"], [false, "Zanzibar", "+255"], ["ZW", "Zimbabwe", "+263"] ]; +Config.CountryCodes = [["AB","country_select_modal_country_ab","+7 840","+7 940","+995 44"],["AF","country_select_modal_country_af","+93"],["AX","country_select_modal_country_ax","+358 18"],["AL","country_select_modal_country_al","+355"],["DZ","country_select_modal_country_dz","+213"],["AS","country_select_modal_country_as","+1 684"],["AD","country_select_modal_country_ad","+376"],["AO","country_select_modal_country_ao","+244"],["AI","country_select_modal_country_ai","+1 264"],["AG","country_select_modal_country_ag","+1 268"],["AR","country_select_modal_country_ar","+54"],["AM","country_select_modal_country_am","+374"],["AW","country_select_modal_country_aw","+297"],["SH","country_select_modal_country_sh_ac","+247"],["AU","country_select_modal_country_au","+61"],["AU","country_select_modal_country_au_et","+672"],["AT","country_select_modal_country_at","+43"],["AZ","country_select_modal_country_az","+994"],["BS","country_select_modal_country_bs","+1 242"],["BH","country_select_modal_country_bh","+973"],["BD","country_select_modal_country_bd","+880"],["BB","country_select_modal_country_bb","+1 246"],["AG","country_select_modal_country_ag_bar","+1 268"],["BY","country_select_modal_country_by","+375"],["BE","country_select_modal_country_be","+32"],["BZ","country_select_modal_country_bz","+501"],["BJ","country_select_modal_country_bj","+229"],["BM","country_select_modal_country_bm","+1 441"],["BT","country_select_modal_country_bt","+975"],["BO","country_select_modal_country_bo","+591"],["BQ","country_select_modal_country_bq","+599 7"],["BA","country_select_modal_country_ba","+387"],["BW","country_select_modal_country_bw","+267"],["BR","country_select_modal_country_br","+55"],["IO","country_select_modal_country_io","+246"],["VG","country_select_modal_country_vg","+1 284"],["BN","country_select_modal_country_bn","+673"],["BG","country_select_modal_country_bg","+359"],["BF","country_select_modal_country_bf","+226"],["MY","country_select_modal_country_mm","+95"],["BI","country_select_modal_country_bi","+257"],["KH","country_select_modal_country_kh","+855"],["CM","country_select_modal_country_cm","+237"],["CA","country_select_modal_country_ca","+1"],["CV","country_select_modal_country_cv","+238"],["KY","country_select_modal_country_ky","+1 345"],["CF","country_select_modal_country_cf","+236"],["TD","country_select_modal_country_td","+235"],["CL","country_select_modal_country_cl","+56"],["CN","country_select_modal_country_cn","+86"],["CX","country_select_modal_country_cx","+61"],["CC","country_select_modal_country_cc","+61"],["CO","country_select_modal_country_co","+57"],["KM","country_select_modal_country_km","+269"],["CG","country_select_modal_country_cg","+242"],["CD","country_select_modal_country_cd","+243"],["CK","country_select_modal_country_ck","+682"],["CR","country_select_modal_country_cr","+506"],["CI","country_select_modal_country_ci","+225"],["HR","country_select_modal_country_hr","+385"],["CU","country_select_modal_country_cu","+53"],["CW","country_select_modal_country_cw","+599 9"],["CY","country_select_modal_country_cy","+357"],["CZ","country_select_modal_country_cz","+420"],["DK","country_select_modal_country_dk","+45"],["DG","country_select_modal_country_dg","+246"],["DJ","country_select_modal_country_dj","+253"],["DM","country_select_modal_country_dm","+1 767"],["DO","country_select_modal_country_do","+1 809","+1 829","+1 849"],["TL","country_select_modal_country_tl","+670"],["EC","country_select_modal_country_ec","+593"],["EG","country_select_modal_country_eg","+20"],["SV","country_select_modal_country_sv","+503"],["GQ","country_select_modal_country_gq","+240"],["ER","country_select_modal_country_er","+291"],["EE","country_select_modal_country_ee","+372"],["ET","country_select_modal_country_et","+251"],["FK","country_select_modal_country_fk","+500"],["FO","country_select_modal_country_fo","+298"],["FJ","country_select_modal_country_fj","+679"],["FI","country_select_modal_country_fi","+358"],["FR","country_select_modal_country_fr","+33"],["GF","country_select_modal_country_gf","+594"],["PF","country_select_modal_country_pf","+689"],["GA","country_select_modal_country_ga","+241"],["GM","country_select_modal_country_gm","+220"],["GE","country_select_modal_country_ge","+995"],["DE","country_select_modal_country_de","+49"],["GH","country_select_modal_country_gh","+233"],["GI","country_select_modal_country_gi","+350"],["GR","country_select_modal_country_gr","+30"],["GL","country_select_modal_country_gl","+299"],["GD","country_select_modal_country_gd","+1 473"],["GP","country_select_modal_country_gp","+590"],["GU","country_select_modal_country_gu","+1 671"],["GT","country_select_modal_country_gt","+502"],["GG","country_select_modal_country_gg","+44"],["GN","country_select_modal_country_gn","+224"],["GW","country_select_modal_country_gw","+245"],["GY","country_select_modal_country_gy","+592"],["HT","country_select_modal_country_ht","+509"],["HN","country_select_modal_country_hn","+504"],["HK","country_select_modal_country_hk","+852"],["HU","country_select_modal_country_hu","+36"],["IS","country_select_modal_country_is","+354"],["IN","country_select_modal_country_in","+91"],["ID","country_select_modal_country_id","+62"],["IR","country_select_modal_country_ir","+98"],["IQ","country_select_modal_country_iq","+964"],["IE","country_select_modal_country_ie","+353"],["IL","country_select_modal_country_il","+972"],["IT","country_select_modal_country_it","+39"],["JM","country_select_modal_country_jm","+1 876"],["SJ","country_select_modal_country_sj","+47 79"],["JP","country_select_modal_country_jp","+81"],["JE","country_select_modal_country_je","+44"],["JO","country_select_modal_country_jo","+962"],["KZ","country_select_modal_country_kz","+7 6","+7 7"],["KE","country_select_modal_country_ke","+254"],["KI","country_select_modal_country_ki","+686"],["KP","country_select_modal_country_kp","+850"],["KR","country_select_modal_country_kr","+82"],["KW","country_select_modal_country_kw","+965"],["KG","country_select_modal_country_kg","+996"],["LA","country_select_modal_country_la","+856"],["LV","country_select_modal_country_lv","+371"],["LB","country_select_modal_country_lb","+961"],["LS","country_select_modal_country_ls","+266"],["LR","country_select_modal_country_lr","+231"],["LY","country_select_modal_country_ly","+218"],["LI","country_select_modal_country_li","+423"],["LT","country_select_modal_country_lt","+370"],["LU","country_select_modal_country_lu","+352"],["MO","country_select_modal_country_mo","+853"],["MK","country_select_modal_country_mk","+389"],["MG","country_select_modal_country_mg","+261"],["MW","country_select_modal_country_mw","+265"],["MY","country_select_modal_country_my","+60"],["MV","country_select_modal_country_mv","+960"],["ML","country_select_modal_country_ml","+223"],["MT","country_select_modal_country_mt","+356"],["MH","country_select_modal_country_mh","+692"],["MQ","country_select_modal_country_mq","+596"],["MR","country_select_modal_country_mr","+222"],["MU","country_select_modal_country_mu","+230"],["YT","country_select_modal_country_yt","+262"],["MX","country_select_modal_country_mx","+52"],["FM","country_select_modal_country_fm","+691"],["MD","country_select_modal_country_md","+373"],["MC","country_select_modal_country_mc","+377"],["MN","country_select_modal_country_mn","+976"],["ME","country_select_modal_country_me","+382"],["MS","country_select_modal_country_ms","+1 664"],["MA","country_select_modal_country_ma","+212"],["MZ","country_select_modal_country_mz","+258"],["NA","country_select_modal_country_na","+264"],["NR","country_select_modal_country_nr","+674"],["NP","country_select_modal_country_np","+977"],["NL","country_select_modal_country_nl","+31"],["NC","country_select_modal_country_nc","+687"],["NZ","country_select_modal_country_nz","+64"],["NI","country_select_modal_country_ni","+505"],["NE","country_select_modal_country_ne","+227"],["NG","country_select_modal_country_ng","+234"],["NU","country_select_modal_country_nu","+683"],["NF","country_select_modal_country_nf","+672"],["MP","country_select_modal_country_mp","+1 670"],["NO","country_select_modal_country_no","+47"],["OM","country_select_modal_country_om","+968"],["PK","country_select_modal_country_pk","+92"],["PW","country_select_modal_country_pw","+680"],["PS","country_select_modal_country_ps","+970"],["PA","country_select_modal_country_pa","+507"],["PG","country_select_modal_country_pg","+675"],["PY","country_select_modal_country_py","+595"],["PE","country_select_modal_country_pe","+51"],["PH","country_select_modal_country_ph","+63"],["PN","country_select_modal_country_pn","+64"],["PL","country_select_modal_country_pl","+48"],["PT","country_select_modal_country_pt","+351"],["PR","country_select_modal_country_pr","+1 787","+1 939"],["QA","country_select_modal_country_qa","+974"],["RE","country_select_modal_country_re","+262"],["RO","country_select_modal_country_ro","+40"],["RU","country_select_modal_country_ru","+7"],["RW","country_select_modal_country_rw","+250"],["BL","country_select_modal_country_bl","+590"],["SH","country_select_modal_country_sh","+290"],["KN","country_select_modal_country_kn","+1 869"],["LC","country_select_modal_country_lc","+1 758"],["MF","country_select_modal_country_mf","+590"],["PM","country_select_modal_country_pm","+508"],["VC","country_select_modal_country_vc","+1 784"],["WS","country_select_modal_country_ws","+685"],["SM","country_select_modal_country_sm","+378"],["ST","country_select_modal_country_st","+239"],["SA","country_select_modal_country_sa","+966"],["SN","country_select_modal_country_sn","+221"],["RS","country_select_modal_country_rs","+381"],["SC","country_select_modal_country_sc","+248"],["SL","country_select_modal_country_sl","+232"],["SG","country_select_modal_country_sg","+65"],["BQ","country_select_modal_country_nl_bq3","+599 3"],["SX","country_select_modal_country_sx","+1 721"],["SK","country_select_modal_country_sk","+421"],["SI","country_select_modal_country_si","+386"],["SB","country_select_modal_country_sb","+677"],["SO","country_select_modal_country_so","+252"],["ZA","country_select_modal_country_za","+27"],["GS","country_select_modal_country_gs","+500"],[false,"country_select_modal_country_ge_so","+995 34"],["SS","country_select_modal_country_ss","+211"],["ES","country_select_modal_country_es","+34"],["LK","country_select_modal_country_lk","+94"],["SD","country_select_modal_country_sd","+249"],["SR","country_select_modal_country_sr","+597"],["SJ","country_select_modal_country_sj_no","+47 79"],["SZ","country_select_modal_country_sz","+268"],["SE","country_select_modal_country_se","+46"],["CH","country_select_modal_country_ch","+41"],["SY","country_select_modal_country_sy","+963"],["TW","country_select_modal_country_tw","+886"],["TJ","country_select_modal_country_tj","+992"],["TZ","country_select_modal_country_tz","+255"],["TH","country_select_modal_country_th","+66"],["TG","country_select_modal_country_tg","+228"],["TK","country_select_modal_country_tk","+690"],["TO","country_select_modal_country_to","+676"],["TT","country_select_modal_country_tt","+1 868"],["TN","country_select_modal_country_tn","+216"],["TR","country_select_modal_country_tr","+90"],["TM","country_select_modal_country_tm","+993"],["TC","country_select_modal_country_tc","+1 649"],["TV","country_select_modal_country_tv","+688"],["UG","country_select_modal_country_ug","+256"],["UA","country_select_modal_country_ua","+380"],["AE","country_select_modal_country_ae","+971"],["UK","country_select_modal_country_uk","+44"],["US","country_select_modal_country_us","+1"],["UY","country_select_modal_country_uy","+598"],["VI","country_select_modal_country_vi","+1 340"],["UZ","country_select_modal_country_uz","+998"],["VU","country_select_modal_country_vu","+678"],["VE","country_select_modal_country_ve","+58"],["VA","country_select_modal_country_va","+39 06 698","+379"],["VN","country_select_modal_country_vn","+84"],["WF","country_select_modal_country_wf","+681"],["YE","country_select_modal_country_ye","+967"],["ZM","country_select_modal_country_zm","+260"],[false,"country_select_modal_country_tz_uk","+255"],["ZW","country_select_modal_country_zw","+263"]]; Config.LangCountries = {"es": "ES", "ru": "RU", "en": "US", "de": "DE", "it": "IT", "nl": "NL", "fr": "FR", "ca": "ES", "es-419": "MX", "ar": "SA", "he": "IL", "tr": "TR", "id": "ID", "pl": "PL"}; diff --git a/app/js/services.js b/app/js/services.js index 2c12fa09..beaa2e77 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -11,7 +11,7 @@ angular.module('myApp.services', ['myApp.i18n']) -.service('AppUsersManager', function ($rootScope, $modal, $modalStack, $filter, $q, MtpApiFileManager, MtpApiManager, RichTextProcessor, SearchIndexManager, ErrorService, Storage) { +.service('AppUsersManager', function ($rootScope, $modal, $modalStack, $filter, $q, MtpApiFileManager, MtpApiManager, RichTextProcessor, SearchIndexManager, ErrorService, Storage, _) { var users = {}, cachedPhotoLocations = {}, contactsFillPromise, @@ -92,8 +92,8 @@ angular.module('myApp.services', ['myApp.i18n']) apiUser.rFirstName = RichTextProcessor.wrapRichText(apiUser.first_name, {noLinks: true, noLinebreaks: true}); apiUser.rFullName = RichTextProcessor.wrapRichText(apiUser.first_name + ' ' + (apiUser.last_name || ''), {noLinks: true, noLinebreaks: true}); } else { - apiUser.rFirstName = RichTextProcessor.wrapRichText(apiUser.last_name, {noLinks: true, noLinebreaks: true}) || apiUser.rPhone || 'DELETED'; - apiUser.rFullName = RichTextProcessor.wrapRichText(apiUser.last_name, {noLinks: true, noLinebreaks: true}) || apiUser.rPhone || 'DELETED'; + apiUser.rFirstName = RichTextProcessor.wrapRichText(apiUser.last_name, {noLinks: true, noLinebreaks: true}) || apiUser.rPhone || _('user_first_name_deleted'); + apiUser.rFullName = RichTextProcessor.wrapRichText(apiUser.last_name, {noLinks: true, noLinebreaks: true}) || apiUser.rPhone || _('user_name_deleted'); } apiUser.sortName = SearchIndexManager.cleanSearchText(apiUser.first_name + ' ' + (apiUser.last_name || '')); apiUser.sortStatus = apiUser.status && (apiUser.status.expires || apiUser.status.was_online) || 0; @@ -456,7 +456,7 @@ angular.module('myApp.services', ['myApp.i18n']) if (!angular.isObject(apiChat)) { return; } - apiChat.rTitle = RichTextProcessor.wrapRichText(apiChat.title, {noLinks: true, noLinebreaks: true}) || 'DELETED'; + apiChat.rTitle = RichTextProcessor.wrapRichText(apiChat.title, {noLinks: true, noLinebreaks: true}) || _('chat_title_deleted'); if (chats[apiChat.id] === undefined) { chats[apiChat.id] = apiChat; } else { @@ -1835,7 +1835,7 @@ angular.module('myApp.services', ['myApp.i18n']) case 'messageActionChatCreate': case 'messageActionChatEditTitle': - message.action.rTitle = RichTextProcessor.wrapRichText(message.action.title, {noLinks: true, noLinebreaks: true}) || 'DELETED'; + message.action.rTitle = RichTextProcessor.wrapRichText(message.action.title, {noLinks: true, noLinebreaks: true}) || _('chat_title_deleted'); break; } } @@ -1946,25 +1946,25 @@ angular.module('myApp.services', ['myApp.i18n']) notificationMessage = RichTextProcessor.wrapPlainText(message.message); } else if (message.media && message.media._ != 'messageMediaEmpty') { switch (message.media._) { - case 'messageMediaPhoto': notificationMessage = 'Photo'; break; - case 'messageMediaVideo': notificationMessage = 'Video'; break; - case 'messageMediaDocument': notificationMessage = 'Document'; break; - case 'messageMediaAudio': notificationMessage = 'Voice message'; break; - case 'messageMediaGeo': notificationMessage = 'Location'; break; - case 'messageMediaContact': notificationMessage = 'Contact'; break; - default: notificationMessage = 'Attachment'; break; + case 'messageMediaPhoto': notificationMessage = _('conversation_media_photo'); break; + case 'messageMediaVideo': notificationMessage = _('conversation_media_video'); break; + case 'messageMediaDocument': notificationMessage = _('conversation_media_document'); break; + case 'messageMediaAudio': notificationMessage = _('conversation_media_audio'); break; + case 'messageMediaGeo': notificationMessage = _('conversation_media_location'); break; + case 'messageMediaContact': notificationMessage = _('conversation_media_contact'); break; + default: notificationMessage = _('conversation_media_attachment'); break; } } else if (message._ == 'messageService') { switch (message.action._) { - case 'messageActionChatCreate': notificationMessage = 'created the group'; break; - case 'messageActionChatEditTitle': notificationMessage = 'changed group name'; break; - case 'messageActionChatEditPhoto': notificationMessage = 'changed group photo'; break; - case 'messageActionChatDeletePhoto': notificationMessage = 'removed group photo'; break; + case 'messageActionChatCreate': notificationMessage = _('conversation_group_created'); break; + case 'messageActionChatEditTitle': notificationMessage = _('conversation_group_renamed'); break; + case 'messageActionChatEditPhoto': notificationMessage = _('conversation_group_photo_updated'); break; + case 'messageActionChatDeletePhoto': notificationMessage = _('conversation_group_photo_removed'); break; case 'messageActionChatAddUser': - notificationMessage = message.action.user_id == message.from_id ? 'returned to group' : 'invited user'; + notificationMessage = message.action.user_id == message.from_id ? _('conversation_returned_to_group') : _('conversation_invited_user_message'); break; case 'messageActionChatDeleteUser': - notificationMessage = message.action.user_id == message.from_id ? 'left group' : 'kicked user'; + notificationMessage = message.action.user_id == message.from_id ? _('conversation_left_group') : _('conversation_kicked_user_message'); break; } } @@ -1979,9 +1979,9 @@ angular.module('myApp.services', ['myApp.i18n']) peerString = AppUsersManager.getUserString(peerID); } else { - notification.title = (fromUser.first_name || fromUser.last_name || 'Somebody') + + notification.title = (fromUser.first_name || fromUser.last_name || _('conversation_unknown_user')) + ' @ ' + - (AppChatsManager.getChat(-peerID).title || 'Unknown chat'); + (AppChatsManager.getChat(-peerID).title || _('conversation_unknown_chat')); notificationPhoto = AppChatsManager.getChatPhoto(-peerID, 'Group');