diff --git a/src/fr/devinsy/xidyn/pages/PageFactory.java b/src/fr/devinsy/xidyn/pages/PageFactory.java index 95516b0..1dbc6cc 100644 --- a/src/fr/devinsy/xidyn/pages/PageFactory.java +++ b/src/fr/devinsy/xidyn/pages/PageFactory.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; @@ -65,7 +66,6 @@ public class PageFactory /** * * @param source - * @param parameters * @return */ public Page create(final CharSequence source) @@ -81,7 +81,6 @@ public class PageFactory /** * * @param source - * @param parameters * @return */ public Page create(final Document source) @@ -97,7 +96,6 @@ public class PageFactory /** * * @param source - * @param parameters * @return */ public Page create(final File source) @@ -113,7 +111,21 @@ public class PageFactory /** * * @param source - * @param parameters + * @return + */ + public Page create(final File source, final Locale locale) + { + Page result; + + result = new Page(PresenterFactory.instance().get(source, locale)); + + // + return result; + } + + /** + * + * @param source * @return */ public Page create(final URL source) diff --git a/src/fr/devinsy/xidyn/presenters/PresenterFactory.java b/src/fr/devinsy/xidyn/presenters/PresenterFactory.java index 6f1abfa..e276f2c 100644 --- a/src/fr/devinsy/xidyn/presenters/PresenterFactory.java +++ b/src/fr/devinsy/xidyn/presenters/PresenterFactory.java @@ -20,11 +20,13 @@ package fr.devinsy.xidyn.presenters; import java.io.File; import java.net.URL; +import java.util.Locale; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; +import fr.devinsy.util.FileTools; import fr.devinsy.xidyn.utils.cache.Cache; /** @@ -124,6 +126,36 @@ public class PresenterFactory return result; } + /** + * + * @param source + * @return + */ + public Presenter get(final File source, final Locale locale) + { + Presenter result; + + if (locale == null) + { + result = get(source); + } + else + { + File localizedSource = new File(FileTools.addBeforeExtension(source.getAbsolutePath(), "-" + locale.getLanguage())); + + result = this.cache.get(localizedSource); + + if (result == null) + { + result = create(localizedSource); + this.cache.put(localizedSource, result); + } + } + + // + return result; + } + /** * * @param source