Categories
main mozilla tech

Reducing MozL10n+Gaia technical debt in Firefox OS 2.1 cycle

Firefox OS is becoming a more mature platform, and one of the components that is maturing with it is the mozL10n library.

In 2.0 cycle, which is already feature complete, we introduced the codebase based on the L20n project.

The 2.1 cycle we’re currently in is a major API cleanup effort. We’re reviewing how Gaia apps use mozL10n, migrating them to the new API and minimizing the code complexity.

Simplifying the code responsible for localizability of Firefox OS is crucial for our ability to maintain and bring new features to the platform.

There are four major areas we’re working on:

  • mozL10n.translate – with introduction of Mutation Observer, we want to phase out manual DOM translation calls.
  • mozL10n.localize – this function is extremely hard to maintain and does enough “magic” to confuse devs.
  • mozL10n.get – manual l10n gets are the biggest cause of bugs and regressions in our code. They are synchronous, not retranslatable and badly misused
  • mock_l10n – many apps still use custom MockL10n class in tests, some even use real MozL10n code in tests. This makes testing harder to maintain and develop new l10n features.

We’re working on all four areas and would love to get your help.

No matter if you are a Gaia app owner, or if you’ve never wrote a patch for Gaia. If you know JavaScript, you can help us!

All of those bugs have instructions on how to start fixing, and I will be happy to mentor you.

We have time until October 13th. Let’s get Gaia ready for the next generation features we want to introduce soon! 🙂

Categories
main mozilla tech

Localization framework changes in Firefox OS 2.0 and plans for 2.1

On Monday we branched Firefox OS 2.0 which is the first branch to contain a new localization library that has been developed by my team.

What landed for 2.0

Library landing and reactions

The library itself landed exactly two months ago. In order to avoid any potential regressions, we’ve put a lot of work to ensure that it matches the behavior of the old code that it replaced. I believe we can now claim a success, because with two months of baking on master we didn’t get any serious regressions that would require us to change anything in our code.

The new library comes with a lot of unit tests and is stricter than the old code, so we had to fix a couple of small bugs where code has been passing an object instead of a string to our API and one related to one test failing on old machine with too little memory. That’s been simple to catch and fix.

We also got a few requests to improve the console log output and error output that the library produces in order to simplify developers work.

New features

Pseudo-locales

The major new thing that Stas completed in this cycle is the support for pseudo-locales. While this could be done with the old code, it was significantly easier with the new code thanks to some architectural decisions like separation of buildtime and runtime code.

Pseudo-locales allow developers to evaluate their UI’s localizability against an artificially generated english-like locale to catch any hardcoded strings. It also generates right-to-left locale for testing purposes. Before that, we’ve been relying on often outdated localizations that we kept with our source code. Now we can always test against fully generated pseudo localization.

mozL10n.once wrapper

Another new feature is the introduction of mozL10n.once wrapper. We identified that a lot of Gaia apps are waiting for localization to be ready before they initialize themselves. That makes sense since a lot of those apps want to work with UI and localized strings, but the challenge in asynchronous world is that you never know if your code has been fired after or before mozL10n is ready.

Because of that, simply setting an event listener and waiting for window.onlocalized event is not enough (what if it already has fired before your code was launched?). Developers were using mozL10n.ready wrapper, but the problem with that is that is has been designed to re-fire on reach retranslation which meant that your init code has been fired every time user changed language. That’s not an intended behavior, but admittedly a rare one. What’s worse is that we retained all the init code in memory.

Now, with mozL10n.once we can safely initialize code when l10n resources are available and free the memory right after that.

Uses of l10n API

On top of adding new features, we’ve been mostly busy investigating and improving how the default Firefox OS apps interact with localization API. That led to multiple design decisions including introduction of the described above mozL10n.once.

Once we got the new wrapper, we started analyzing bootstrapping code of each and every Gaia app and updating it to use the proper L10n API. Twenty two fixed bugs later, we’re done!

It’s incredible how much we were able to accomplish in just two short months. We feel much better right now about the bootstrap process and we have a clear picture on what we want to do next.

Use new navigator.languages API

Thank’s to Mounir’s work on navigator.languages API and implementation we were able to remove the only Mozilla specific API in mozL10n. That means that mozL10n should work in any modern browser now!

What we’re working on for 2.1

