Add Locale management.

This commit is contained in:
Christian P. MOMON 2013-09-14 16:48:54 +02:00
parent 9daeb06fc4
commit 3d42e1057c
2 changed files with 82 additions and 5 deletions

View file

@ -1,6 +1,7 @@
package fr.devinsy.xidyn.presenters; package fr.devinsy.xidyn.presenters;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import fr.devinsy.util.FileTools; import fr.devinsy.util.FileTools;
import fr.devinsy.xidyn.data.TagDataManager; import fr.devinsy.xidyn.data.TagDataManager;
@ -39,7 +40,7 @@ public class TranslatorPresenter implements Presenter
{ {
StringBuffer result; StringBuffer result;
Presenter presenter = getPresenter(null); Presenter presenter = getPresenter((String) null);
if (presenter == null) if (presenter == null)
{ {
result = null; result = null;
@ -53,6 +54,31 @@ public class TranslatorPresenter implements Presenter
return result; 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; StringBuffer result;
Presenter presenter = getPresenter(null); Presenter presenter = getPresenter((String) null);
if (presenter == null) if (presenter == null)
{ {
result = null; result = null;
@ -88,6 +114,31 @@ public class TranslatorPresenter implements Presenter
return result; 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; 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 else
{ {
result = getPresenter(null); result = getPresenter((String) null);
} }
} }
} }
@ -170,7 +246,7 @@ public class TranslatorPresenter implements Presenter
try try
{ {
result = getPresenter(null).isAvailable(); result = getPresenter((String) null).isAvailable();
} }
catch (Exception exception) catch (Exception exception)
{ {

View file

@ -1,5 +1,6 @@
package fr.devinsy.xidyn.views; package fr.devinsy.xidyn.views;
import java.util.Locale;
/** /**
* *
@ -13,7 +14,7 @@ public interface CharterView extends View
* @param content * @param content
* @return * @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;
} }
// //////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////////