Skip to content
This repository has been archived by the owner on May 9, 2019. It is now read-only.

Nav controller initialization failure in Japan locale #161

Open
chang-chao opened this issue Oct 11, 2017 · 1 comment
Open

Nav controller initialization failure in Japan locale #161

chang-chao opened this issue Oct 11, 2017 · 1 comment

Comments

@chang-chao
Copy link

chang-chao commented Oct 11, 2017

The initialization code below in webGateway/controllers/Nav.java fails in Japan locale.

    private static final PrettyTime prettyTime = new PrettyTime();
    static {
        prettyTime.removeUnit(JustNow.class);
        ResourcesTimeUnit justNow = new ResourcesTimeUnit() {
            {
                setMaxQuantity(10000);
            }
            @Override
            protected String getResourceKeyPrefix() {
                return "JustNow";
            }
        };
        prettyTime.registerUnit(justNow, new ResourcesTimeFormat(justNow));
    }

to reproduce it ,we can just change the first line to

PrettyTime prettyTime = new PrettyTime(Locale.JAPAN);

It will fail with the following exception:

Exception in thread "main" java.util.MissingResourceException: Can't find resource for bundle org.ocpsoft.prettytime.i18n.Resources, key Pattern
	at java.util.ResourceBundle.getObject(ResourceBundle.java:450)
	at java.util.ResourceBundle.getObject(ResourceBundle.java:444)
	at java.util.ResourceBundle.getString(ResourceBundle.java:407)
	at org.ocpsoft.prettytime.i18n.Resources_ja$JaTimeFormat.(Resources_ja.java:148)
	at org.ocpsoft.prettytime.i18n.Resources_ja.getFormatFor(Resources_ja.java:117)
	at org.ocpsoft.prettytime.impl.ResourcesTimeFormat.setLocale(ResourcesTimeFormat.java:34)
	at org.ocpsoft.prettytime.impl.ResourcesTimeFormat.setLocale(ResourcesTimeFormat.java:16)
	at org.ocpsoft.prettytime.PrettyTime.registerUnit(PrettyTime.java:472)

this is because the getUnitName(TimeUnit) method of JaTimeFormat class cannot properly get the unit name in case of anonymous TimeUnit class(An empty string is returned).

        private String getUnitName(TimeUnit unit) {
            return unit.getClass().getSimpleName();
        }
@chang-chao
Copy link
Author

chang-chao commented Oct 11, 2017

Possibly it is an issue of PrettyTime,instead of this project.

@chang-chao chang-chao changed the title Nav controller initialization failure in some locales Nav controller initialization failure in japan locale Oct 12, 2017
@chang-chao chang-chao changed the title Nav controller initialization failure in japan locale Nav controller initialization failure in Japan locale Oct 12, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants