Your Computer Science Resource

Eclipse: Externalize Strings

I don’t use this often, and only recently discovered this feature. Eclipse allows you to “externalize” all or specific strings in your project. This means that any string you’re using in your application can be stored in a properties file outside of your program. This essentially separates your text from the programming. Why would this be useful? Suppose you’re building an application that you want to translate into other languages. Rather than hard-code the text into your program, you can simply load up different property files depending on the language. See the potential? Now let’s see how it’s done.

In your project, go to Source -> Externalize Strings… from the menu.

Externalize Strings - Menu

Select the strings you want to externalize and press next.

Externalize Strings - Select Strings

You may be prompted that the property file does not exist. Click next.

Externalize Strings - Prompt

Next you will see an overview of what is about to be done. You can click finish.

Externalize Strings - Overview

Finally, you will notice a messages.properties file in your project. Open it up. It will look something like this:

Externalize Strings - Property File

Feel free to edit this file to change the text, and there is no need to update your code! Obviously, if you are planning to do language translation for your application, it will require a bit more logic than this, but this is a good start.

Tags: , ,

2 Responses to “Eclipse: Externalize Strings”

  1. Sarah J.

    What type of RSS feed do you use here, because i can’t seem to get it working with my reader… :( hopefully I’ll figure it out because I like this place!

  2. Kurt

    Hello, and thanks for visiting! We’re using RSS 2.0, which I believe is pretty standard. I’ve had no problems bookmarking the RSS feed in Firefox, as well as reading the feed dynamically on my other site. Which RSS reader are you using?

Leave a Reply