[英]Optimizing jar file size (images) when developing java client supporting multiple languages
I am developing the Java client which should support several languages. 我正在开发应支持多种语言的Java客户端。 For translation of the text I use Java ResourceBoundle and it works okay.
对于文本的翻译,我使用Java ResourceBoundle,它可以正常工作。
Now the problem is with images. 现在问题出在图像上。 The client should load around 50 images which are specific cards for a board game.
客户应加载约50张图像,这些图像是用于棋盘游戏的特定纸牌。 Each image has a title.
每个图像都有一个标题。 So if I have N languages I should prepare 50*N images and put then into the jar file.
因此,如果我有N种语言,则应该准备50 * N张图像,然后将其放入jar文件中。
Each language support would add around 1 Mb to the size of jar file. 每种语言支持都会使jar文件的大小增加大约1 Mb。
Do you think I should 你认为我应该
I advise another option altogether. 我建议另一种选择。
Have a set of images without text, and use AWT's Graphics2D to add the text in the necessary language (as opposed to doing so with a JLabel). 拥有一组没有文本的图像,并使用AWT的Graphics2D以必要的语言添加文本(与JLabel相反)。
Graphics2D g = imageBase.createGraphics();
// color, font, etc settings
g.drawString("title", 0, 0);
g.dispose();
You can modify the parameters of g.drawString
as necessary to draw the correct title at the correct coordinates. 您可以根据需要修改
g.drawString
的参数,以在正确的坐标处绘制正确的标题。 If you wish to center the title, you can find a nice tutorial here . 如果您希望标题居中,可以在此处找到一个不错的教程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.