package org.postgresql.util;

import java.text.MessageFormat;
import java.util.ResourceBundle;
import java.util.MissingResourceException;

public class GT {

	private static GT instance;

	private final static GT getGT() {
		if (instance == null) {
			instance = new GT();
		}
		return instance;
	}

	public final static String tr(String message) {
		GT gt = getGT();
		return gt.translate(message, null);
	}

	public final static String tr(String message, Object arg) {
		GT gt = getGT();
		return gt.translate(message, new Object[]{arg});
	}

	public final static String tr(String message, Object args[]) {
		GT gt = getGT();
		return gt.translate(message, args);
	}


	private ResourceBundle _bundle;

	private GT() {
		try {
			_bundle = ResourceBundle.getBundle("org.postgresql.translation.messages");
		} catch (MissingResourceException mre) {
			// translation files have not been installed
			_bundle = null;
		}
	}

	private final String translate(String message, Object args[])
	{
		if (_bundle != null && message != null)
		{
			try {
				message = _bundle.getString(message);
			} catch (MissingResourceException mre) {
				// If we can't find a translation, just
				// use the untranslated message.
			}
		}

		// Replace placeholders with arguments
		//
		if (args != null && message != null) {
			message = MessageFormat.format(message, args);
		}

		return message;
	}

}


@@ -136,167 +136,403 @@
 n;%0A%0A
-public class GT %7B%0A%0A%09private static GT instance;%0A%0A%09private final static GT getGT() %7B%0A%09%09if (instance == null) %7B%0A%09%09%09instance = new GT();%0A%09%09%7D%0A%09%09return instance;%0A%09%7D
+/**%0A * This class provides a wrapper around a gettext message catalog that%0A * can provide a localized version of error messages.  The caller provides%0A * a message String in the standard java.text.MessageFormat syntax and any%0A * arguments it may need.  The returned String is the localized version if%0A * available or the original if not.%0A */%0A%0Apublic class GT %7B%0A%0A%09private static GT _gt = new GT();
 %0A%0A%09p
@@ -578,35 +578,16 @@
 sage) %7B%0A
-%09%09GT gt = getGT();%0A
 %09%09return
@@ -579,32 +579,33 @@
 age) %7B%0A%09%09return 
+_
 gt.translate(mes
@@ -682,35 +682,16 @@
  arg) %7B%0A
-%09%09GT gt = getGT();%0A
 %09%09return
@@ -683,32 +683,33 @@
 arg) %7B%0A%09%09return 
+_
 gt.translate(mes
@@ -806,27 +806,8 @@
 ) %7B%0A
-%09%09GT gt = getGT();%0A
 %09%09re
@@ -811,16 +811,17 @@
 %09return 
+_
 gt.trans

Fix thread safety problem in initialization of new translation code.