[22:03] so let's start [22:03] yeah [22:03] I'm sorry I've been quite missing [22:03] no problem [22:03] April it's a nightmare month [22:04] but I'll manage to do a bit more starting from next week :) [22:04] after all we do it for fun :) [22:04] so today's topis is localization [22:05] last mail you were saying you had problems in testing localization [22:05] I think it needs to be discussed in more detai [22:05] l [22:06] what the manager should do [22:06] yes [22:06] about which path to pass to the locale [22:06] precisely [22:06] if I'm trying to fetch a properties file from the package where the test lies [22:06] did you try to pass absolute path ./test/....? [22:06] it doesn't pick it up [22:06] no I haven't got time - I can try quickly now however [22:07] yes why not this is crucial to let you finish the task :) [22:07] yeah [22:07] let me quickly do it [22:07] so something like [22:07] ./test/org/freelords etc [22:07] yes till the resource?en or similar [22:07] resource_en [22:08] yeah [22:08] well the _en must be taken [22:08] depending on the locale [22:08] yes [22:08] so you point to the directory path [22:09] brb [22:09] ok [22:09] so I've got my file called [22:09] MessageBundle_en_GB.properties [22:10] ok [22:10] hust see if it load something from it [22:11] well [22:11] or at least it can find the file [22:11] ok [22:11] if it finds the file you have done [22:11] java.util.MissingResourceException: Can't find bundle for base name src/org/freelords/i18n/MessageBundle, locale en_GB [22:11] I put the file into the source folder... [22:12] well it search for messageBundle and not for MessageBundle_en_GB [22:12] you must create the right name [22:12] well [22:12] when it says locale en_GB [22:13] the semantics is that it searches for a file called MessageBundle_en_GB.properties [22:13] I'll link you the method doc [22:13] yes but the locale extension must be added to the file name [22:13] there is [22:13] the file is called MessageBundle_en_GB.properties [22:13] http://docs.oracle.com/javase/6/docs/api/java/util/ResourceBundle.html [22:14] I hope I'm not missing something very basic [22:14] the code is [22:14] private final String messageBundleName = "src/org/freelords/i18n/MessageBundle"; [22:14] private final String messageBundleName = "src/org/freelords/i18n/MessageBundle"; [22:14] private final String messageBundleName = "src/org/freelords/i18n/MessageBundle"; [22:14] private final String messageBundleName = "src/org/freelords/i18n/MessageBundle"; [22:14] private final String messageBundleName = "src/org/freelords/i18n/MessageBundle"; [22:14] oh sorry - crap client [22:14] and [22:15] ResourceBundle specificLocaleBundle = ResourceBundle.getBundle(messageBundleName, locale); [22:15] it was messageBundleName = "MessageBundle" before [22:15] the file must be called X_en_EN [22:15] try to remove .properties [22:15] I did it already... [22:15] I'm calling it with Locale.UK in the tests [22:15] which is resolved to "en_GB" [22:16] mmm strange it seems that it does not find for locale string [22:16] yes [22:16] what about to rename the file int Xen_GB? [22:16] that's weird [22:16] let me try it [22:16] but do you agree that [22:16] having the properties file [22:17] in the same folder [22:17] of the test class [22:17] should make it able to load it into the classpath of the test class? [22:17] yes it always worked to me [22:17] let me see if i can find some working code somewhere [22:18] I saw something similar [22:18] but the fact is I'm not loading directly the properties file from the classpath [22:18] I'm using getBundle() methord [22:18] ok call it X_en.properties [22:19] same problem [22:19] I was thinking [22:19] I could try to commit it [22:19] now [22:19] and you can check it out [22:19] and see if it works for you [22:19] to avoid it's a problem on my IDE [22:19] mmm give me a sec i have the code somewhere [22:19] ok [22:21] public static String getMessageResourceString( [22:21] String bundleName, [22:21] String key, [22:21] Object params[], [22:21] Locale locale) { [22:21] String text = null; [22:21] ResourceBundle bundle; [22:21] Locale localetmp=locale; [22:21] try { [22:21] bundle = ResourceBundle.getBundle(bundleName, localetmp, getCurrentClassLoader(params)); [22:21] } catch (Exception e) { [22:21] localetmp=Locale.ITALIAN; [22:21] bundle = ResourceBundle.getBundle(bundleName, localetmp, getCurrentClassLoader(params)); [22:21] } [22:21] try { [22:21] text = bundle.getString(key); [22:21] if (params != null) { [22:21] final MessageFormat mf = new MessageFormat(text, localetmp); [22:21] text = mf.format(params, new StringBuffer(), null).toString(); [22:21] } [22:21] } catch (Exception e) { [22:21] LoggerUtils.getLogger().error(LoggerUtils.stackTraceToString(e)); [22:21] text = "?? key " + key + " not found ??"; [22:21] } [22:21] return text; [22:21] } [22:22] this code works to me [22:22] where bundlename is the filename [22:22] and localetmp is the right locale [22:22] the default [22:22] I see [22:22] passed by outside [22:22] the difference [22:23] getCurrentClassLoader(params) [22:23] let me try passing the current class loader... [22:23] ok [22:24] was your get current class loader [22:24] something like [22:24] Thread.currentThread().getContextClassLoader() ? [22:25] let me see [22:26] ClassLoader loader = Thread.currentThread().getContextClassLoader(); [22:26] if (loader == null) { [22:26] loader = defaultObject.getClass().getClassLoader(); [22:26] } [22:26] return loader; [22:26] i past the complete code [22:26] protected static ClassLoader getCurrentClassLoader(Object defaultObject) { [22:26] ClassLoader loader = Thread.currentThread().getContextClassLoader(); [22:26] if (loader == null) { [22:26] loader = defaultObject.getClass().getClassLoader(); [22:26] } [22:26] return loader; [22:26] } [22:27] I see [22:27] one thing [22:27] Gets a resource bundle using the specified base name and locale, and the caller's class loader. [22:27] let me try to pass the test class classloader to the method [22:27] just to see if it works [22:27] ok [22:28] that's weird [22:29] it doesn't work the same :S [22:29] let me try with passing esplicitly new Locale("en", "GB") [22:29] ok [22:30] nothing [22:30] mmm absurd [22:30] yeah [22:30] can I try committing it [22:30] and you try running? [22:31] just add new package for that [22:31] i will try to run it [22:31] yeah [22:31] it is already in a new package [22:31] i18n [22:32] ok [22:33] one sec... [22:34] ok [22:35] ok try to update [22:35] brb [22:35] ok [22:36] back [22:37] do you have als the resource file? and the test? [22:37] I committed everything [22:37] I think... [22:37] let me check the logs [22:38] here i have only the LocalizationManager [22:38] ahh ok [22:38] it is my fault [22:39] oh ok cool [22:39] I thought my Mac had gone nuts :) [22:41] ok i try to do something fancy [22:42] ok - by the way are you getting the same error? [22:42] mmm no it does not work to me either [22:43] can't find bundle for base name messageBundle locale en_Gb [22:43] yeah [22:43] but everything seems ok - at least to me... [22:43] i wonder if there is a way to write out the path where it search for the bunfle [22:43] just to understand where it goes to [22:44] http://stackoverflow.com/questions/6360973/getbundle-can-not-find-properties-file [22:46] uhm [22:46] let me try something [22:47] mmm it does not say anithing useful [22:47] ok [22:47] I fixed it [22:47] private final String messageBundleName = "org.freelords.i18n.MessageBundle"; [22:47] this works [22:48] mmm [22:49] so a realtive path is needed there? [22:49] it seems so [22:49] ok better to know [22:49] well this is the package name [22:49] hope it work also in the app [22:49] let me clean it up a bit [22:50] and re commit it [22:50] I want to avoid passing the class loader [22:50] it shouldn't be needed [22:50] ok [22:53] ok [22:53] cool [22:54] does it works? [22:54] work [22:55] yes [22:55] I committed it [22:55] ok [22:56] ok [22:56] ok so now we can talk about responsibilities [22:56] this should be the base [22:57] so what are your thoughts? [22:58] so [22:58] I think we should focus [22:58] on what do we want to localize [22:58] messages for sure [22:59] what about [22:59] dates - or numbers [22:59] numbers? [22:59] what do you mean [22:59] ? [22:59] for example [22:59] in Italy [22:59] 3000 [22:59] it's 3.000 [23:00] and if we add decimals is [23:00] 3.000,00 [23:00] in UK, instead [23:00] it is 3,000.00 [23:00] ah i though you meant numbers conversion [23:00] no :) [23:00] sorry I wasn't very clear [23:01] we use always the international convention :) [23:01] ok - let's say then we use only it for messages? [23:01] we can add other methods later on [23:02] well we could have problems to handle numbers conversion [23:02] since there is no library at least that we can use [23:02] we should code it from scratch [23:03] so i would postpone it for now [23:03] let's concentrate on texts or now [23:03] ok [23:03] for now [23:04] ok.. [23:04] what we need are simple methods to localize messages [23:04] we need to handle messages parameters too [23:05] since for sure we will have parametric texts [23:06] yes [23:07] after that you can add a simple tak on the kanban to localize all messages in the code [23:07] and a newbie can do it without problems [23:07] we preapare the basic file with at least one line [23:07] yes [23:07] the we can call for translators :) [23:07] well [23:08] after that we have all strings in a single file [23:08] we will need to face the "plural" problem [23:09] well this should be standard more or less [23:09] i believe we have a lot of examples about that [23:09] ok [23:10] http://docs.oracle.com/javase/tutorial/i18n/format/choiceFormat.html [23:10] yes I was looking at that [23:10] we integrate this into the manager class too [23:11] ok [23:12] yes [23:12] ok so i would say you can work a bit to integrate this feature [23:12] prepare n easy public interface [23:13] and document a bit the usage of the classe [23:13] and document a bit the usage of the class [23:13] ok [23:13] I went for a singleton however [23:13] as you can see from the code [23:13] is that ok for you? [23:13] yes this can be a singleton [23:13] pheraps is even better a static method [23:13] I don't like too much static methods [23:13] since you does not need to call each time the getInstance [23:14] if it's a singleton we can still inject it [23:14] so we don't need to do fancy things [23:14] when testing other classes that depend on this one [23:14] well yes [23:14] we could just mock it if needed [23:14] but this will become a parameter for almost every class [23:14] but ok better to pass it by injectionas usual [23:15] well [23:15] this will be a parameter I think on GUI classes isn't it [23:15] ? [23:15] yes [23:15] well [23:15] or maybe [23:15] converting this to static if it becames too much of a mess [23:15] the log files are english? [23:15] shouldn't be that hard [23:16] I think we shouldn't localize logs [23:16] ok [23:18] yeah so [23:18] well [23:18] I don't know if we should define an interface [23:18] because I don't see [23:18] any other way of implementing [23:18] a localization manager [23:19] well if we want to mock it [23:19] an interface should be defined then yes [23:19] sorry i was meaning about usage interface not java interface [23:19] oh ok [23:19] clear set of public methods [23:20] ok [23:21] so i think you now have some material to work on [23:21] yeah [23:21] I may need to wait next week to take on this [23:21] ok [23:22] this week is still bad but I'll manage [23:22] do not worry [23:22] after that just prepae the code base [23:22] and make the basic task to localaze messages [23:22] so that we can assign to some newbie [23:22] ok [23:22] after that we can start with GUI [23:23] yeah [23:23] we will need a bit of session in that [23:24] i am still inspecting some code to handle mouse cursor changes and then i should have all the basis to implement a little gui lib [23:24] at least i ported almost all basic things from the old code :) [23:25] nice :) [23:25] ok [23:25] so i go to bed now [23:26] see you online [23:26] if you have problems just send amail [23:26] ok [23:26] cool [23:26] will you put the log online? [23:26] yes [23:27] i put the log online [23:27] cool thanks a lot [23:27] see you later then [23:27] night [23:27] gn