Hades
6 years ago
13 changed files with 231 additions and 40 deletions
@ -0,0 +1,32 @@
|
||||
package com.fr.design.i18n; |
||||
|
||||
public enum ActionType { |
||||
|
||||
/** |
||||
* 视频教学 |
||||
*/ |
||||
VIDEO("video"), |
||||
|
||||
/** |
||||
* 激活码 |
||||
*/ |
||||
ACTIVATION_CODE("activationCode"), |
||||
|
||||
/** |
||||
* 帮助文档 |
||||
*/ |
||||
HELP_DOCUMENT("helpDocument"), |
||||
|
||||
/** |
||||
* 论坛 |
||||
*/ |
||||
BBS("bbs"); |
||||
|
||||
|
||||
private String description; |
||||
|
||||
ActionType(String description) { |
||||
this.description = description; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,41 @@
|
||||
package com.fr.design.i18n; |
||||
|
||||
import com.fr.design.i18n.impl.ChinaLocaleAction; |
||||
import com.fr.design.i18n.impl.JapanLocaleAction; |
||||
import com.fr.design.i18n.impl.KoreaLocaleAction; |
||||
import com.fr.design.i18n.impl.TaiWanLocaleAction; |
||||
import com.fr.design.i18n.impl.USLocaleAction; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Locale; |
||||
import java.util.Map; |
||||
|
||||
public class LocaleCenter { |
||||
|
||||
private Map<Locale, LocaleDifference> actionMap = new HashMap<Locale, LocaleDifference>(); |
||||
|
||||
private LocaleCenter() { |
||||
init(); |
||||
} |
||||
|
||||
private void init() { |
||||
actionMap.put(Locale.CHINA, new ChinaLocaleAction()); |
||||
actionMap.put(Locale.US, new USLocaleAction()); |
||||
actionMap.put(Locale.TAIWAN, new TaiWanLocaleAction()); |
||||
actionMap.put(Locale.JAPAN, new JapanLocaleAction()); |
||||
actionMap.put(Locale.KOREA, new KoreaLocaleAction()); |
||||
} |
||||
|
||||
private static class Holder { |
||||
private static final LocaleCenter INSTANCE = new LocaleCenter(); |
||||
} |
||||
|
||||
public static LocaleCenter getInstance() { |
||||
return Holder.INSTANCE; |
||||
} |
||||
|
||||
public LocaleDifference getLocaleAction(Locale locale) { |
||||
LocaleDifference localeDifference = actionMap.get(locale); |
||||
return localeDifference == null ? actionMap.get(Locale.CHINA) : localeDifference; |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.fr.design.i18n; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 国际化之间有不同表现的动作 |
||||
*/ |
||||
public interface LocaleDifference { |
||||
|
||||
/** |
||||
* 返回该国际化所有的url |
||||
* @return url |
||||
*/ |
||||
Map<ActionType, String> getUrls(); |
||||
|
||||
|
||||
/** |
||||
* 添加Action |
||||
* @param list 列表 |
||||
* @param action 对应action |
||||
*/ |
||||
void addAction(List list, Object action); |
||||
|
||||
/** |
||||
* 返回设计器启动画面路径 |
||||
* @return 路径 |
||||
*/ |
||||
String getSplashPath(); |
||||
|
||||
|
||||
} |
@ -0,0 +1,41 @@
|
||||
package com.fr.design.i18n.impl; |
||||
|
||||
import com.fr.design.i18n.LocaleDifference; |
||||
import com.fr.design.i18n.ActionType; |
||||
import com.fr.general.CloudCenter; |
||||
|
||||
import java.util.EnumMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public abstract class AbstractDefaultLocaleAction implements LocaleDifference { |
||||
|
||||
protected EnumMap<ActionType, String> urls = new EnumMap<ActionType, String>(ActionType.class); |
||||
|
||||
protected void init() { |
||||
urls.put(ActionType.BBS, CloudCenter.getInstance().acquireUrlByKind("bbs")); |
||||
urls.put(ActionType.VIDEO, CloudCenter.getInstance().acquireUrlByKind("bbs.video")); |
||||
urls.put(ActionType.ACTIVATION_CODE, CloudCenter.getInstance().acquireUrlByKind("frlogin.cn")); |
||||
urls.put(ActionType.HELP_DOCUMENT, CloudCenter.getInstance().acquireUrlByKind("help.zh_CN.10")); |
||||
} |
||||
|
||||
@Override |
||||
public Map<ActionType, String> getUrls() { |
||||
if (urls.isEmpty()) { |
||||
init(); |
||||
} |
||||
return urls; |
||||
} |
||||
|
||||
@Override |
||||
public void addAction(List list, Object action) { |
||||
// do nothing
|
||||
} |
||||
|
||||
@Override |
||||
public String getSplashPath() { |
||||
return "/com/fr/design/images/splash_10_en.gif"; |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,9 @@
|
||||
package com.fr.design.i18n.impl; |
||||
|
||||
public class ChinaLocaleAction extends AbstractDefaultLocaleAction { |
||||
|
||||
@Override |
||||
public String getSplashPath() { |
||||
return "/com/fr/design/images/splash_10.gif"; |
||||
} |
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.fr.design.i18n.impl; |
||||
|
||||
import com.fr.design.i18n.ActionType; |
||||
import com.fr.general.CloudCenter; |
||||
|
||||
public class JapanLocaleAction extends AbstractDefaultLocaleAction { |
||||
|
||||
@Override |
||||
protected void init() { |
||||
super.init(); |
||||
urls.put(ActionType.ACTIVATION_CODE, CloudCenter.getInstance().acquireUrlByKind("frlogin.jp")); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public String getSplashPath() { |
||||
return "/com/fr/design/images/splash_10_jp.gif"; |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,6 @@
|
||||
package com.fr.design.i18n.impl; |
||||
|
||||
|
||||
public class KoreaLocaleAction extends AbstractDefaultLocaleAction { |
||||
|
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.fr.design.i18n.impl; |
||||
|
||||
import com.fr.design.i18n.ActionType; |
||||
import com.fr.general.CloudCenter; |
||||
|
||||
import java.util.List; |
||||
|
||||
public class TaiWanLocaleAction extends AbstractDefaultLocaleAction { |
||||
|
||||
@Override |
||||
protected void init() { |
||||
super.init(); |
||||
urls.put(ActionType.VIDEO, CloudCenter.getInstance().acquireUrlByKind("bbs.video.zh_TW")); |
||||
urls.put(ActionType.ACTIVATION_CODE, CloudCenter.getInstance().acquireUrlByKind("frlogin.tw")); |
||||
} |
||||
|
||||
@Override |
||||
public void addAction(List list, Object action) { |
||||
list.add(action); |
||||
} |
||||
} |
@ -0,0 +1,16 @@
|
||||
package com.fr.design.i18n.impl; |
||||
|
||||
import com.fr.design.i18n.ActionType; |
||||
import com.fr.general.CloudCenter; |
||||
|
||||
public class USLocaleAction extends AbstractDefaultLocaleAction { |
||||
|
||||
@Override |
||||
protected void init() { |
||||
super.init(); |
||||
urls.put(ActionType.VIDEO, CloudCenter.getInstance().acquireUrlByKind("bbs.video.en")); |
||||
urls.put(ActionType.HELP_DOCUMENT, CloudCenter.getInstance().acquireUrlByKind("help.en_US.10")); |
||||
urls.put(ActionType.ACTIVATION_CODE, CloudCenter.getInstance().acquireUrlByKind("frlogin.en")); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue