google-web-toolkit - issue #4418
ImageResources inside a ClientBundle are not being internationalized
I18N seems to be broken for ImageResources inside a ClientBundle. It does not seem to be picking up the localized versions of the images.
Found in GWT Release (e.g. 1.5.3, 1.6 RC): 2.0
Encountered on OS / Browser (e.g. WinXP, IE6-7, FF3): Tried with both IE6 on Windows XP, and Firefox 3.5 on Mac OS X 10.5
Detailed description (please be as specific as possible): We have a set of internationalized images. We would like to use ClientBundle's I18N functionality to automatically show the english images to english users, and the french images to french users. Based on the ClientBundle documentation, if we declare this: @Source("logo.png") ImageResource logo();
It should automatically look for logo_fr.png when compiling the french permutation. Indeed, this does work when we try this with a TextResource. However, with an ImageResource, it will always pick up the default (english) version of the image.
Shortest code snippet which demonstrates issue (please indicate where actual result differs from expected result):
Create four files - a text file which has both an english and french version, and an image file which has both an english and a french version. - hello.txt - hello_fr.txt - helloImage.gif - helloImage_fr.gif
Create a simple Client Bundle to display the contents of the file: public interface TestClientBundle extends ClientBundle { public static TestClientBundle INSTANCE = GWT.create(TestClientBundle.class);
@Source("hello.txt")
public TextResource helloText();
@Source("helloImage.gif")
public ImageResource helloImage();
}
A simple entry point which displays the contents of the Client Bundle: public class TestEntryPoint implements EntryPoint { public void onModuleLoad() { RootPanel rootPanel = RootPanel.get("gwt-main");
VerticalPanel vPanel = new VerticalPanel();
vPanel.add(new Label(TestClientBundle.INSTANCE.helloText().getText()));
vPanel.add(new Image(TestClientBundle.INSTANCE.helloImage()));
rootPanel.add(vPanel);
}
}
And inside the .gwt.xml file, need to add the french locale <extend-property name='locale' values='fr'/>
When I run this, the french locale ends up displaying - hello_fr.txt - helloImage.gif
I expected the french locale to show - hello_fr.txt - helloImage_fr.gif
Workaround if you have one: Do it the 'old' way, using a Factory which implements Localizable, as described in http://code.google.com/webtoolkit/doc/1.6/DevGuideUserInterface.html#DevGuideImageBundles
Links to relevant GWT Developer Forum posts:
Comment #1
Posted on Jan 11, 2010 by Quick OxI cannot reproduce this with against 2.0 or trunk using the following test.
public class Hello implements EntryPoint {
interface R extends ClientBundle { R INSTANCE = GWT.create(R.class);
@Source("me.gif")
ImageResource me2();
TextResource t();
}
public void onModuleLoad() { RootPanel.get().add(new Label(R.INSTANCE.t().getText())); RootPanel.get().add(new Image(R.INSTANCE.me2())); } }
$ ls src/com/google/gwt/sample/hello/client/ Hello.java me.gif me_fr.gif t.txt t_fr.txt
Comment #2
Posted on Jan 12, 2010 by Massive Camelhmm, i pasted that exact code into a project and am still getting the error.
I've attached the full project file, which includes the source code listed above. you just need to set the gwt.sdk path in build.xml and you shuold be able to compile and run it.
When I go to hello.html, i get the result in the attached screenshot.
- I18nImages.tar.gz 12.29KB
- I18nImages2.png 2.2KB
Comment #3
Posted on Jan 12, 2010 by Massive CamelCan this issue be reopened? I do not have permissions to do so.
Comment #4
Posted on Mar 17, 2010 by Helpful DogHello,
Could this issue be reopened? I have the same issue and cannot localize images with ClientBundle...
This code works ok in Dev Mode, but doesn't work after compile it.
The same problem was reported here: http://groups.google.com/group/google-web- toolkit/browse_thread/thread/acacf997b8cbb436/61fc8748dec53ba8?lnk=raot
Comment #5
Posted on Mar 17, 2010 by Happy GiraffeI also experience the same problem.
Comment #6
Posted on Mar 24, 2010 by Helpful Catit's also reported here: http://code.google.com/p/google-web-toolkit/issues/detail?id=4779
Comment #7
Posted on Mar 24, 2010 by Quick OxThe keys of ImageResourceGenerator.CachedState.imageRectsByName don't take the resource into account, just the method name. This map should be re-keyed with a StringKey consisting of the method name and the location of the image data backing the implementation.
Comment #8
Posted on Apr 2, 2010 by Helpful KangarooPlease change the priority of this issue. as for us it would by "very high" or "critical" as It blocks us with going international with our product :(
thanks aNeutrino :)
Comment #9
Posted on Apr 16, 2010 by Quick OxComment #10
Posted on Apr 29, 2010 by Massive CatI also met the same problem, even using the old way with Abstract Localizable Factory. It works perfect in development mode, but gives an error [ERROR] Cannot find a class to bind to argument type com.xxx.MyImageFactory during the compilation process. As ImageBundle is deprecated, please, pay your great attention to the considered issue.
Comment #11
Posted on May 14, 2010 by Quick PandaI also experience the same problem.
Comment #12
Posted on Jun 2, 2010 by Quick OxIssue 4779 has been merged into this issue.
Comment #13
Posted on Jun 7, 2010 by Quick OxThis should be corrected in r8231
Comment #14
Posted on Jun 22, 2010 by Quick Ox(No comment was entered for this change.)
Comment #15
Posted on Oct 29, 2010 by Grumpy Hippo(No comment was entered for this change.)
Status: Fixed
Labels:
Category-UI
Milestone-2_1
Code