Friday, February 15, 2013

AngularJS & i18next, IE

As I mentioned earlier, to be continued...

And so here I am to fully revoke my earlier rant about Javascript Frameworks.
Since I am working with two that I enjoy at the moment: AngularJS and i18next.

I especially enjoyed them once they were integrated using an i18n directive in Angular (SEE BELOW), so it would automatically handle the data-i18n attribute (with a $watch for locale changes).
And created a few custom Maven plugins/tools to handle creating the i18n JSON data per locale.

My favorite aspect is that I was able to recently submit a defect to i18next and have it fixed within hours.
These are both development communities I'd love to contribute to, if I only had the time.

My least favorite is trying to get AngularJS to work with IE7 or really any IE version. I found a solution from trial/error and reading comments (add ng-app id/class, add json2 for http/resource).
Or rather trying to do anything in IE ever.
Seriously, just for example, printing in IE goes and re-requests resources but only sends session cookies, so printing can mess up when these requests return different responses.
Or how about trying to use a select option with handlebar replacement variables under an Angular ng-switch rendering fine except for in IE.
And back button and history not working in IE7 or compat view.
There are really too many to name, I can't keep track.

Although the worst so far was not being able to upgrade to Angular 1.0.4, although I don't blame Angular (yet) and still assume its something wrong on our app.

But ignoring the minor issues, it's great to have frameworks providing the needed UI functionality and ease of deploy/changes. And still falling back on JQuery when needed.

I've added some examples for the approach used to combine AngularJS, i18next and JQuery.
I'm sure this will all be outdated quickly, JS libraries are always changing (versions used were roughly AngularJS 1.0.1-1.0.3 and i18next 1.5.10-1.6.0 with a bugfix in 1.6.1pre).
The i18next init was done in the app run, so it would already be setup with the needed options/defaults.

This directive was added to allow AngularJS to process the data-i18n attribute supported by i18next, and avoid manually calling $.i18n. Also catches changes in the rootScope field 'locale', used with $.i18n.setLng, to update the i18n text.

angular.module('appname').directive('i18n', function () {
    return {
        link: function(scope, element, attrs) {
            scope.$watch('locale', function(newValue, oldValue) {
                if( newValue !== oldValue ) {
            }, true);

This directive allows handling the i18next data-i18n attribute in HTML such as:

<div data-i18n="page.key"></div>

That could handle 90% of cases. But if you need to have parameters replaced in the text, an app function could be used:

$rootScope.i18n = function(key,options) {
  return $.i18n.t(key,options);

This function can be used to replace the parameter {0} in the text (when interpolationPrefix/Suffix are the curly brackets in i18next options):

<div>{{i18n("page.key", {"0": obj.field})}}</div>

Tuesday, February 12, 2013

Batman Rises

finally saw dark knight rises
i really enjoyed it (no surprise, well deserving of the 94+% rotten tomatoes rating)

i think it's a perfect companion to the novel i finished reading earlier, no mans land
with many of the same elements:
batman is out of commission for a while, giving up
gotham city is condemed
the city is a mess and controlled by criminals who are let loose from the prison
a small group of cops are still fighting for the city on their own
batman symbols on the buildings (as a symbol of hope)

but the film is different and much worse is many other ways.
it should really be called batman: no hope
since he really loses everything and gotham is destroyed
instead of an earthquake as in the novel, it is bane kidnapping the city with a nuclear bomb and sealing it off with explosives
batman is almost always one step ahead in the book, and almost always ten steps behind in the movie
batman/bruce's own money and machinery is used against the city
bane is actually quite civil in the book, only playing his small role, he is far from the worst
batman has a lot more help in the book, those who can almost match him (nightwing, robin, batgirl), while the film does have catwoman and not-yet-robin?

Saturday, February 9, 2013

Trek Catchup

i really like the bbc sherlock and i've been catching up with the few episodes there are (like s02e02).

when i heard about the new star trek into darkness possibly featuring the star (cumberbatch) as khan.

so of course today i caught up on my khan-ness.
i watched the original star trek season 1 space seed episode (on hulu, remastered).
and then watched star trek 2 wrath of khan.

then i also heard he could be playing gary mitchell instead,
so i checked out that episode on hulu as well.
between the two i'd vote for this.
it seems to make more sense, with a few scenes matching: the blond on the bridge, gary in the cell.
gary is definitely more dangerous, since he seems almost invincible and can reshape matter on his own (more than khan with genesis)

interesting is the similarities in the characters khan and gary.
both augmented humans in some way.
and both could say they can do "everything" better than kirk.

whether he ends up playing khan or gary or neither, the movie looks great from the trailer.

Friday, February 8, 2013

Batman Animated Beginning, Reading

Just watched batman year one on netflix
awesome beginning stories for batman and gordon
it's really about batman, gordon, and gotham all meeting each other for the first time
and kicking each other's ass until they find their place
well done, i liked the graphics
only downside is how abruptly it ends, making you want more
it stops just short of actually seeing gordon and batman working together

continuing my earlier reading post and somewhat related...

Earlier this week I finished the batman novel, it was good
At first, i thought it was strange to read a book about batman but read nothing about him for the first 1/4 of the book, but it was part of the story
i liked the characters and there were plenty, the story actually feels like a collection of related stories (most likely because it is based on the series of comics)
i thought it was strange to bring in lex luthor but he works as a counter balance to bruce wayne in terms of power/resources (especially in gotham),
also lex is most likely explained through the comics (which included superman)
while reading, i was always waiting for the big bad moments to come, expecting the worst
and i knew there would be a sucker punch at the end,
and there it was right down to the wire in the last few pages

Also in reading,
I started and finished the second volume star wars comic in the series

i'm not a fan of the changing artists and having to adjust to characters new appearance
But after i did, i still enjoyed the story
now waiting for the next 2 to arrive

Sunday, February 3, 2013

Zombie Cinema and Gaming

I saw Warm Bodies at the theater yesterday
sounds like an aweful or cheesy story from the title and even from the description as a zombie love story
it's apparently based on a novel of the same name which sounds very similar in its summary to the film
but i was pleasantly surprised, i really ended up enjoying it
especially the internal monologue at the beginning
it was really funny, i would totally watch it again
the big baddies (bonies) in the movie look a lot like immolators from zombie master, fast blackened skeletal zombies except not on fire

In related news, zombie gaming over the weekend
mostly zombie multiplayers with headset on steam: left4dead, zombie master, killing floor
zm is still awesome for being a dated game with few servers and players, and maps focused little on zombies and more on random challenges and traps
i was surprised to realize i actually like killing floor now. i disliked it initially from being tough and dying, which still happens on single player, but multi is fun,
even with team killers, and mods killing team killers, even accidental (hey don't walk right in front of my spray haha).