JxBrowser allows configuring Chromium engine with specified language (two letter code from ISO-639 e.g. "en", "de", "it", etc). The language will be used for UI text messages localization (e.g. text on the web page that's displayed when Chromium failed to load URL).


By default Chromium engine is configured to use Java application language that can be received from the user.language System Property. To configure Chromium engine with Java application language, JxBrowser extracts the language from user.language System Property and pass it to Chromium engine via the --lang Chromium switcher.


If you need to change this default behavior, then you can configure Chromium engine directly with specified language via Chromium --lang switcher. Here's examples that show how Chromium engine will display localized text on the Navigation Failed web page:


Configure Chromium with English language (en)

public class BrowserSample {
    public static void main(String[] args) {
        BrowserPreferences.setChromiumSwitches("--lang=en");

        Browser browser = new Browser();
        BrowserView view = new BrowserView(browser);

        JFrame frame = new JFrame();
        frame.add(view, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setVisible(true);

        browser.loadURL("http://123.nonexisting.url");
    }
}

Screen Shot 2015-11-04 at 00.35.24.png

Configure Chromium with German language (de): 

public class BrowserSample {
    public static void main(String[] args) {
        BrowserPreferences.setChromiumSwitches("--lang=de");

        Browser browser = new Browser();
        BrowserView view = new BrowserView(browser);

        JFrame frame = new JFrame();
        frame.add(view, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setVisible(true);

        browser.loadURL("http://123.nonexisting.url");
    }
}

Screen Shot 2015-11-04 at 00.35.58.png