face-config по умолчанию требует кодировки переопределения сообщений - PullRequest
0 голосов
/ 19 марта 2019

У меня есть многоязычный проект с использованием различных языков, и я создал UTF8-Control, который я определил в моем файле face-config.xml, он отлично работает с моими файлами .properties для всех языков.

, затем я переопределяюjavax.faces.component.UIInput.REQUIRED = {0} странный ответ.в пользовательском интерфейсе, когда мне нужно требуемое сообщение на немецком языке, тогда я получаю имя вирд benötigt.

эта проблема появляется только тогда, когда я пытался использовать пользовательские переопределения сообщений, например

javax.faces.component.UIInput.CONVERSION javax.faces.converter.DateTimeConverter.DATE_detail

у меня сложилось впечатление, что мой UT8Control не используется для преобразования этого текста (это также было верно, когда я попытался отладить)

мой класс UTF8Control здесь

public class UTF8Control extends ResourceBundle.Control {
@Override
public ResourceBundle newBundle
    (String baseName, Locale locale, String format, ClassLoader loader, boolean reload)
        throws IllegalAccessException, InstantiationException, IOException
{
    // The below is a copy of the default implementation.
    String bundleName = toBundleName(baseName, locale);
    String resourceName = toResourceName(bundleName, "properties");
    ResourceBundle bundle = null;
    InputStream stream = null;
    if (reload) {
        URL url = loader.getResource(resourceName);
        if (url != null) {
            URLConnection connection = url.openConnection();
            if (connection != null) {
                connection.setUseCaches(false);
                stream = connection.getInputStream();
            }
        }
    } else {
        stream = loader.getResourceAsStream(resourceName);
    }
    if (stream != null) {
        try {
            // Only this line is changed to make it to read properties files as UTF-8.
            bundle = new PropertyResourceBundle(new InputStreamReader(stream, UTF_8));
        } finally {
            stream.close();
        }
    }
    return bundle;
}

@Override
public Locale getFallbackLocale(String name,
                                        Locale locale) {
    // see super @return description. Return null for no fallback locale
    return null;
}}
...