2.1 will be as ambitious for us as 2.0 was. The hashtag of the work is still #cleanup, but now it’s much more about modifying our API so that it’s more transparent to developers and requires less manual code in their apps.

entity.attributes become node attributes

First thing we were able to land is the transition away from assigning l10n entity attributes as node properties. We cleaned up the hacks that have been used and switched to entity attributes as node attributes.

DOM overlays

Next, we have one leftover from the previous change and that is an infamous innerHTML. We currently don’t have any clear way to inject localizable DOMFragment in Gaia. Fortunately, we have one that fits perfectly in L20n. It’s called DOM Overlays, and we’re working on getting them into mozL10n. That will allow us to further secure L10n API and remove any innerHTML calls.

Mutation Observers

Majority of localizability code in Gaia apps is related to localization of DOM nodes. With Mutation Observers we will be able to significantly reduce the amount of manual calls to mozL10n API and make majority of calls be just about settings data-l10n-id attribute with Mutation Observers doing the rest.

Not only will it reduce the use cases of mozL10n.translate and mozL10n.localize, but I expect to be able to cut by over 50% the number of manual mozL10n.get calls and manual operations that are currently used to set the result of that call into the node.

Mutation Observers will simplify Gaia code, reduce the amount of bugs related to language switching and get us closer to runtime l10n API that we want to offer for Gecko.

Bootstrap

There are still some interesting edge cases around how code boostrapping relies on particular pieces of environment. Does your code need DOM to be interactive? Does it need l10n resources to be loaded? Or maybe you need DOM to be localized? All those events happen asynchronously and we currently do not have a clean way to guard against any combination of those that your init code may require.

We’re working on a bootstrapping wrapper that will allow app developers to simply define which pieces of environment should their initialization be blocked by.

That will further secure the app boostrapping process and limit the risk of condition races.

mozDOMLocalized

One part of the bootstrap puzzle is how we fire event when certain bootstrap things happen. Right now we fire window.onlocalized event that means that mozL10n resources have been loaded, but doesn’t tell us anything about if document’s DOM has been localized (and is ready to be displayed).

With the work on the new event, we’ll be able to remove the global one, and settle on triggering on event on document and one on mozL10n object. Did I tell you that we’re still cleaning up? 🙂

Move mozL10n to document

We originally placed mozL10n object as a property on navigator object. Because our API is transitioning to be per-document, it becomes an inconsistency and an obstacle to keep mozL10n API on navigator object. It hardly fits the world with iframes, ShadowDOM and HTML Templates. We’re going to move it to document.mozL10n.

Remove inline l10n

One of the built time optimizations that we have in Gaia is called inline l10n. We store some portion of the l10n resources within each HTML file in order to localize the UI before it is displayed. It’s not very scalable, costs us memory and performance, but historically helped us prevent flashes of untranslated content. We hope to be able to remove this optimization in this cycle which will significantly simplify our internal code and give us some small memory and performance wins.

Is this L20n yet?

While we introduce L20n concepts into mozL10n, we’re still pretty far from being able to say that we support L20n API in Gaia. There’s a lot of work to do and it’s going to be a challenging work as we port L20n concepts to Gaia, and merge lessons we learned while working on Gaia into L20n spec and implementation. What we hope to end up with is a single codebase used in Gaia and offered to web developers.

It’s an exciting journey and I’m so happy to make Firefox OS’s localizability the most modern among all OSes!

Categories
main mozilla tech

L20n – what to add before 1.0

As I mentioned in my last blog post, we’re narrowing down the list of features that we’re willing to consider for inclusion into L20n 1.0 prior to its freeze and release.

Here’s the list:

Name Driver Target Milestone
difference between entities/macros from the resource and variables provided by the developer stas 1.0
difference between public and private attributes/entities gandalf 1.0
default values for hashes/arrays gandalf 1.0
globals namespace gandalf 1.0
import command gandalf 1.0
conditional blocks gandalf 1.0
value as ID (gettext mode) stas ?
string as ID (simple gettext mode) stas ?
key as string stas ?
relative referrals gandalf 1.0
dependency list gandalf 1.0
computer readable comments gandalf ?
multi-language resource files gandalf 1.0
Switch expression gandalf ?
attribute indexes stas 1.1
nested indexes gandalf 1.0
Expression errors gandalf 1.0
workflow gandalf 1.0
resource file syntax stas (support from: kaze, fantsai) 1.0
forbid referencing public entities stas ?
Macro attributes gandalf ?

