info.magnolia.cms.i18n.Messages.getWithDefault()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(83)

本文整理了Java中info.magnolia.cms.i18n.Messages.getWithDefault()方法的一些代码示例,展示了Messages.getWithDefault()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Messages.getWithDefault()方法的具体详情如下:
包路径:info.magnolia.cms.i18n.Messages
类名称:Messages
方法名:getWithDefault

Messages.getWithDefault介绍

[英]You can provide a default value if the key is not found.
[中]如果找不到密钥,可以提供默认值。

代码示例

代码示例来源:origin: info.magnolia.core/magnolia-freemarker-support

/**
 * @deprecated since 5.4.4. Use {@link #get(String, java.util.List)} instead.
 */
@Deprecated
protected String getWithDefault(String key, String defaultMsg, Messages messages) {
  return messages.getWithDefault(key, defaultMsg);
}

代码示例来源:origin: info.magnolia.core/magnolia-freemarker-support

/**
 * @deprecated since 5.4.4. Use {@link #get(String, java.util.List)} instead.
 */
@Deprecated
protected String getWithDefault(String key, List args, String defaultMsg, Messages messages) {
  Object[] argsArray = new Object[args.size()];
  return messages.getWithDefault(key, args.toArray(argsArray), defaultMsg);
}

代码示例来源:origin: info.magnolia/magnolia-core

/**
 * Use a default string.
 *
 * @param key key to find
 * @param defaultMsg default message
 * @return the message
 */
public static String getWithDefault(String key, String defaultMsg) {
  return getMessages().getWithDefault(key, defaultMsg);
}

代码示例来源:origin: info.magnolia/magnolia-core

/**
 * Get a message with parameters inside: the value {0} must be a number. Use a default message.
 *
 * @param key key to find
 * @param args replacement strings
 * @param defaultMsg default message
 * @return the message
 */
public static String getWithDefault(String key, Object[] args, String defaultMsg) {
  return getMessages().getWithDefault(key, args, defaultMsg);
}

代码示例来源:origin: info.magnolia/magnolia-gui

/**
 * Get the message.
 * @param key key
 * @return message
 */
public String getMessage(String key) {
  return this.getMessages().getWithDefault(key, key);
}

代码示例来源:origin: info.magnolia/magnolia-gui

/**
 * Get the message from the renderer. Uses getMessages().
 * @param key
 * @return the string found, or the key if not found
 */
public String getMessage(String key) {
  return getMessages().getWithDefault(key, key);
}

代码示例来源:origin: info.magnolia/magnolia-templating

/**
 * @deprecated since 5.4.4. Use new i18n mechanism instead.
 */
@Deprecated
protected String getInterfaceMessage(String key) {
  return MessagesUtil.chainWithDefault(DEFAULT_I18N_BASENAME).getWithDefault(key, key);
}

代码示例来源:origin: info.magnolia/magnolia-gui

/**
 * Get the message with replacement strings. Use the {nr} syntax
 * @param key key
 * @param args replacement strings
 * @return message
 */
public String getMessage(String key, Object[] args) {
  return this.getMessages().getWithDefault(key, args, key);
}

代码示例来源:origin: info.magnolia/magnolia-core

public static String getWithDefault(String key, String dflt, String basename) {
  return MessagesManager.getMessages(basename).getWithDefault(key, dflt);
}

代码示例来源:origin: info.magnolia/magnolia-core

public static String getWithDefault(String key, String dflt) {
  return MessagesManager.getMessages().getWithDefault(key, dflt);
}

代码示例来源:origin: info.magnolia/magnolia-core

public static String getWithDefault(String key, String dflt, String[] args) {
  return MessagesManager.getMessages().getWithDefault(key, args, dflt);
}

代码示例来源:origin: info.magnolia/magnolia-core

public static String getWithDefault(String key, String dflt, String basename, String[] args) {
  return MessagesManager.getMessages(basename).getWithDefault(key, args, dflt);
}

代码示例来源:origin: info.magnolia/magnolia-core

public static String getChainedWithDefault(String key, String dflt, String[] basenames) {
  return chain(basenames).getWithDefault(key, dflt);
}

代码示例来源:origin: info.magnolia/magnolia-core

public static String getChainedWithDefault(String key, String dflt, String[] basenames, String[] args) {
  return chain(basenames).getWithDefault(key, args, dflt);
}

代码示例来源:origin: info.magnolia/magnolia-core

/**
 * Uses the i18n mechanism to translate the message if the resulting string is a key.
 */
public static String getI18NString(Content node, String str, String basename) {
  String key = getString(node, str);
  return MessagesManager.getMessages(basename).getWithDefault(key, key);
}

代码示例来源:origin: info.magnolia/magnolia-core

/**
 * @see info.magnolia.commands.MgnlCommand#execute(info.magnolia.context.Context)
 */
@Override
public boolean execute(Context context) throws Exception {
  if (StringUtils.isNotEmpty(message)) {
    Messages msgs = MessagesUtil.chainWithDefault(this.getI18nBasename());
    AlertUtil.setMessage(msgs.getWithDefault(message, message));
  }
  return true;
}

代码示例来源:origin: info.magnolia/magnolia-templating

/**
 * @deprecated since 5.4.4. Use new i18n mechanism instead.
 */
@Deprecated
protected String getDefinitionMessage(RenderableDefinition definition, String key) {
  Messages messages = MessagesUtil.chain(definition.getI18nBasename(), MessagesUtil.chainWithDefault(DEFAULT_I18N_BASENAME));
  return messages.getWithDefault(key, key);
}

代码示例来源:origin: info.magnolia/magnolia-core

/**
 * Uses the i18n mechanism to translate the message if the resulting string is a key.
 */
public static String getI18NString(Content node, String str) {
  Messages msgs = MessagesManager.getMessages();
  String key = getString(node, str);
  String i18nBasename = null;
  try {
    i18nBasename = NodeDataUtil.inheritString(node, "i18nBasename");
  } catch (RepositoryException e) {
    log.error("can't read i18nBasename value, will default back", e);
  }
  if (StringUtils.isNotEmpty(i18nBasename)) {
    msgs = MessagesUtil.chainWithDefault(i18nBasename);
  }
  return msgs.getWithDefault(key, key);
}

代码示例来源:origin: info.magnolia/magnolia-templating-compatibility

public String getI18NTitle() {
  Messages msgs = MessagesManager.getMessages(getI18nBasename());
  return msgs.getWithDefault(getTitle(), getTitle());
}

代码示例来源:origin: info.magnolia/magnolia-module-templating

public String getI18NTitle() {
  Messages msgs = MessagesManager.getMessages(getI18nBasename());
  return msgs.getWithDefault(getTitle(), getTitle());
}

相关文章