* work around missing JFX WebView navigator.language settings

This commit is contained in:
Reinhard Pointner 2015-06-12 10:44:44 +00:00
parent 53aadcd8ae
commit 2602dc20ef
2 changed files with 5 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import static net.filebot.Settings.*;
import java.awt.Desktop; import java.awt.Desktop;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.net.URI; import java.net.URI;
import java.util.Locale;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -75,6 +76,9 @@ public class GettingStartedStage {
// force black background while page is loading // force black background while page is loading
setBackground(webview.getEngine(), 0xFF000000); setBackground(webview.getEngine(), 0xFF000000);
// make sure that we can read the user locale in JS
webview.getEngine().executeScript(String.format("navigator.locale = '%s'", Locale.getDefault()));
} }
public void show() { public void show() {

View File

@ -49,7 +49,7 @@ function getData() {
}] }]
var links = location.hash.length > 0 var links = location.hash.length > 0
var youtube = !(/zh(.CN)?/i).test(navigator.language) // YouTube is blocked in China (mainland) var youtube = !(/zh(.CN)?/i).test(navigator.locale ? navigator.locale : navigator.language) // YouTube is blocked in China (mainland)
if (links) { if (links) {
data = data.slice(0, 5) // use only tutorial images data = data.slice(0, 5) // use only tutorial images