diff --git a/src/fr/devinsy/xidyn/pages/Page.java b/src/fr/devinsy/xidyn/pages/Page.java index c0aa8c7..8aaeed6 100644 --- a/src/fr/devinsy/xidyn/pages/Page.java +++ b/src/fr/devinsy/xidyn/pages/Page.java @@ -20,6 +20,7 @@ package fr.devinsy.xidyn.pages; import java.io.File; import java.net.URL; +import java.util.Locale; import org.w3c.dom.Document; @@ -66,6 +67,15 @@ public class Page extends TagDataManager this(new FilePresenter(source)); } + /** + * + * @param source + */ + public Page(final File source, final Locale locale) + { + this(PresenterFactory.create(source, locale)); + } + /** * */ diff --git a/src/fr/devinsy/xidyn/presenters/PresenterFactory.java b/src/fr/devinsy/xidyn/presenters/PresenterFactory.java index e276f2c..660bce0 100644 --- a/src/fr/devinsy/xidyn/presenters/PresenterFactory.java +++ b/src/fr/devinsy/xidyn/presenters/PresenterFactory.java @@ -135,7 +135,11 @@ public class PresenterFactory { Presenter result; - if (locale == null) + if (source == null) + { + result = null; + } + else if (locale == null) { result = get(source); } @@ -148,6 +152,12 @@ public class PresenterFactory if (result == null) { result = create(localizedSource); + + if ((result == null) || (!result.isAvailable())) + { + result = create(source); + } + this.cache.put(localizedSource, result); } } @@ -280,6 +290,40 @@ public class PresenterFactory return result; } + /** + * + * @param source + * @param locale + * @return + */ + public static Presenter create(final File source, final Locale locale) + { + Presenter result; + + if (source == null) + { + result = null; + } + else if (locale == null) + { + result = create(source); + } + else + { + File localizedSource = new File(FileTools.addBeforeExtension(source.getAbsolutePath(), "-" + locale.getLanguage())); + + result = create(localizedSource); + + if ((result == null) || (!result.isAvailable())) + { + result = create(source); + } + } + + // + return result; + } + /** * * @param source