13.5. Globalization and Bebop

Bebop is enabled to use GlobalizedMessages wherever the localizable content is displayed to the user.

To display localized content to the user using Bebop, pass a GlobalizedMessage to the Bebop widget. For example, to write a globalized HelloWorld page using Bebop:

package com.arsdigita.helloworld;

import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Page;
import com.arsdigita.dispatcher.Dispatcher;
import com.arsdigita.globalization.GlobalizedMessage;

public class HelloWorldDispatcher extends Dispatcher {
    // do some stuff, set up URL to method map, etc.

    private Page buildHelloWorldPage() {
        Label message = new Label(new GlobalizedMessage(
            "hello_world",
            "com.arsdigita.helloworld.HelloWorldResources"
        ));

        Page page = new Page(message);
        page.add(message);
	page.lock();
	return page;
    }
}

When the Page is served, Bebop will automatically call the localize(java.util.Locale) method of each of the GlobalizedMessages on the Page with the Locale of the current request as an argument. This will allow the pages to be displayed to each user in his or her preferred language.