Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Commit d7ecb20

Browse files
committed
Update to working vers of Translations, begin rewrite
1 parent 0f785df commit d7ecb20

File tree

6 files changed

+205
-72
lines changed

6 files changed

+205
-72
lines changed

.bowerrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"directory": "/public/lib"
2+
"directory": "public/lib"
33
}

app/controllers/actions.server.controller.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ var generateActions = function(user) {
111111
// prevents actions from being listed after completed
112112
// [TODO] check against time since completion
113113
// var reject = user.actionFlags.indexOf(action.key) !== -1 && action.type == 'once';
114-
var reject = _.contains(user.actionFlags, action.key) && action.type == 'once';
114+
var reject/* = _.contains(user.actionFlags, action.key) && action.type == 'once'*/;
115115

116116
if(add && !reject) {
117117
if(action.followUp) action.hasFollowUp = true;

bower.json

+7-5
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
"fastclick": "~1.0.6",
2020
"angular-lazy-img": "~1.1.0",
2121
"angular-scroll": "~0.7.2",
22-
"angular-translate": "~2.7.1",
23-
"angular-translate-loader-static-files": "~2.7.1",
24-
"angular-translate-storage-local": "~2.7.1",
25-
"angular-translate-handler-log": "~2.7.1",
22+
"angular-translate": "~2.13.0",
23+
"angular-translate-loader-static-files": "~2.13.0",
24+
"angular-translate-storage-local": "~2.13.0",
25+
"angular-translate-handler-log": "~2.13.0",
2626
"angular-dynamic-locale": "~0.1.27",
2727
"angular-i18n": "1.4.7",
2828
"ui-select": "angular-ui-select#~0.13.2",
@@ -32,7 +32,9 @@
3232
},
3333
"resolutions": {
3434
"angular-bootstrap": "^0.13.3",
35-
"angular": "1.4.7"
35+
"angular": "1.4.7",
36+
"angular-translate-storage-cookie": "~2.13.0",
37+
"angular-translate": "~2.13.0"
3638
},
3739
"overrides": {
3840
"bootstrap-sass-official": {

public/application.js

+178-16
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,22 @@
33
//Start by defining the main module and adding the module dependencies
44
angular.module(ApplicationConfiguration.applicationModuleName, ApplicationConfiguration.applicationModuleVendorDependencies);
55

6-
// Extend $santize to accomidate for ui-sref
7-
// NEEDED: this has to be in the angular-translate module
8-
// https://github.com/angular/angular.js/pull/6252/files
6+
angular.module(ApplicationConfiguration.applicationModuleName).factory(
7+
'customLoader', function($q, $http) {
8+
return function(opts) {
9+
var deferred = $q.deferred;
910

10-
/*var $sanitizeExtFactory = function() {
11-
return {
11+
$http.get('/languages/locale-es_US.json')
12+
.then(function(data){
13+
deferred.resolve(data);
14+
}, function(err){
15+
deferred.reject(err);
16+
});
1217

13-
addSafeElements: function(elements) {
14-
var map = makeMap(elements);
15-
angular.extend(blockElements, map);
16-
angular.extend(validElements, map);
17-
},
18-
19-
addSafeAttributes: function(attrs) {
20-
angular.extend(validAttrs, makeMap(attrs));
21-
}
22-
};
23-
};*/
18+
return deferred.promise;
19+
}
20+
}
21+
);
2422

2523
angular.module(ApplicationConfiguration.applicationModuleName)
2624
// Setting HTML5 Location Mode
@@ -47,6 +45,170 @@ angular.module(ApplicationConfiguration.applicationModuleName)
4745
// enable logging for missing IDs
4846
$translateProvider.useMissingTranslationHandlerLog();
4947

48+
$translateProvider.translations('special', {
49+
"checklist": {
50+
"bedrooms": {
51+
"title": "Bedrooms",
52+
"paint": "Peeling Paint",
53+
"cracked": "Cracked Walls",
54+
"mold": "Mold on Walls",
55+
"water": "Water Damage",
56+
"loose": "Loose Floor",
57+
"windowGlass": "Window Glass Broken",
58+
"windowFrame": "Window Frame Defective",
59+
"door": "Door Broken",
60+
"radiators": "Radiators/Risers Defective",
61+
"ceilingFall": "Ceiling Falling/Fell",
62+
"ceilingLeaking": "Ceiling Leaking",
63+
"electricity": "Electricity defective",
64+
"electricExposed": "Electric wiring exposed",
65+
"outlets": "Outlets defective"
66+
},
67+
"kitchen":{
68+
"title": "Kitchen",
69+
"paint": "@:checklist.bedrooms.paint",
70+
"cracked": "@:checklist.bedrooms.cracked",
71+
"mold": "@:checklist.bedrooms.mold",
72+
"water": "@:checklist.bedrooms.water",
73+
"loose": "@:checklist.bedrooms.loose",
74+
"baseboards": "Baseboards Defective",
75+
"windowGlass": "@:checklist.bedrooms.windowGlass",
76+
"windowFrame": "@:checklist.bedrooms.windowFrame",
77+
"door": "@:checklist.bedrooms.door",
78+
"radiators": "@:checklist.bedrooms.radiators",
79+
"ceilingFall": "@:checklist.bedrooms.ceilingFall",
80+
"ceilingLeaking": "@:checklist.bedrooms.ceilingLeaking",
81+
"electricity": "@:checklist.bedrooms.electricity",
82+
"electricExposed": "@:checklist.bedrooms.electricExposed",
83+
"outlets": "@:checklist.bedrooms.outlets",
84+
"sink": "Cracked Sink (Sink)",
85+
"leakyFaucet": "Leaky Faucet (Sink)",
86+
"noFaucet": "Faucets not installed (Sink)",
87+
"brokenFaucet": "Faucets not working (Sink)",
88+
"pipesLeaking": "Pipes Leaking (Sink)",
89+
"drainBlock": "Drain Stoppage (Sink)",
90+
"fridgeDefective": "Refrigerator Defective",
91+
"fridgeBroken": "Refrigerator Broken",
92+
"stoveDefective": "Stove Defective",
93+
"stoveBroken": "Stove Broken"
94+
},
95+
"livingRoom": {
96+
"title": "Living Room",
97+
"paint": "@:checklist.bedrooms.paint",
98+
"cracked": "@:checklist.bedrooms.cracked",
99+
"mold": "@:checklist.bedrooms.mold",
100+
"water": "@:checklist.bedrooms.water",
101+
"loose": "@:checklist.bedrooms.loose",
102+
"baseboards": "Baseboards Defective",
103+
"windowGlass": "@:checklist.bedrooms.windowGlass",
104+
"windowFrame": "@:checklist.bedrooms.windowFrame",
105+
"door": "@:checklist.bedrooms.door",
106+
"radiators": "@:checklist.bedrooms.radiators",
107+
"ceilingFall": "@:checklist.bedrooms.ceilingFall",
108+
"ceilingLeaking": "@:checklist.bedrooms.ceilingLeaking",
109+
"electricity": "@:checklist.bedrooms.electricity",
110+
"electricExposed": "@:checklist.bedrooms.electricExposed",
111+
"outlets": "@:checklist.bedrooms.outlets"
112+
},
113+
"bathroom": {
114+
"title": "Bathroom",
115+
"paint": "@:checklist.bedrooms.paint",
116+
"cracked": "@:checklist.bedrooms.cracked",
117+
"mold": "@:checklist.bedrooms.mold",
118+
"water": "@:checklist.bedrooms.water",
119+
"loose": "@:checklist.bedrooms.loose",
120+
"baseboards": "Baseboards Defective",
121+
"windowGlass": "@:checklist.bedrooms.windowGlass",
122+
"windowFrame": "@:checklist.bedrooms.windowFrame",
123+
"door": "@:checklist.bedrooms.door",
124+
"radiators": "@:checklist.bedrooms.radiators",
125+
"ceilingFall": "@:checklist.bedrooms.ceilingFall",
126+
"ceilingLeaking": "@:checklist.bedrooms.ceilingLeaking",
127+
"electricity": "@:checklist.bedrooms.electricity",
128+
"electricExposed": "@:checklist.bedrooms.electricExposed",
129+
"outlets": "@:checklist.bedrooms.outlets",
130+
"toiletBroken": "Toilet not working (Toilet)",
131+
"toiletLeaking": "Toilet leaking (Toilet)",
132+
"waterPressureToilet": "Inadequate Water pressure (Toilet)",
133+
"sink": "Cracked Sink (Sink)",
134+
"leakyFaucet": "Leaky Faucet (Sink)",
135+
"noFaucet": "Faucets not installed (Sink)",
136+
"brokenFaucet": "Faucets not working (Sink)",
137+
"pipesLeaking": "Pipes Leaking (Sink)",
138+
"crackedTub": "Cracked Tub (Bathtub)",
139+
"leakyFaucetB": "Leaky Faucet (Bathtub)",
140+
"noFaucetB": "Faucets not installed (Bathtub)",
141+
"faucetsNotWorkingB": "Faucets not working (Bathtub)",
142+
"pipesLeakingB": "Pipes Leaking (Bathtub)",
143+
"notWorkingShower": "Not working (Shower)",
144+
"WaterPressureShower": "Inadequate Water pressure (Shower)",
145+
"leakyShowerHead": "Leaky shower head (Shower)",
146+
"wallTiles": "Wall tiles cracked (Shower)",
147+
"wallTilesMissing": "Wall tiles missing (Shower)",
148+
"drainStoppage": "Drain Stoppage (Shower)"
149+
},
150+
"entireHome": {
151+
"title": "Entire Home",
152+
"mice": "Mice",
153+
"rats": "Rats",
154+
"cockroaches": "Cockroaches",
155+
"hotWater": "No Hot water",
156+
"coldWater": "No Cold water",
157+
"heat": "No heat",
158+
"frontDoorDefective": "Front door defective",
159+
"frontDoorBroken": "Front door broken",
160+
"doorLockDefective": "Door lock defective",
161+
"doorLockBroken": "Door lock broken",
162+
"doorbellDefective": "Doorbell defective",
163+
"doorbellBroken": "Doorbell broken",
164+
"buzzerDefective": "Buzzer defective",
165+
"buzzerBroken": "Buzzer broken",
166+
"smoke": "No Smoke detector",
167+
"smokeDefective": "Smoke detector defective",
168+
"floorSags": "Floor sags",
169+
"apartmentPainting": "Apartment needs painting"
170+
},
171+
"publicAreas": {
172+
"title": "Public Areas",
173+
"paintOverdue": "Painting overdue (3 years)",
174+
"peelingFlaking": "Peeling/flaking paint",
175+
"heat": "@:checklist.entireHome.heat",
176+
"hotWater": "@:checklist.entireHome.hotWater",
177+
"waterPressure": "Inadequate water pressure",
178+
"rusty": "Rusty water",
179+
"electricExposed": "@:checklist.bedrooms.electricExposed",
180+
"electricWeak": "Weak electrical current (lights dim)",
181+
"windowGuards": "Window guards missing",
182+
"smokeCO2": "Missing/broken smoke/Co2 detector",
183+
"fumesSmoke": "Fumes/smoke entering apartment",
184+
"ratsMice": "Rats/Mice",
185+
"bug": "Bug Infestation",
186+
"illegalImpartments": "Illegal apartments in basement",
187+
"noReceipts": "No rent receipts given",
188+
"incompleteReceipts": "Rent receipts incomplete (no date/ NYC address for landlord, etc.)",
189+
"inadequateSuper": "Inadequate / no super service"
190+
},
191+
"landlordIssues": {
192+
"title": "Landlord Issues",
193+
"noReceipts": "@:checklist.publicAreas.noReceipts",
194+
"noReciepts": "@:checklist.publicAreas.noReceipts",
195+
"noLease": "No lease",
196+
"falseDocuments": "False documents",
197+
"illegalConstruction": "Illegal construction",
198+
"repeatedMci": "Repeated MCI",
199+
"overcharging": "Overcharging",
200+
"holdover": "Holdover cases",
201+
"useForce": "Using force or threats of force",
202+
"stopInterrupt": "Stopping or interrupting essential services",
203+
"stealing": "Removing possessions from unit",
204+
"changeLocks": "Changing locks without supplying a new key",
205+
"retaliation": "Retaliation for seeking repairs",
206+
"buyout": "Constant buyout demands",
207+
"falseEviction": "Threatening eviction on false claims"
208+
}
209+
}
210+
});
211+
50212
$translateProvider.useStaticFilesLoader({
51213
prefix: 'languages/locale-',// path to translations files
52214
suffix: '.json'// suffix, currently- extension of the translations

public/modules/actions/services/messages.client.service.js

+16-43
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

3-
angular.module('actions').factory('Messages', ['$http', '$q', '$filter', '$location', 'Authentication', '$translate',
4-
function Issues($http, $q, $filter, $location, Authentication, $translate) {
3+
angular.module('actions').factory('Messages', ['$http', '$q', '$filter', '$location', 'Authentication', '$translate', 'LocaleService',
4+
function Issues($http, $q, $filter, $location, Authentication, $translate, LocaleService) {
55

66
var user = Authentication.user;
77
var request = function(url) {
@@ -17,7 +17,17 @@ angular.module('actions').factory('Messages', ['$http', '$q', '$filter', '$locat
1717
return deferred.promise;
1818
};
1919

20-
var language = $translate.use();
20+
var language = function() {
21+
var deferred = $q.defer;
22+
$http.get('languages/locale-en_US.json')
23+
.then(function(res){
24+
deferred.resolve(res);
25+
}, function(err) {
26+
deferred.reject();
27+
});
28+
29+
return deferred.promise;
30+
};
2131

2232
var getShareMessage = function(type) {
2333

@@ -48,9 +58,6 @@ angular.module('actions').factory('Messages', ['$http', '$q', '$filter', '$locat
4858
};
4959

5060
var getLandlordEmailMessage = function() {
51-
var language = $translate.use();
52-
53-
$translate.use('en_US');
5461

5562
var message = 'To whom it may regard, \n\n' +
5663
'I am requesting the following repairs in my apartment referenced below [and/or] in the public areas of the building:\n\n';
@@ -61,48 +68,15 @@ angular.module('actions').factory('Messages', ['$http', '$q', '$filter', '$locat
6168

6269
var prob = user.problems[i];
6370

64-
problemsContent += $translate.instant(prob.title) + ':\n';
71+
problemsContent += $translate.instant(prob.title, undefined, undefined, 'special') + ':\n';
6572
for(var j = 0; j < prob.issues.length; j++) {
66-
problemsContent += ' - ' + $translate.instant(prob.issues[j].key);
73+
problemsContent += ' - ' + $translate.instant(prob.issues[j].key, undefined, undefined, 'special');
6774
if(prob.issues[j].emergency) problemsContent += ' (FIX IMMEDIATELY)';
6875
problemsContent += '\n';
6976
}
7077
problemsContent += '\n';
7178

7279
}
73-
74-
// for(var issue in user.issues) {
75-
// var key = issue,
76-
// title = $filter('areaTitle')(key),
77-
// vals = user.issues[issue];
78-
//
79-
// if(vals.length) {
80-
//
81-
// var activityIdx = user.activity.map(function(i) { return i.key; }).indexOf(key);
82-
// if(activityIdx !== -1) var activity = user.activity[activityIdx];
83-
//
84-
// issuesContent += title + ':\n';
85-
// vals.forEach(function(v) {
86-
// issuesContent += ' - ' + v.title;
87-
// if(v.emergency) issuesContent += ' (FIX IMMEDIATELY)';
88-
// issuesContent += '\n';
89-
// });
90-
//
91-
// issuesContent += '\n First Appeared: ';
92-
// if(activity) {
93-
// issuesContent += $filter('date')(activity.date, 'longDate');
94-
// issuesContent += '\n Additional Information:';
95-
// issuesContent += '\n ' + activity.description;
96-
// issuesContent += '\n';
97-
// activity = undefined;
98-
// } else {
99-
// issuesContent += '\n Additional Information:';
100-
// }
101-
//
102-
// issuesContent += '\n';
103-
// }
104-
// }
105-
//
10680
message += problemsContent + '\n\n';
10781

10882
var superContactIdx = user.activity.map(function(i) { return i.key; }).indexOf('contactSuper');
@@ -122,9 +96,8 @@ angular.module('actions').factory('Messages', ['$http', '$q', '$filter', '$locat
12296
user.borough + ', NY ' + '\n' +
12397
$filter('tel')(user.phone);
12498

125-
$translate.use(language);
126-
12799
return message;
100+
128101
};
129102

130103
var getLandlordEmailSubject = function() {

public/modules/actions/services/pdf.client.service.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ angular.module('actions').factory('Pdf', ['$http', '$q', 'Authentication', '$fil
66
var user = Authentication.user;
77

88
var assemble = function(landlordName, landlordAddr) {
9-
var language = $translate.use();
10-
11-
$translate.use('en_US');
129

1310
// This block assembles our issues list PhantomJS
1411
var assembledObject = {
@@ -41,10 +38,10 @@ angular.module('actions').factory('Pdf', ['$http', '$q', 'Authentication', '$fil
4138

4239
var problemPush = angular.copy(user.problems[i]);
4340

44-
problemPush.title = $translate.instant(problemPush.title);
41+
problemPush.title = $translate.instant(problemPush.title, undefined, undefined, 'en_US');
4542

4643
problemPush.issues.map(function(curr, idx, arr) {
47-
curr.key = $translate.instant(curr.key);
44+
curr.key = $translate.instant(curr.key, undefined, undefined, 'en_US');
4845
if(curr.emergency === true) {
4946
assembledObject.emergency = true;
5047
}
@@ -54,7 +51,6 @@ angular.module('actions').factory('Pdf', ['$http', '$q', 'Authentication', '$fil
5451
}
5552

5653
return assembledObject;
57-
5854
};
5955

6056
var createComplaint = function(landlord, accessDates) {

0 commit comments

Comments
 (0)