Test your app from right to left

Can you spot the error in the following webpage?


Unless you are one of the 56 million Internet users who read Arabic, the answer is probably no. But BidiChecker, a tool for checking webpages for errors in handling of bidirectional text, can find it:


Oops! The Arabic movie title causes the line to be laid out in the wrong order, with half of the phrase “57 reviews” on one side of it and half on the other.

As this example demonstrates, text transposition errors can occur even if your web application is entirely in a left-to-right language. If the application accepts user input or displays multilingual content, this data may be in one of the right-to-left languages, such as Arabic, Hebrew, Farsi or Urdu. Displaying right-to-left text in a left-to-right environment, or vice versa, is likely to cause text garbling if not done correctly. So most user interfaces, whether left-to-right or right-to-left, need to be able to deal with bidirectional (BiDi) text.

Handling BiDi text can be tricky and requires special processing at every appearance of potentially BiDi data in the UI. As a result, BiDi text support often regresses when a developer adds a new feature–and fails to include BiDi support in the updated code.

Called from your automated test suite, BidiChecker can catch regressions before they go live. It features a pure JavaScript API which can easily be integrated into a test suite based on common JavaScript test frameworks such as JSUnit. Here’s a sample test for the above scenario:


// Check for BiDi errors with Arabic data in an English UI.
function testArabicDataEnglishUi() {



 // User reviews data to display; includes Arabic data.



 var reviewsData = [



 

 {'title': 'The Princess Bride', 'reviews': '23'},


 

 {'title': '20,000 Leagues Under the Sea', 'reviews': '17'},


 

 {'title': 'ستار تريك', 'reviews': '57'} // “Star Trek”



 ];





 // Render the reviews in an English UI.


 var app = new ReviewsApp(reviewsData, testDiv);


 app.setLanguage('English');



 app.render();







 // Run BidiChecker.



 var errors = bidichecker.checkPage(/* shouldBeRtl= */ false, testDiv);



 // This assertion will fail due to BiDi errors!



 assertArrayEquals([], errors);

}

We’ve just released BidiChecker as an open source project on Google Code, so web developers everywhere can take advantage of it. We hope it makes the web a friendlier place for users of right-to-left languages and the developers who support them.

By Jason Elbaum, Internationalization Team

Make your websites run faster, automatically — try mod_pagespeed for Apache

Last year, as part of Google’s initiative to make the web faster, we introduced Page Speed, a tool that gives developers suggestions to speed up web pages. It’s usually pretty straightforward for developers and webmasters to implement these suggestions by updating their web server configuration, HTML, JavaScript, CSS and images. But we thought we could make it even easier — ideally these optimizations should happen with minimal developer and webmaster effort.

So today, we’re introducing a module for the Apache HTTP Server called mod_pagespeed to perform many speed optimizations automatically. We’re starting with more than 15 on-the-fly optimizations that address various aspects of web performance, including optimizing caching, minimizing client-server round trips and minimizing payload size. We’ve seen mod_pagespeed reduce page load times by up to 50% (an average across a rough sample of sites we tried) — in other words, essentially speeding up websites by about 2x, and sometimes even faster.

Video comparison of the AdSense blog site with and without mod_pagespeed

Here are a few simple optimizations that are a pain to do manually, but that mod_pagespeed excels at:

  • Making changes to the pages built by the Content Management Systems (CMS) with no need to make changes to the CMS itself,
  • Recompressing an image when its HTML context changes to serve only the bytes required (typically tedious to optimize manually), and
  • Extending the cache lifetime of the logo and images of your website to a year, while still allowing you to update these at any time.

We’re working with Go Daddy to get mod_pagespeed running for many of its 8.5 million customers. Warren Adelman, President and COO of Go Daddy, says:

“Go Daddy is continually looking for ways to provide our customers the best user experience possible. That’s the reason we partnered with Google on the ‘Make the Web Faster’ initiative. Go Daddy engineers are seeing a dramatic decrease in load times of customers’ websites using mod_pagespeed and other technologies provided. We hope to provide the technology to our customers soon – not only for their benefit, but for their website visitors as well.”

We’re also working with Cotendo to integrate the core engine of mod_pagespeed as part of their Content Delivery Network (CDN) service.

mod_pagespeed integrates as a module for the Apache HTTP Server, and we’ve released it as open-source for Apache for many Linux distributions. Download mod_pagespeed for your platform and let us know what you think on the project’s mailing list. We hope to work with the hosting, developer and webmaster community to improve mod_pagespeed and make the web faster.

By Richard Rabbat, ‘Make the Web Faster’ initiative

Styled Static Maps Launches

Last week at Google Developer Day 2010 in Sao Paulo, Brazil we launched support for Styled Maps in the Static Maps API. This comes on the heels of our launch of Styled Maps in the Maps API for Flash two weeks ago and now means that developers can use Styled Maps in the Maps JavaScript API, the Maps API for Flash and the Static Maps API. The Static Maps API is useful for those who want to display a map in a browser where Javascript or Flash isn’t supported or to create a lightweight thumbnail map.

To use it simply specify one or more “style” parameters in your query string, like this:

style=feature:featureArgument|element:elementArgument|rule1:rule1Argument|rule2:rule2Argument

Here’s an example creating a Halloween themed static map of Sao Paulo:


http://maps.google.com/maps/api/staticmap?sensor=false&size=500x300&zoom=9&center=Sao+Paulo+Brazil&style=feature:water|saturation:100|hue:0xff5e00|gamma:0.58&style=feature:landscape|invert_lightness:true&style=element:labels|visibility:off&style=feature:poi|hue:0x0800ff|ligtness:-70&style=feature:administrative|element:geometry|visibility:off

Google Developer Days and DevFests are a chance to learn about Google’s developer products and meet the engineers who work on them. With GDD Brazil finished, I attended DevFest Argentina to give presentations on the Maps APIs, Earth API, KML and Fusion Tables. Following that we’ll have events in Munich, Moscow and Prague. Hope to see you on the (now more styled) road.

Posted by Ossama Alami, Google Geo Developer Relations