Exemplo n.º 1
0
		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);
			}
		}
Exemplo n.º 2
0
 public string Format(params object[] args)
 {
     return(MessageFormat.Format(Message, args));
 }
Exemplo n.º 3
0
			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);
			}
Exemplo n.º 4
0
 //public override string GetLocalizedMessage()
 public string GetLocalizedMessage()
 {
     MessageFormat format = new MessageFormat(bundle.GetString(key.ToString()));
     object[] args = new object[] { serviceName };
     return format.Format(args);
 }