Skip to content

Commit 4b92580

Browse files
committed
Updated for i18n and added mixins,
1 parent 13bc51f commit 4b92580

File tree

20 files changed

+274
-173
lines changed

20 files changed

+274
-173
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Ember from 'ember';
2+
import BaseController from '../mixins/base-controller';
23

3-
export default Ember.ArrayController.extend({
4+
export default Ember.ArrayController.extend(BaseController,{
45

56
});

MarvelWorld-Cli/app/controllers/events.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Ember from 'ember';
2+
import BaseController from '../mixins/base-controller';
23

3-
export default Ember.ArrayController.extend({
4+
export default Ember.ArrayController.extend(BaseController,{
45
sortProperties: ['country'],
56
sortAscending: false,
67
actions:{
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Ember from 'ember';
2+
import BaseController from '../../mixins/base-controller';
23

3-
export default Ember.ArrayController.extend({
4+
export default Ember.ArrayController.extend(BaseController,{
45
needs:['games/index']
56
});

MarvelWorld-Cli/app/controllers/movies/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Ember from 'ember';
2+
import BaseController from '../../mixins/base-controller';
23

3-
export default Ember.ArrayController.extend({
4+
export default Ember.ArrayController.extend(BaseController,{
45
sortProperties: ['title'],
56
sortAscending: true,
67
watches: Ember.computed.mapBy('model', 'watches'),

MarvelWorld-Cli/app/controllers/movies/view.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,22 @@ export default Ember.Controller.extend({
1515
actorNames: Ember.computed.map('model.actors', function(actor){
1616
return actor.get('name').split(' ')[0] + ' ';
1717
}),
18-
hasGoodRating: Ember.computed.gt('model.review', 9),
18+
/* hasGoodRating: Ember.computed.gt('model.review', 9), */
19+
hasGoodRating: function(){
20+
var rate = this.get('container').lookup('application:main').get('awardRate');
21+
return this.get('model.review') >= rate;
22+
}.property('model.review'),
1923
checkReviewChanged: function(e){
20-
if(e.target.router.activeTransition === null){
21-
console.log('Observers');
22-
var amount = this.get('reviewCountChanged');
23-
console.log(amount);
24-
amount++;
25-
this.set('reviewCountChanged', amount);
26-
if(amount === 3){
27-
alert('OBSERVERS - Wait! Do you have any doubts about the movie? then... watch it again! :)');
24+
if(e.target.router.activeTransition === null){
25+
var amount = this.get('reviewCountChanged');
26+
amount++;
27+
this.set('reviewCountChanged', amount);
28+
if(amount === 3){
29+
alert(this.get('i18n').current.reviewChangedValidation);
30+
this.set('reviewCountChanged', 0);
31+
}
32+
}else{
2833
this.set('reviewCountChanged', 0);
2934
}
30-
}else{
31-
this.set('reviewCountChanged', 0);
32-
}
33-
}.observes('model.review')
35+
}.observes('model.review')
3436
});
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Ember from 'ember';
22

33

4-
export default Ember.Handlebars.makeBoundHelper(function(key){
5-
4+
export default Ember.Handlebars.makeBoundHelper(function(container, key){
5+
return this.get('i18n').current[container][key];
66
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import Ember from 'ember';
2+
import enUs from '../locales/en';
3+
import esEs from '../locales/es';
4+
5+
var i18n = {};
6+
7+
var locales = {
8+
'en': enUs,
9+
'es': esEs
10+
};
11+
12+
function setCurrent(application) {
13+
Ember.set(i18n, 'current', locales[application.defaultLocale]);
14+
}
15+
16+
export function initialize(container, application) {
17+
application.register('utils:i18n', i18n, { instantiate: false });
18+
application.inject('route', 'i18n', 'utils:i18n');
19+
application.inject('model', 'i18n', 'utils:i18n');
20+
application.inject('component', 'i18n', 'utils:i18n');
21+
application.inject('controller', 'i18n', 'utils:i18n');
22+
23+
setCurrent(application);
24+
25+
/* application.localeStream.subscribe(function(stream) {
26+
setCurrent(stream.value());
27+
});*/
28+
}
29+
30+
export default {
31+
name: 'i18n-current',
32+
after: 't',
33+
initialize: initialize
34+
};
35+

MarvelWorld-Cli/app/locales/en.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
export default {
22
movie:{
3+
name: "Movies",
34
yes: "YES",
45
noExclamation: "NO!",
56
maxWatches: "(*) The movie with MAX watches has: ",
67
minWatches: "(*) The movie with MIN watches has: ",
78
viewers: "viewers.",
8-
award: "(*) Is there movie with awards?",
9+
award: "(*) Is there movie with awards?",
10+
allActors: "All actors",
11+
summary: "Summary"
912
},
1013
english: "English",
11-
spain: "Spain"
14+
spain: "Spain",
15+
premiere: "premiere",
16+
comingSoon: "coming Soon",
17+
released: "released",
18+
reviewChangedValidation: "OBSERVERS - Wait! Do you have any doubts about the movie? then... watch it again! :)",
19+
total: "Total"
1220
};
21+

MarvelWorld-Cli/app/locales/es.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
export default {
22
movie:{
3-
name: "Movie",
3+
name: "Peliculas",
44
yes: "SI",
55
noExclamation: "NO!",
66
maxWatches: "(*) La película con mayor cantidad de espectadores: ",
7-
minWatches: "(*) La película con menos cantidad de espectadores: ",
8-
viewers: "espectadores.",
9-
award: "(*) Hay peliculas con premiados?",
10-
}
7+
minWatches: "(*) La película con menos cantidad de espectadores: ",
8+
viewers: "espectadores.",
9+
award: "(*) Hay peliculas con premiados?",
10+
allActors: "Todos los actores",
11+
summary: "Resumen"
12+
},
13+
english: "Ingles",
14+
spain: "Castellano",
15+
premiere: "estreno",
16+
comingSoon: "proximamente",
17+
released: "estrenada",
18+
reviewChangedValidation: "OBSERVERS - Momento..pareciera que tienes dudas con la clasificación de la peli..mirala de nuevo! :)",
19+
total: "Total"
1120
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
export default Ember.Mixin.create({
3+
total:function(){
4+
return this.get('model').content.length;
5+
}.property('model')
6+
});

0 commit comments

Comments
 (0)