mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +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:
parent
69c40076b3
commit
f0b7ccf674
2 changed files with 8 additions and 32 deletions
|
@ -3737,25 +3737,25 @@
|
||||||
<template
|
<template
|
||||||
id="org.eclipse.cdt.build.core.templates.HelloWorldCCProject"
|
id="org.eclipse.cdt.build.core.templates.HelloWorldCCProject"
|
||||||
filterPattern=".*"
|
filterPattern=".*"
|
||||||
location="templates/projecttemplates/HelloWorldCCProject/template.xml"
|
location="$nl$/templates/projecttemplates/HelloWorldCCProject/template.xml"
|
||||||
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
|
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
|
||||||
</template>
|
</template>
|
||||||
<template
|
<template
|
||||||
id="org.eclipse.cdt.build.templates.HelloWorldCAnsiProject"
|
id="org.eclipse.cdt.build.templates.HelloWorldCAnsiProject"
|
||||||
filterPattern=".*"
|
filterPattern=".*"
|
||||||
location="templates/projecttemplates/HelloWorldCAnsiProject/template.xml"
|
location="$nl$/templates/projecttemplates/HelloWorldCAnsiProject/template.xml"
|
||||||
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
|
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
|
||||||
</template>
|
</template>
|
||||||
<template
|
<template
|
||||||
id="org.eclipse.cdt.build.core.templates.EmptyProject"
|
id="org.eclipse.cdt.build.core.templates.EmptyProject"
|
||||||
filterPattern=".*"
|
filterPattern=".*"
|
||||||
location="templates/projecttemplates/EmptyProject/template.xml"
|
location="$nl$/templates/projecttemplates/EmptyProject/template.xml"
|
||||||
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
|
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
|
||||||
</template>
|
</template>
|
||||||
<template
|
<template
|
||||||
id="org.eclipse.cdt.build.core.templates.MakefileHelloWorldCCProject"
|
id="org.eclipse.cdt.build.core.templates.MakefileHelloWorldCCProject"
|
||||||
filterPattern=".*"
|
filterPattern=".*"
|
||||||
location="templates/projecttemplates/MakefileHelloWorldCCProject/template.xml"
|
location="$nl$/templates/projecttemplates/MakefileHelloWorldCCProject/template.xml"
|
||||||
projectType="org.eclipse.cdt.build.makefile.projectType">
|
projectType="org.eclipse.cdt.build.makefile.projectType">
|
||||||
</template>
|
</template>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Bala Torati (Symbian) - Initial API and implementation
|
* Bala Torati (Symbian) - Initial API and implementation
|
||||||
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.templateengine;
|
package org.eclipse.cdt.core.templateengine;
|
||||||
|
|
||||||
|
@ -14,7 +15,6 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
@ -198,7 +198,7 @@ public class TemplateEngineHelper {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static URL getTemplateResourceURL(String pluginId, String resourcePath) throws IOException {
|
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 {
|
} else {
|
||||||
path = path.substring(0, slash + 1) + resourcePath;
|
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) {
|
if (entry == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -278,30 +278,6 @@ public class TemplateEngineHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static URL getResourceURL(Bundle bundle, String propertiesFile) {
|
private static URL getResourceURL(Bundle bundle, String propertiesFile) {
|
||||||
// Get the properties in the following order
|
return FileLocator.find(bundle, new Path(propertiesFile), null);
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue