public virtual XLRTargetNode checkLocales(System.Globalization.CultureInfo locale, System.String id)
        {
            XLRTargetNode t = checkPrefix(locale, id, locale, id);

            //UPGRADE_ISSUE: Method 'java.util.Locale.getVariant' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javautilLocalegetVariant'"
            if ((t == null) && (new System.Globalization.RegionInfo(locale.LCID).TwoLetterISORegionName.Length > 0) && (locale.getVariant().Length > 0))
            {
                //UPGRADE_WARNING: Constructor 'java.util.Locale.Locale' was converted to 'System.Globalization.CultureInfo' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
                //UPGRADE_TODO: Method 'java.util.Locale.getLanguage' was converted to 'System.Globalization.CultureInfo.TwoLetterISOLanguageName' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilLocalegetLanguage'"
                t = checkPrefix(new System.Globalization.CultureInfo(locale.TwoLetterISOLanguageName + "-" + new System.Globalization.RegionInfo(locale.LCID).TwoLetterISORegionName), id, locale, id);
            }

            if ((t == null) && (new System.Globalization.RegionInfo(locale.LCID).TwoLetterISORegionName.Length > 0))
            {
                //UPGRADE_TODO: Method 'java.util.Locale.getLanguage' was converted to 'System.Globalization.CultureInfo.TwoLetterISOLanguageName' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilLocalegetLanguage'"
                t = checkPrefix(new Locale(locale.TwoLetterISOLanguageName), id, locale, id);
            }

            if ((t == null))
            {
                t = checkPrefix(null, id, locale, id);
            }

            return(t);
        }
        public virtual XLRTargetNode loadNode(System.Globalization.CultureInfo fileLocale, System.String fileId, System.Globalization.CultureInfo locale, System.String id)
        {
            System.String key = getKey(fileLocale, fileId);
            XLRFile       f   = (XLRFile)filedict[key];

            if (f == null)
            {
                System.String resource = key.replaceAll("\\.", "/") + ".xlr";
                //UPGRADE_ISSUE: Method 'java.lang.ClassLoader.getResource' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangClassLoader'"
                //UPGRADE_ISSUE: Method 'java.lang.Class.getClassLoader' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangClassgetClassLoader'"
                System.Uri url = GetType().getClassLoader().getResource(resource);

                if (url != null)
                {
                    f             = new XLRFile(this, fileId, url);
                    filedict[key] = f;
                }
            }
            if (f != null)
            {
                f.load();
                XLRMessageNode messageNode = (XLRMessageNode)nodedict[id];
                if (messageNode != null)
                {
                    XLRTargetNode targetNode = messageNode.getTarget(locale.ToString());
                    return(targetNode);
                }
            }

            return(null);
        }
        public virtual XLRTargetNode checkPrefix(System.Globalization.CultureInfo fileLocale, System.String fileId, System.Globalization.CultureInfo locale, System.String id)
        {
            XLRTargetNode t = loadNode(fileLocale, fileId, locale, id);

            if (t == null)
            {
                int sep = fileId.LastIndexOf('$');

                if (sep == -1)
                {
                    sep = fileId.LastIndexOf('.');
                }

                if (sep != -1)
                {
                    t = checkPrefix(fileLocale, fileId.Substring(0, (sep) - (0)), locale, id);
                }
            }
            return(t);
        }
        public virtual ILocalizedText getLocalizedText(System.Globalization.CultureInfo locale, System.String id)
        {
            XLRMessageNode messageNode = (XLRMessageNode)nodedict[id];
            XLRTargetNode  targetNode  = null;

            if (messageNode != null)
            {
                targetNode = messageNode.getTarget(locale.ToString());
            }

            if (targetNode == null)
            {
                targetNode = checkLocales(locale, id);
            }

            if (targetNode == null)
            {
                return(null);
            }

            return(new XLRLocalizedText(this, targetNode));
        }