All of those features represent some feedback item we got and we’re trying to evaluate it ASAP in order to finalize the parser/interpreter couple and work on the workflow toolchain for L20n 1.0 next.

If you want to discuss any of the items, join our localization-20 group and start a new thread for each feature.

If you want to add a new feature to be considered, start a wiki article in L20n/Features namespace.

 

Categories
main mozilla tech

L20n, feedback round

Last months have been extremely busy for L20n. I basically focused 100% of my time on the project, driving simultaneously multiple aspects of the project to completion.

L20n is a very complex project, not only technically, but also socially. Localization technologies have always been of minor importance for most of the software world so we never really develop technologies that could anyhow match the complexity of the human languages. The most common mindset, even among those who have to deal with localization, is that you can get “most of the stuff” done with simple key-value pair lists where English string is a key, and target localization string is a value.

It’s a bit like claiming that most of Firefox front end could be written in BASIC.

L20n is on the other side of the spectrum. It brings the localization technology to the new level, and in result breaks almost all paradigms of what people are used to do with l10n and breaks how it “usually works”.

In result, the major challenge when helping someone learn what L20n is, is to convince the person that she has to stop trying to match its components to the concepts the person knows from other l10n frameworks. It will just not do.

The reward is that once you get beyond the game of “how does L20n relate to Gettext / DTD / Properties?” people get into the “Oooh!” moment and what follows is a litany of ideas of what would be nice to have if we are about to reinvent the localization technologies. I love it 🙂

As many project leaders before me have observed, getting close to a target milestone always turns you from a visionary leader that sets the goals and drives them to completion into some sort of a butcher that says “no” to everything except the most crucial additions in the fear of never ending cycle of adding more and more without getting your project released.

So here we are. For the last month we’ve been working pretty close with several projects – Boot 2 Gecko, Jetpack, Firefox – and we got plenty of feedback, from minor additions to major suggestions. Now is the time to narrow down the list of changes we’re ready to incorporate for 1.0, close the list, work toward the release, and push everything else back to L20n:Next.

In the next blog post I’ll list the proposals and the status of the discussion on those.

Categories
main mozilla tech

Mozillians on Digital Freedom

Matjaz wrote a blog post on his presence in ACTA debate in Slovenia. With multiple interviews, shows and a speech at a government organized roundtable discussion, Matjaz became an ad-hoc representative of our collective in front of the audience that we rarely interfere with. That is just awesome Matjaz! Congratulations, dude!

But it’s not only Matjaz! Mozillians have been active all around Europe in the public debate on ACTA. Me and StaÅ› have been both helping the civic NGO side on ACTA front in Poland, Otto in Estonia, and Bogo in Sofia, just to mention a few.

Three things that strike me about this are:

1) The whole generation of Mozillians who gained their experience by shaping local Mozilla communities in Europe are now becoming respected public figures precisely because of what we are doing at Mozilla project. For years we’ve been responding to what was needed, adapting to the changing landscape on the cross of the local and global Web, growing up to roles that had to be filed. It’s amazing to see that our experience and cred gained by fighting for the Open Web is now placing us in the spotlights when the future of the Internet is being debated.

2) We all seem to intuitively build our positions on a small set of principles that we wrote just a few years ago.
I remember the time when Gerv has been driving the conversation at FOSDEM trying to isolate the limited set of statements and principles that unite us, Mozillians, and I even remember voices questioning the need for such a document arguing that we were successfully able to raise and grow our project without it.
These days, the very first thing that we do when we face something that we intuitively feel is wrong for the Internet, is that we cross check it against the Mozilla Manifesto.

We are united under this manifesto, it does work as a written summary of what we believe in and now it serves us as a point of reference when we face proposals that are not in line with the Internet that we want to see. Just take a look at Polish Mozilla Community position on ACTA, or read Matjaz’s speech.

It  grows far beyond what we originally expected and everyone who worked on this document should be proud now. I certainly am!

3) As individuals, but also as representatives of Mozilla project, we are being asked to speak, because people want to know what Mozilla thinks. It’s important. Like in all other debates that we took part in, web standards, browser wars, web video formats or privacy, Mozilla has a unique role and it’s fundamental for us to walk this thin line of subtle balance that we aim for with our hybrid nature. I’m particularly proud to read Mitchell’s words and also journalists commenting on our statement in a way like the following:

