Posts tagged logic

java_starting

Java resource bundle modification to identify hardcoded strings

In Java, Internationalization of applications is supported through the ResourceBundle class. The strings which need to be translated are packaged in individual resource bundles and each language will have its own resource bundle which is loaded by the ResourceBundle Class based on the application logic.

I was involved in the modification of the Java ResourceBundle class to make it optionally decorate all the strings coming from any specific resource bundle with certain special characters like {{ or [[ so that it will be possible to visually identify any hard coded strings in the application. My role in this project was to specifically hack the XliffResourceBundle class which decorates the strings from Xliff resource bundle files. The decoration process had to be turned off or on by the user and had to obey certain rules/filters which allows the user to decorate specific strings (exclude any numbers/dates etc).
As all strings which support internationalization typically use the resource bundle class to fetch the translated strings, modifying the class itself at the root level will help one to indentify the ones which are not using this class (and hence hardcoded).
But one might ask “why not write a tool to scan through hardcoded strings using regex”. Yes , you could do this, but there are cases where this method wont be sufficient. The strings could still be following your regex pattern and might not be using the resourcebundle class to fetch the translated strings. Only modifying resource nundle class can provide a foolproof way to identify them.

Why ?
Identifying hardcoded strings is very much necessary for any software application which has to be internationalized. Especially when the software is used all over the world. Typically Arab speaking and Chinese users contribute to a major percentage of profits and they prefer localized versions of the user interface. Localizing the UI after a software has become successful will take minimal effort and the results of such a move are quite astounding.

But usually during inital phases of development, no developer will give much importance to externalizing string and coding in a way that makes localization of each UI easier. The tendency is to concentrate on the functionality of the software and make things work well. The problem comes when the functionality breaks during the localiztion process. Also from the profits point of view, localizing the software becomes important. But to the developer, who feels that putting additional efforts to just make the software work under different locales and obey the rules of different regions in showing the dates/currency and timezone implications , it is something of least interest. They are the developers who just copy past code samples from the internet and never give importance to how things work. Such negligence gives rise to performance issues too. But internationalizing existing programs also become difficult is this is the case.

Incoming search terms:

Kaun banega crorepati flash game

Kaun banega crorepati game (kbc2) (download the game)

Update as of 5th June 2011 : Source code for the game has been published on this page. Now you can change the game as you wish, using Swishmax (www.swishzone.com)

Update as of 20th Dec 2010 : I have been noticing quite a lot of visitors reaching this page through google search.  So drop in a comment if you would like me to add any new features onto the game.

This was a simple game I created using SWiSH in 2005. The questions appear randomly with no logic for the levels of difficulty and the “Phone a friend” lifeline is a dummy lifeline with no real purpose. You should check out the game here. The game was hosted on a free domain kbc2.be and also on openflash.be initially which got a decent amount of hits. Those domain names dont exist anymore, so I have published it here. You can download the source code and read the instructions below if you like to edit the game to suite your needs.

Click below to play the game


VN:F [1.9.22_1171]
Rating: 7.8/10 (4349 votes cast)
VN:F [1.9.22_1171]
Rating: 7.8/10 (4349 votes cast)

KBC flash game source code

I have also noticed a few visitors to this blog searching for terms like “kbc game source code”. I am not sure whether anyone want to modify the existing flash game to accomodate new lifelines or game rules.
Anyway, you can download the source code for this game and a sample questions database (20 questions only) using the link below. You will need Swishmax v3 to open the .swi source file and edit program logic. If you just want to edit the questions and answers database, you can edit the core.kbc file in the zip archive.
If you modify the game using this source code and publish it elsewhere, you should retain an always visible text which reads “thekirankumar.com”

Download the game

How to add your own questions or edit the questions in KBC ?

The questions database (core.kbc is included in the KBC.zip package) contents are as follows :

&totques=183&
&ques1=What is capital of India?&
&a1=Bombay&
&b1=Delhi&
&c1=Calcutta&
&d1=Madras&
&ans1=2&
&ques2=Who is known as the father of the nation?&
&a2=Lal Bahadur Sastri&
&b2=Mahatma Gandhi&
&c2=Bal Gangadhar Tilak&
&d2=Rajiv Gandhi&
&ans2=2&

The first line &totques=183& in the file can be changed to specify the total number of questions you have in your database. If you plan to put only 20 questions, change the line to &totques=20&

The first question is in a variable called quest1, the second on quest2 and so on…
Similar naming for options . Variables a1,b1,c1,d1 will contain the text for the options for question 1. a2,b2 etc for question no 2

Answer is specified as &ans1=2& where the value 2 says the answer for question number 1 is option b (i.e, the variable b1). Similarly ans1=3 means that the answer is c.

Hence, by editing the core.kbc file using an text editor, you can modify/add new questions to the game.

You can access the source code of the flash game by opening the KBC.swi file using SwishMax. Post the URL of your version of the game as a comment in this page, I would love to see them.

kon banega crorepati game
kbc game
kaun banega crorepati game download
play kbc online

Incoming search terms: