forked from fanruan/design
Jinbokai
6 years ago
177 changed files with 596 additions and 617 deletions
@ -1,48 +1,57 @@ |
|||||||
package com.fr.design.i18n; |
package com.fr.design.i18n; |
||||||
|
|
||||||
|
import com.fr.general.GeneralContext; |
||||||
import com.fr.general.log.MessageFormatter; |
import com.fr.general.log.MessageFormatter; |
||||||
import com.fr.locale.InterProviderFactory; |
import com.fr.locale.InterProviderFactory; |
||||||
|
import com.fr.locale.LocaleManager; |
||||||
|
import com.fr.locale.impl.FineLocaleManager; |
||||||
|
|
||||||
/** |
/** |
||||||
* 设计器国际化类,后面会不再依赖InterProviderFactory |
* 设计器国际化类,后面会不再依赖InterProviderFactory |
||||||
*/ |
*/ |
||||||
public class Toolkit { |
public class Toolkit { |
||||||
|
|
||||||
|
private static LocaleManager localeManager = FineLocaleManager.create(); |
||||||
|
|
||||||
|
static { |
||||||
|
addResource("com/fr/design/i18n/main"); |
||||||
|
} |
||||||
|
|
||||||
|
public static void addResource(String path) { |
||||||
|
|
||||||
|
localeManager.addResource(path); |
||||||
|
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 设计器国际化方法 |
* 设计器国际化方法 |
||||||
|
* |
||||||
* @param key 国际化键 |
* @param key 国际化键 |
||||||
* @return 国际化值 |
* @return 国际化值 |
||||||
*/ |
*/ |
||||||
public static String i18nText(String key) { |
public static String i18nText(String key) { |
||||||
return InterProviderFactory.getProvider().getLocText(key); |
return localeManager.getLocalBundle(GeneralContext.getLocale()).getText(localeManager, key); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 带格式化内容的国际化方法 |
* 带格式化内容的国际化方法 |
||||||
* Toolkit.i18nText("Fine-Design_xxx", 1, 2),假设Fine-Design_xxx的中文值为:我来计算{}+{},输出结果为:我来计算1+2 |
* Toolkit.i18nText("Fine-Design_xxx", 1, 2),假设Fine-Design_xxx的中文值为:我来计算{}+{},输出结果为:我来计算1+2 |
||||||
* @param key 格式化文本 |
* |
||||||
|
* @param key 格式化文本 |
||||||
* @param args 格式化参数 |
* @param args 格式化参数 |
||||||
* @return 国际化值 |
* @return 国际化值 |
||||||
*/ |
*/ |
||||||
public static String i18nText(String key, Object... args) { |
public static String i18nText(String key, Object... args) { |
||||||
String format = InterProviderFactory.getProvider().getLocText(key); |
String format = InterProviderFactory.getProvider().getLocText(key); |
||||||
MessageFormatter.FormattingTuple tuple = MessageFormatter.arrayFormat(format, args); |
MessageFormatter.FormattingTuple tuple = MessageFormatter.arrayFormat(format, args); |
||||||
return tuple.getMessage(); |
return localeManager.getLocalBundle(GeneralContext.getLocale()).getText(localeManager, tuple.getMessage()); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 太鸡儿多了,改不完,先加上慢慢改 |
* 太鸡儿多了,改不完,先加上慢慢改 |
||||||
|
* |
||||||
* @deprecated |
* @deprecated |
||||||
*/ |
*/ |
||||||
public static String i18nTextArray(String[] keys) { |
public static String i18nTextArray(String[] keys) { |
||||||
return InterProviderFactory.getProvider().getLocText(keys); |
return InterProviderFactory.getProvider().getLocText(keys); |
||||||
} |
} |
||||||
|
|
||||||
/** |
|
||||||
* 太鸡儿多了,改不完,先加上慢慢改 |
|
||||||
* @deprecated |
|
||||||
*/ |
|
||||||
public static String i18nTextArray(String[] keys, String[] delimiter) { |
|
||||||
return InterProviderFactory.getProvider().getLocText(keys, delimiter); |
|
||||||
} |
|
||||||
} |
} |
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue