public static string GetMessage(string messageId, object[] args) { Context cx = Context.GetCurrentContext(); CultureInfo locale = cx == null ? CultureInfo.CurrentCulture : cx.GetLocale(); // ResourceBundle does caching. ResourceBundle rb = ResourceBundle.GetBundle("org.mozilla.javascript.tools.resources.Messages", locale); string formatString; try { formatString = rb.GetString(messageId); } catch (MissingResourceException) { throw new Exception("no message resource found for message property " + messageId); } if (args == null) { return formatString; } else { MessageFormat formatter = new MessageFormat(formatString); return formatter.Format(args); } }
public string Format(params object[] args) { return(MessageFormat.Format(Message, args)); }
public virtual string GetMessage(string messageId, object[] arguments) { string defaultResource = "org.mozilla.javascript.resources.Messages"; Context cx = Context.GetCurrentContext(); CultureInfo locale = cx != null ? cx.GetLocale() : CultureInfo.CurrentCulture; // ResourceBundle does caching. ResourceBundle rb = ResourceBundle.GetBundle(defaultResource, locale); string formatString; try { formatString = rb.GetString(messageId); } catch (MissingResourceException) { throw new Exception("no message resource found for message property " + messageId); } MessageFormat formatter = new MessageFormat(formatString); return formatter.Format(arguments); }
//public override string GetLocalizedMessage() public string GetLocalizedMessage() { MessageFormat format = new MessageFormat(bundle.GetString(key.ToString())); object[] args = new object[] { serviceName }; return format.Format(args); }