Example #5
0
			public override void  startElement(System.String uri, System.String localName, System.String qName, SaxAttributesSupport attributes)
			{
				XLRNode current = null;
				if (context.Count > 0)
				{
					current = (XLRNode) context[context.Count - 1];
				}
				
				// common shortcuts...
				System.String locale = attributes.GetValue("locale");
				if (locale == null)
					locale = fileLocale;
				System.String text = attributes.GetValue("text");
				
				XLRNode node = null;
				if ("messages".Equals(qName))
				{
					fileLocale = attributes.GetValue("locale");
					if (attributes.GetValue("idbase") != null)
						base_Renamed = attributes.GetValue("idbase");
				}
				else if ("message".Equals(qName))
				{
					System.String id = attributes.GetValue("id");
					
					if (base_Renamed != null)
						id = base_Renamed + "." + id;
					
					node = (XLRMessageNode) nodedict[id];
					if (node == null)
					{
						node = new XLRMessageNode(id);
						nodedict[id] = node;
					}
					if ((text != null) && (locale != null))
					// check errors
					{
						XLRTargetNode targetNode = new XLRTargetNode(locale);
						node.children.Add(targetNode);
						XLRTextNode textNode = new XLRTextNode(text);
						targetNode.children.Add(textNode);
					}
					
					
					context.Add(node);
				}
				else if ("target".Equals(qName))
				{
					node = new XLRTargetNode(locale);
					if (text != null)
						node.children.Add(new XLRTextNode(text));
					
					current.children.Add(node);
					context.Add(node);
				}
				else if ("text".Equals(qName))
				{
					System.String value_Renamed = attributes.GetValue("value");
					
					node = new XLRTextNode(value_Renamed);
					
					current.children.Add(node);
					context.Add(node);
				}
				else if ("variable".Equals(qName))
				{
					System.String name = attributes.GetValue("name");
					
					node = new XLRVariableNode(name);
					current.children.Add(node);
					context.Add(node);
				}
				else if ("match".Equals(qName))
				{
					node = new XLRMatchNode(attributes.GetValue("variable"), attributes.GetValue("pattern"));
					if (text != null)
						node.children.Add(new XLRTextNode(text));
					
					current.children.Add(node);
					context.Add(node);
				}
				else if ("select".Equals(qName))
				{
					node = new XLRChoiceNode();
					current.children.Add(node);
					context.Add(node);
				}
				else
				{
					//UPGRADE_ISSUE: Constructor 'org.xml.sax.SAXParseException.SAXParseException' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_orgxmlsaxSAXParseExceptionSAXParseException_javalangString_orgxmlsaxLocator'"
					throw new SAXParseException("blorp", null); // fixme
				}
			}
Example #6
0
			public XLRLocalizedText(XLRTargetNode node)
			{
				this.node = node;
			}
            public override void  startElement(System.String uri, System.String localName, System.String qName, SaxAttributesSupport attributes)
            {
                XLRNode current = null;

                if (context.Count > 0)
                {
                    current = (XLRNode)context[context.Count - 1];
                }

                // common shortcuts...
                System.String locale = attributes.GetValue("locale");
                if (locale == null)
                {
                    locale = fileLocale;
                }
                System.String text = attributes.GetValue("text");

                XLRNode node = null;

                if ("messages".Equals(qName))
                {
                    fileLocale = attributes.GetValue("locale");
                    if (attributes.GetValue("idbase") != null)
                    {
                        base_Renamed = attributes.GetValue("idbase");
                    }
                }
                else if ("message".Equals(qName))
                {
                    System.String id = attributes.GetValue("id");

                    if (base_Renamed != null)
                    {
                        id = base_Renamed + "." + id;
                    }

                    node = (XLRMessageNode)nodedict[id];
                    if (node == null)
                    {
                        node         = new XLRMessageNode(id);
                        nodedict[id] = node;
                    }
                    if ((text != null) && (locale != null))
                    // check errors
                    {
                        XLRTargetNode targetNode = new XLRTargetNode(locale);
                        node.children.Add(targetNode);
                        XLRTextNode textNode = new XLRTextNode(text);
                        targetNode.children.Add(textNode);
                    }


                    context.Add(node);
                }
                else if ("target".Equals(qName))
                {
                    node = new XLRTargetNode(locale);
                    if (text != null)
                    {
                        node.children.Add(new XLRTextNode(text));
                    }

                    current.children.Add(node);
                    context.Add(node);
                }
                else if ("text".Equals(qName))
                {
                    System.String value_Renamed = attributes.GetValue("value");

                    node = new XLRTextNode(value_Renamed);

                    current.children.Add(node);
                    context.Add(node);
                }
                else if ("variable".Equals(qName))
                {
                    System.String name = attributes.GetValue("name");

                    node = new XLRVariableNode(name);
                    current.children.Add(node);
                    context.Add(node);
                }
                else if ("match".Equals(qName))
                {
                    node = new XLRMatchNode(attributes.GetValue("variable"), attributes.GetValue("pattern"));
                    if (text != null)
                    {
                        node.children.Add(new XLRTextNode(text));
                    }

                    current.children.Add(node);
                    context.Add(node);
                }
                else if ("select".Equals(qName))
                {
                    node = new XLRChoiceNode();
                    current.children.Add(node);
                    context.Add(node);
                }
                else
                {
                    //UPGRADE_ISSUE: Constructor 'org.xml.sax.SAXParseException.SAXParseException' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_orgxmlsaxSAXParseExceptionSAXParseException_javalangString_orgxmlsaxLocator'"
                    throw new SAXParseException("blorp", null);                     // fixme
                }
            }
 public XLRLocalizedText(XLRTargetNode node)
 {
     this.node = node;
 }