com.alibaba.dubbo.governance.web.common.i18n.LocaleUtil Java Examples
The following examples show how to use
com.alibaba.dubbo.governance.web.common.i18n.LocaleUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocaleValve.java From dubbox with Apache License 2.0 | 5 votes |
public void invoke(PipelineContext pipelineContext) throws Exception { TurbineRunData rundata = getTurbineRunData(request); if (ignoreTarget(rundata.getTarget())) { pipelineContext.invokeNext(); return; } //默认是中文 String[] temp = rundata.getCookies().getStrings("locale"); String locale = null; if (temp != null) { if (temp.length > 1) { locale = temp[temp.length - 1]; } else if (temp.length == 1) { locale = temp[0]; } } if (locale == null || "".equals(locale)) { locale = "zh"; } Locale newLocale = Locale.SIMPLIFIED_CHINESE; if ("en".equals(locale)) { newLocale = Locale.ENGLISH; } else if ("zh".equals(locale)) { newLocale = Locale.SIMPLIFIED_CHINESE; } else if ("zh_TW".equals(locale)) { newLocale = Locale.TRADITIONAL_CHINESE; } LocaleUtil.setLocale(newLocale); pipelineContext.invokeNext(); }
Example #2
Source File: MessageResourceServiceImpl.java From dubbox with Apache License 2.0 | 5 votes |
public String get(String key, Object... args) { try { if (messageSource != null) { return messageSource.getMessage(key, args, key, LocaleUtil.getLocale()); } return key; } catch (NoSuchMessageException e) { return key; } }
Example #3
Source File: LocaleValve.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
public void invoke(PipelineContext pipelineContext) throws Exception { TurbineRunData rundata = getTurbineRunData(request); if (ignoreTarget(rundata.getTarget())) { pipelineContext.invokeNext(); return; } //默认是中文 String[] temp = rundata.getCookies().getStrings("locale"); String locale = null; if (temp != null) { if (temp.length > 1) { locale = temp[temp.length - 1]; } else if (temp.length == 1) { locale = temp[0]; } } if (locale == null || "".equals(locale)) { locale = "zh"; } Locale newLocale = Locale.SIMPLIFIED_CHINESE; if ("en".equals(locale)) { newLocale = Locale.ENGLISH; } else if ("zh".equals(locale)) { newLocale = Locale.SIMPLIFIED_CHINESE; } else if ("zh_TW".equals(locale)) { newLocale = Locale.TRADITIONAL_CHINESE; } LocaleUtil.setLocale(newLocale); pipelineContext.invokeNext(); }
Example #4
Source File: MessageResourceServiceImpl.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
public String get(String key, Object... args) { try { if (messageSource != null) { return messageSource.getMessage(key, args, key, LocaleUtil.getLocale()); } return key; } catch (NoSuchMessageException e) { return key; } }
Example #5
Source File: LocaleValve.java From dubbo3 with Apache License 2.0 | 5 votes |
public void invoke(PipelineContext pipelineContext) throws Exception { TurbineRunData rundata = getTurbineRunData(request); if (ignoreTarget(rundata.getTarget())) { pipelineContext.invokeNext(); return; } //默认是中文 String[] temp = rundata.getCookies().getStrings("locale"); String locale = null; if (temp != null) { if (temp.length > 1) { locale = temp[temp.length - 1]; } else if (temp.length == 1) { locale = temp[0]; } } if (locale == null || "".equals(locale)) { locale = "zh"; } Locale newLocale = Locale.SIMPLIFIED_CHINESE; if ("en".equals(locale)) { newLocale = Locale.ENGLISH; } else if ("zh".equals(locale)) { newLocale = Locale.SIMPLIFIED_CHINESE; } else if ("zh_TW".equals(locale)) { newLocale = Locale.TRADITIONAL_CHINESE; } LocaleUtil.setLocale(newLocale); pipelineContext.invokeNext(); }
Example #6
Source File: MessageResourceServiceImpl.java From dubbo3 with Apache License 2.0 | 5 votes |
public String get(String key, Object... args) { try { if (messageSource != null) { return messageSource.getMessage(key, args, key, LocaleUtil.getLocale()); } return key; } catch (NoSuchMessageException e) { return key; } }
Example #7
Source File: LocaleValve.java From dubbox with Apache License 2.0 | 5 votes |
public void invoke(PipelineContext pipelineContext) throws Exception { TurbineRunData rundata = getTurbineRunData(request); if (ignoreTarget(rundata.getTarget())) { pipelineContext.invokeNext(); return; } //默认是中文 String[] temp = rundata.getCookies().getStrings("locale"); String locale = null; if (temp != null) { if (temp.length > 1) { locale = temp[temp.length - 1]; } else if (temp.length == 1) { locale = temp[0]; } } if (locale == null || "".equals(locale)) { locale = "zh"; } Locale newLocale = Locale.SIMPLIFIED_CHINESE; if ("en".equals(locale)) { newLocale = Locale.ENGLISH; } else if ("zh".equals(locale)) { newLocale = Locale.SIMPLIFIED_CHINESE; } else if ("zh_TW".equals(locale)) { newLocale = Locale.TRADITIONAL_CHINESE; } LocaleUtil.setLocale(newLocale); pipelineContext.invokeNext(); }
Example #8
Source File: MessageResourceServiceImpl.java From dubbox with Apache License 2.0 | 5 votes |
public String get(String key, Object... args) { try { if (messageSource != null) { return messageSource.getMessage(key, args, key, LocaleUtil.getLocale()); } return key; } catch (NoSuchMessageException e) { return key; } }
Example #9
Source File: LocaleValve.java From dubbox with Apache License 2.0 | 5 votes |
public void invoke(PipelineContext pipelineContext) throws Exception { TurbineRunData rundata = getTurbineRunData(request); if (ignoreTarget(rundata.getTarget())) { pipelineContext.invokeNext(); return; } //默认是中文 String[] temp = rundata.getCookies().getStrings("locale"); String locale = null; if (temp != null) { if (temp.length > 1) { locale = temp[temp.length - 1]; } else if (temp.length == 1) { locale = temp[0]; } } if (locale == null || "".equals(locale)) { locale = "zh"; } Locale newLocale = Locale.SIMPLIFIED_CHINESE; if ("en".equals(locale)) { newLocale = Locale.ENGLISH; } else if ("zh".equals(locale)) { newLocale = Locale.SIMPLIFIED_CHINESE; } else if ("zh_TW".equals(locale)) { newLocale = Locale.TRADITIONAL_CHINESE; } LocaleUtil.setLocale(newLocale); pipelineContext.invokeNext(); }
Example #10
Source File: MessageResourceServiceImpl.java From dubbox with Apache License 2.0 | 5 votes |
public String get(String key, Object... args) { try { if (messageSource != null) { return messageSource.getMessage(key, args, key, LocaleUtil.getLocale()); } return key; } catch (NoSuchMessageException e) { return key; } }