Essential statement on ACTA by Polish Mozilla Community
(…)
It’s worth pointing out, that the community’s position is very rational, calm and stripped of the emotions that are driving most of the conversation these days.
(…)
Polish PM, Donald Tusk, has said that Poland will not ratify ACTA if the there will be any doubts, and this statement by the community clearly presents those that are of vital importance for the information society.
(…)
The statement written by the Mozilla community in Poland is important for yet another reason. Its authors are not connected to any market player. Mozilla Community is not an NGO or political organization. Usually, Mozilla and its community do not comment law related topics.
(…)
Those are the people that usually avoid law related topics focusing on their great, a bit crazy vision.
Apparently what has happened, made them feel they have to speak up.

In cases like SOPA in US or ACTA in Europe, Mozilla DNA that has shaped all of us, is being injected and influences the debate in a profound way.
The same vision that has shaped Firefox, Thunderbird, Drumbeat and tons of other projects and products, and through this influenced how the Web looks like today on both, technological and social layer, has also shaped our minds and beliefs, and through this is now impacting the public debate that is being held all around the world on the future of the Interent.

Isn’t that just amazing?

p.s. We’re igniting a newsgroup devoted to the topic of digital freedom. Join us there!

Categories
main mozilla tech

simple bash script to recompile libxul

Since I started working on L20n bindings for XUL I always felt frustrated that our build system cannot properly recompile the dependencies. When I work on XUL I’d like to just be able to type:

cd ./content/xul;
make;

and be done with it.

Unfortunately, for the reasons that are beyond my level of understanding, it never worked this way. Fortunately, the bits that you have to recompile are always the same so I created a small bash script that recompiles what I need plus the dependency:

DIR="$( cd "$( dirname "$0" )" && pwd )"

cd $1 && 
make &&
cd $DIR/layout &&
make &&
cd $DIR/toolkit/library &&
make

Just place it in your build-dir and then:

./rebuild.sh ./content/xul

will do the rest

enjoy!

 

Categories
main mozilla tech

Perceived proximity on the Web

Over the years of traveling around the world to evangelize about Open Web and explaining the position and role Mozilla holds, I’ve encountered an interesting phenomena that I tried to put into a social context for quite some time.

My last trip to China, where I had met with Mozilla community in Shanghai triggered me to write about it, so here it comes.

The Web

The Web is a virtual plane on which human interact. It’s an incredible and amazing plane which breaks a vast number of physical laws and, in consequence, economical laws, biological laws, psychological laws, and, maybe in a most profound way, social laws.

From the social perspective, the web changes everything because  it holds an unprecedented characteristic:

The Web almost fully neutralize three basic physical dimensions in which humans operate, and, if that was not enough, it also severely limits the fourth one – time!

Think about it for a moment, please. Isn’t it mind blowing that we’re here, now, as it happens?

Spatial dimensions

Things on the Web are equally “close” to each Web user and the “dimension” that is closest to replace spatial distance – connection speed – is just a temporary factor that is disappearing over the course of a few years becoming ignorable itself.

It may not be the first invention that reduces the eternal impact of spatial dimensions on human life – cars, planes, mail, they all contributed to the sense of the world getting smaller, but the Web just cut it off entirely. You have access to this text from each place on Earth at the very same moment and you can build meaningful connections with everyone on the planet using the same techniques we use to build connections with our neighbors.

The laws of physical proximity and its impact on our social life is being transferred onto the Web and suddenly everyone is socially close to everyone else.

Time

Similar shift happens with the fourth dimension. With mobiles devices, laptops, SMS, video chats, forums, and push&pull notification systems we’ve not only overcame physical distance limitations but we also built a plethora of technologies to store, in a lossless mode, every data byte transferred between human beings. Every piece of communication. Every smile, every word, every information, story or emotion that we manage to encode into any of the digital communication channels may be stored, multiplied, transformed and replayed forever.

Once again, the Web is not the first medium to do it, books, photographs, CD’s, vinyl and cameras where there before, but the Web brought it to the next level. Everything that manages to fit the web can be ripped of action-time limitation. It doesn’t matter when it happens, and how far did it happen. I can record my fingers typing this text and broadcast them to everyone around the world plus let anyone interested watch it in 100 years. All this interesting social/cultural/memetic implications about your daughter reading your blog posts from when you were sixteen kick in!

