1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

fix for bug 184452 - get template files using FileLocator.find() so translated template files will get picked up

This commit is contained in:
Vivian Kong 2007-06-07 14:06:30 +00:00
parent 69c40076b3
commit f0b7ccf674
2 changed files with 8 additions and 32 deletions

View file

@ -3737,25 +3737,25 @@
<template
id="org.eclipse.cdt.build.core.templates.HelloWorldCCProject"
filterPattern=".*"
location="templates/projecttemplates/HelloWorldCCProject/template.xml"
location="$nl$/templates/projecttemplates/HelloWorldCCProject/template.xml"
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
</template>
<template
id="org.eclipse.cdt.build.templates.HelloWorldCAnsiProject"
filterPattern=".*"
location="templates/projecttemplates/HelloWorldCAnsiProject/template.xml"
location="$nl$/templates/projecttemplates/HelloWorldCAnsiProject/template.xml"
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
</template>
<template
id="org.eclipse.cdt.build.core.templates.EmptyProject"
filterPattern=".*"
location="templates/projecttemplates/EmptyProject/template.xml"
location="$nl$/templates/projecttemplates/EmptyProject/template.xml"
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
</template>
<template
id="org.eclipse.cdt.build.core.templates.MakefileHelloWorldCCProject"
filterPattern=".*"
location="templates/projecttemplates/MakefileHelloWorldCCProject/template.xml"
location="$nl$/templates/projecttemplates/MakefileHelloWorldCCProject/template.xml"
projectType="org.eclipse.cdt.build.makefile.projectType">
</template>
</extension>

View file

@ -7,6 +7,7 @@
*
* Contributors:
* Bala Torati (Symbian) - Initial API and implementation
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.core.templateengine;
@ -14,7 +15,6 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Locale;
import java.util.Properties;
import org.eclipse.cdt.core.CCorePlugin;
@ -198,7 +198,7 @@ public class TemplateEngineHelper {
*/
public static URL getTemplateResourceURL(String pluginId, String resourcePath) throws IOException {
return FileLocator.toFileURL(Platform.getBundle(pluginId).getEntry(resourcePath));
return FileLocator.find(Platform.getBundle(pluginId), new Path(resourcePath), null);
}
/**
@ -220,7 +220,7 @@ public class TemplateEngineHelper {
} else {
path = path.substring(0, slash + 1) + resourcePath;
}
URL entry = Platform.getBundle(templateInfo.getPluginId()).getEntry(path);
URL entry = FileLocator.find(Platform.getBundle(templateInfo.getPluginId()), new Path(path), null);;
if (entry == null) {
return null;
}
@ -278,30 +278,6 @@ public class TemplateEngineHelper {
}
private static URL getResourceURL(Bundle bundle, String propertiesFile) {
// Get the properties in the following order
// propertiesFile_lang_country_variant
// propertiesFile_lang_country
// propertiesFile_lang
// propertiesFile
URL url = null;
Locale locale = Locale.getDefault();
String lang = locale.getLanguage();
String country = locale.getCountry();
String variant = locale.getVariant();
url = bundle.getResource(propertiesFile + US + lang + US + country + US + variant);
if (url == null) {
url = bundle.getResource(propertiesFile + US + lang + US + country);
}
if (url == null) {
url = bundle.getResource(propertiesFile + US + lang);
}
if (url == null) {
url = bundle.getResource(propertiesFile);
}
return url;
return FileLocator.find(bundle, new Path(propertiesFile), null);
}
}