diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index f78c536e63b..105327b0484 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,8 @@ +2004-07-29 Tanya Wolff + + Part Fix for 69768: CDT wasn't displaying non-English templates. + *org.eclipse.cdt.internal.corext.template/Templates.java + 2004-07-27 Tanya Wolff Fix for 70124 -- allow buttons to be expandable for translation diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/Templates.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/Templates.java index 64056a442aa..9f965884876 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/Templates.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/Templates.java @@ -5,15 +5,19 @@ package org.eclipse.cdt.internal.corext.template; * All Rights Reserved. */ -import org.eclipse.cdt.ui.CUIPlugin; - import java.io.File; +import java.io.IOException; import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; - +import org.eclipse.core.runtime.Platform; import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.ui.internal.util.BundleUtility; +import org.osgi.framework.Bundle; /** * Templates gives access to the available templates. @@ -21,6 +25,8 @@ import org.eclipse.jface.dialogs.ErrorDialog; public class Templates extends TemplateSet { private static final String DEFAULT_FILE= "default-templates.xml"; //$NON-NLS-1$ + private static final String NL_DEFAULT_FILE= "$nl$/org/eclipse/cdt/internal/corext/template/default-templates.xml"; //$NON-NLS-1$ + private static final String TEMPLATE_FILE= "templates.xml"; //$NON-NLS-1$ /** Singleton. */ @@ -84,8 +90,39 @@ public class Templates extends TemplateSet { } private static InputStream getDefaultsAsStream() { - return Templates.class.getResourceAsStream(DEFAULT_FILE); + URL defFile = getDefaultTemplateFile(); + if (defFile == null) return Templates.class.getResourceAsStream(DEFAULT_FILE); + try { + return defFile.openStream(); + } catch (IOException e) { + return null; + } + + //return Templates.class.getResourceAsStream(getDefaultTemplateFile()); } + /** + * Gets the resolved $nl$ path to the NL_DEFAULT_TEMPLATE file as a URL. + * If it doesn't exist, then null is returned. Calling procedures use + * DEFAULT_TEMPLATES if null is returned from this. + */ + public static URL getDefaultTemplateFile() { + + Bundle bundle = Platform.getBundle("org.eclipse.cdt.ui"); //$NON-NLS-1$ + if (!BundleUtility.isReady(bundle)) + return null; + + URL fullPathString = BundleUtility.find(bundle, NL_DEFAULT_FILE); + if (fullPathString == null) { + try { + fullPathString = new URL(NL_DEFAULT_FILE); + } catch (MalformedURLException e) { + return null; + } + } + + return fullPathString; + + } private static File getTemplateFile() { IPath path= CUIPlugin.getDefault().getStateLocation();