And the price limes is zero! It costs almost nothing and it will cost less and less! (making economy laws not fit anymore).

Physical vs. virtual

Hola, hola! – as many of my spanish fluent friends would say – but that’s all virtual. Yes, we removed spatial and time dimensions but only from information. Nothing changes in the realm of physical objects. No teleportation, no time travels, right? Right!

Categories
main mozilla tech

Pontoon has a new leader!

Oh, Pontoon, hi! When we introduced the idea of Pontoon on the forum of Mozilla Planet, it generated quite a lot of positive comments, but nothing close to what has happened when we showed the first live demo (Shaver did!) at Mozilla All-Hands in 2010.

Pontoon represents what, I believe, will be the future of web localization and I tried my best to rush it to the point where we will be able to verify if such an approach is realistic, but from there, I failed to find enough time to give this project the love it deserves.

Worry not, great ideas don’t perish, and it sometimes takes a vacuum to appear for a new leader to step in!

I had luck to drive Pontoon to the point where it attracted several souls from Mozilla community to keep pinging me, keep asking about it, and, what’s always the best result of an idea, to act.

In particular one gentleman, my long time friend from Slovenia – Matjaž Horvat, stepped up and took what was there, turned a crank, wrote some code, draw a mockup, moved pieces around, stitched it a bit, and probably invoked some primal magic to assemble new version of it, available here – http://horv.at/pontoon/.

He was able to take the source code to the next level and covered up the visual appearance and user experience zone which has been sorta ignored since we started and needed love. He was also willing to jump in and join me and we’re lucky enough to get Mozilla backing for this project which resulted in Pontoon having a new leader!

I’m proud to announce that I’m stepping down from Pontoon leadership position and Matjaz is taking over! I’ll be serving him as a mentor and a peer and I’m absolutely confident that the baby is in the right hands!

Please, join me in congratulating Matjaž!

You can also track his progress at http://horv.at/blog/ and on Twitter.:)

Categories
main mozilla tech

Thunderbird to become the default in Ubuntu!

Great news from Budapest where Ubuntu project is holding their version of our All Hands 😉

According to Michael Larabel Thunderbird will become the default choice for Ubuntu’s mail/newsgroup client! That’s a strong prove of progress that Thunderbird has made, and trust me, Ubuntu does not swap the defaults that easily.

Well, it now seems that we’ll have two of our products used as pretty important defaults in this most popular Linux distribution – Firefox and Thunderbird! (although we do have a strong competition for the browser slot).

Congratulations to the team working on Thunderbird!

Categories
main mozilla tech

Falsy Values – volunteer opportunity

In just about a week Warsaw will be hosting a major JavaScript event – Falsy Values.

Falsy Values is brought to you by the two people – Damian Wielgosik and PaweÅ‚ Czerski – who made their way onto the Web Event Stage last year with their widely praised Front-Trends conference.

This year, they focus on hardcode JavaScript. This conference is not about soft disciplines, not about social science, it’s solely about hacking the modern Web.
With stellar workshops and talks, with names such as Douglas Crockford, Tantek Çelik, Tom Hughes-Croucher and our homegrown stars like Kornel “porneL” LesiÅ„ski, it has what it takes to be the powerful event to be at.

Now, such an event is not going to happen on its own, it takes passion, dedication and the one thing we all should value most – time – to shape it up and deliver.

One of the unique features of this conference is that it really is handmade by those two fellows who work 24/7 right now to plug all the cables in the right slots, bring supply to the tables and speakers to the microphone.

All hands on deck!

As you may have guessed from the title – we believe we could use some help during the event itself!

If you’re located in Warsaw, or if you will be here for the time of the event, and you’re looking for a chance to participate in what’s going to happen there, help us make it perfect, learn the unique lesson from behind the scenes, here’s your chance!

We’re looking for geeks who seek experience in helping us run this event. Several brave souls to support speakers, guide the crowd through the agenda, run fiercely to aid some brother in JavaScript arms who’s in danger of any kind (like – you know that moment when your WiFi doesn’t work?)

We expect you to be there with us (even an hour before the opening), assist when needed and enjoy the conference. We offer an opportunity to learn, gain experience and help us make the best event in the JavaScript world since Brendan invented this monster!

Get in touch with us! Email me (gandalf at mozilla dot org)  or contact Damian and PaweÅ‚ directly and we’ll go from there. Hurry up, we only have 5-7 slots available!