Ejemplo n.º 1
0
        /**
         * Constructor
         *
         * @param l the locale
         */
        public FunctionNames(CultureInfo locale)
        {
//			ResourceBundle rb = ResourceBundle.getBundle("functions",locale);
            Function[] allfunctions = Function.getFunctions();
            names     = new Dictionary <Function, string>(allfunctions.Length);
            functions = new Dictionary <string, Function>(allfunctions.Length);

            string languageCode = locale.IetfLanguageTag;

            if (languageCode.IndexOf('-') > 0)
            {
                languageCode = languageCode.Substring(0, languageCode.IndexOf('-'));                            // tear off country from IETF tag
            }
            // Iterate through all the functions, adding them to the hash maps
            for (int i = 0; i < allfunctions.Length; i++)
            {
                Function f        = allfunctions[i];
                string   propname = f.getPropertyName();

                string localName = FunctionNameLookup.LookupFunctionName(languageCode, propname);
                if (localName != null)
                {
                    string s = localName.ToUpper();                             // keys are always uppercase
                    names.Add(f, s);
                    functions.Add(s, f);
                }
                else                               // CML - should the function still not be IN the list of functions even if it not in the language?
                {
                    string s = propname.ToUpper(); // keys are always uppercase
                    if (!functions.ContainsKey(s))
                    {
                        names.Add(f, s);
                        functions.Add(s, f);
                    }
                }
            }
        }