From 3d42e1057cdd412f47dddecf8160d79117b8e736 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sat, 14 Sep 2013 16:48:54 +0200 Subject: [PATCH] Add Locale management. --- .../xidyn/presenters/TranslatorPresenter.java | 84 ++++++++++++++++++- src/fr/devinsy/xidyn/views/CharterView.java | 3 +- 2 files changed, 82 insertions(+), 5 deletions(-) diff --git a/src/fr/devinsy/xidyn/presenters/TranslatorPresenter.java b/src/fr/devinsy/xidyn/presenters/TranslatorPresenter.java index a7747cc..7876c3a 100644 --- a/src/fr/devinsy/xidyn/presenters/TranslatorPresenter.java +++ b/src/fr/devinsy/xidyn/presenters/TranslatorPresenter.java @@ -1,6 +1,7 @@ package fr.devinsy.xidyn.presenters; import java.util.HashMap; +import java.util.Locale; import fr.devinsy.util.FileTools; import fr.devinsy.xidyn.data.TagDataManager; @@ -39,7 +40,7 @@ public class TranslatorPresenter implements Presenter { StringBuffer result; - Presenter presenter = getPresenter(null); + Presenter presenter = getPresenter((String) null); if (presenter == null) { result = null; @@ -53,6 +54,31 @@ public class TranslatorPresenter implements Presenter return result; } + /** + * + */ + public StringBuffer dynamize(final Locale locale) throws Exception + { + StringBuffer result; + + // + String language; + if (locale == null) + { + language = null; + } + else + { + language = locale.getLanguage(); + } + + // + result = getPresenter(language).dynamize(); + + // + return result; + } + /** * */ @@ -74,7 +100,7 @@ public class TranslatorPresenter implements Presenter { StringBuffer result; - Presenter presenter = getPresenter(null); + Presenter presenter = getPresenter((String) null); if (presenter == null) { result = null; @@ -88,6 +114,31 @@ public class TranslatorPresenter implements Presenter return result; } + /** + * + */ + public StringBuffer dynamize(final TagDataManager datas, final Locale locale) throws Exception + { + StringBuffer result; + + // + String language; + if (locale == null) + { + language = null; + } + else + { + language = locale.getLanguage(); + } + + // + result = getPresenter(language).dynamize(datas); + + // + return result; + } + /** * */ @@ -101,6 +152,31 @@ public class TranslatorPresenter implements Presenter return result; } + /** + * + */ + public Presenter getPresenter(final Locale locale) throws Exception + { + Presenter result; + + // + String language; + if (locale == null) + { + language = null; + } + else + { + language = locale.getLanguage(); + } + + // + result = getPresenter(language); + + // + return result; + } + /** * */ @@ -140,7 +216,7 @@ public class TranslatorPresenter implements Presenter } else { - result = getPresenter(null); + result = getPresenter((String) null); } } } @@ -170,7 +246,7 @@ public class TranslatorPresenter implements Presenter try { - result = getPresenter(null).isAvailable(); + result = getPresenter((String) null).isAvailable(); } catch (Exception exception) { diff --git a/src/fr/devinsy/xidyn/views/CharterView.java b/src/fr/devinsy/xidyn/views/CharterView.java index 21cb162..b6850ac 100644 --- a/src/fr/devinsy/xidyn/views/CharterView.java +++ b/src/fr/devinsy/xidyn/views/CharterView.java @@ -1,5 +1,6 @@ package fr.devinsy.xidyn.views; +import java.util.Locale; /** * @@ -13,7 +14,7 @@ public interface CharterView extends View * @param content * @return */ - public StringBuffer getHtml(final Integer userId, final String language, final CharSequence content) throws Exception; + public StringBuffer getHtml(final Integer userId, final Locale language, final CharSequence content) throws Exception; } // //////////////////////////////////////////////////////////////////////// \ No newline at end of file