Note: Advice in this article will only work for JxBrowser 6. See the corresponding article for JxBrowser 7 here.(注意:本文中的建议仅适用于JxBrowser6,JxBrowser7相应文章请点击这里。)


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).(JxBrowser允许使用指定的语言(ISO-639中的两个字母代码,例如“ en”,“ de”,“ it”等)配置Chromium引擎。该语言将用于UI文本消息的本地化(例如,Chromium无法加载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.(默认情况下,Chromium引擎配置为使用可从user.language系统属性接收的Java应用程序语言。要使用Java应用程序语言配置Chromium引擎,JxBrowser将从user.language系统属性中提取该语言,然后通过--lang Chromium切换器将其传递给Chromium引擎。)


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:(如果您需要更改此默认行为,则可以通过Chromium --lang切换器直接使用指定的语言配置Chromium引擎。以下示例显示了Chromium引擎如何在“导航失败”网页上显示本地化文本:)


Configure Chromium with English language (en)(使用英语配置Chromium(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): (使用德语(de)配置Chromium:)

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