-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading locale-sensitive external resources #2
Comments
I support your idea! Also, is it possible to allow such definitions like en_US, en_UK, etc. taking into account both the language and the country rather than just the language only? |
Thanks! Sure, you would be able to do that, because annotations can be bound to any See how the default annotations are bound for reference: https://github.com/rodionmoiseev/c10n/blob/master/core/src/main/java/c10n/annotations/DefaultC10NAnnotations.java#L43 |
I've already knew about Locale(). Sorry that my suggestion is not so direct: can it be done for annotations like @en_US, @en_UK, etc.? |
Sure! Just declare your own annotation: @Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface en_US {
String value();
} and bind it to the right locale, somewhere in your configuration: bindAnnotation(en_US.class).toLocale(new Locale("en", "US")); |
* Added support for retrieving content via absolute URL (file:// and http:// protocols tested) * Added test dependency on apache commons io ver: 2.3
* Moved C10N.UDEF to (new) Constants.UNDEF to remove package cyclic dependency * Added `extRes` method to all built-in annotations
* Added support for loading resource from the classpath (or inside the jar). Sample usage: @en(intRes="com/example/resources/data.txt") * Added `intRes` method to all built-in annotations
Got the most features to work, except the Edit: The internal resource path should look like |
Inspired by https://developers.google.com/web-toolkit/doc/latest/DevGuideClientBundle#I18N
API draft:
The text was updated successfully, but these errors were encountered: