rodionmoiseev / c10n

A Java library, focused on making internationalisation more modular, easier to evolve and maintain, robust-to-change and IDE-friendly without excess of external tools.
Apache License 2.0
67 stars 10 forks source link

{0} is not replaced with argument value #36

Closed fedotxxl closed 8 years ago

fedotxxl commented 8 years ago

Hello. I configured C10N following way:

C10N.configure(new C10NConfigBase(){
            @Override
            public void configure(){
                install(new DefaultC10NAnnotations());
                setLocaleProvider(() -> Locale.ENGLISH);
            }
        });

and I've got following method:

@En("Can't load page by url {0}")
String pageNotLoaded(String url);

which returns Can't load page by url {0} instead of Can't load page by url MY_CUSTOM_URL

How can I fix it?

rodionmoiseev commented 8 years ago

Hi. One possible problem is that you're calling C10N.get(...) too early, before C10N.configure(...) had the chance to execute.

fedotxxl commented 8 years ago

Nope... Can you tell me class/method which replaces {0} values - I'll try to debug it

rodionmoiseev commented 8 years ago

C10NInvokationHandler#invoke get's invoked first. Then, getStringValue will do most heavy lifting of retrieving the string and formatting it.

rodionmoiseev commented 8 years ago

The above is for ver 1.1

rodionmoiseev commented 8 years ago

Hope this is not too urgent, because I have to go now. If you cannot resolve the issue, please post your full set-up and I will try to reproduce it locally. Thanks!

fedotxxl commented 8 years ago

It was java.text.MessageFormat.format issue - Can't should be replaced with Can''t - http://stackoverflow.com/questions/17569608/format-a-message-using-messageformat-format-in-java

rodionmoiseev commented 8 years ago

omg, that was a nasty one! Thanks! I should probably put it on a wiki somewhere.