Implement localization/locale handling classes
LadyCailinBot opened this issue ยท 4 comments
Comment by TheE
I have not found any statements on how you plan to solve this, so please excuse if I say something that is already planned.
A proper localization implementation should probably use Java's standard [ResourceBundles|http://docs.oracle.com/javase/tutorial/i18n/resbundle/concept.html] for managing individual localizations: Instead of rolling out a custom mechanisms to provide the individual translations that match a certain requested locale (fall-back etc.) like CraftBook currently does, Java's ResourceBundle should be used as they already provide all needed functionality and also provide automatic low-level caching. All that is needed to implement is a [ResourceBundles|http://docs.oracle.com/javase/8/docs/api/java/util/ResourceBundle.html] that used the desired format (YAML?) and a [ResourceBundle.Control|http://docs.oracle.com/javase/8/docs/api/java/util/ResourceBundle.Control.html] implementation that manages how these files are loaded.
For [MyWarp|https://github.com/TheE/MyWarp/tree/master/src/main/java/me/taylorkelly/mywarp/localization] I wrote such an implementation that used Bukkit's default YamlConfiguration mechanisms - in fact, it is the only ResourceBundle solution within the Bukkit sphere that I am aware of. It could quit easily be altered to use WorldEdit's logic (Yaml Configuration, CommandSender replacement...), if you should decide to go this road.
Comment by sk89q
I have already implemented ResourceBundles. You can find it on this branch:
https://github.com/sk89q/worldedit/compare/feature/localization
I currently do not plan to implement .yaml at this time because (1) my tools know how to handle properties, not YAML and (2) SnakeYAML is not available on all platforms that WorldEdit is for and I do not desire bundling the library or creating platform-specific extensions at the time.
Comment by TheE
Good work (apart from the cache issue I already mentioned on the commit).
Looking at usage in other plugins (your own and external such as my MyWarp) one thing that might be needed is the ability to provide a custom ResourceBundle.Control or ManagedControl implementation when creating the LocalManager so plugins can control the way and type of there own resource bundles, if they want to.
I really look forward to WE 6.0 - looks like I will depend on WorldEdit for a lot of stuff in the future.