public string GetJavaScript(string varname, string resourceSet, string localeId,
                                    string resourceType, string resourceMode)
        {
            // varname is embedded into script so validate to avoid script injection
            // it's gotta be a valid C# and valid JavaScript name
            var match = Regex.Match(varname, @"^[\w|\d|_|$|@|\.]*$");

            if (match.Length < 1 || match.Groups[0].Value != varname)
            {
                throw new WestwindException("Invalid variable name passed.");
            }

            if (string.IsNullOrEmpty(resourceSet))
            {
                throw new WestwindException("Invalid ResourceSet specified.");
            }

            // pick current UI Culture
            if (localeId == "auto")
            {
                localeId = Thread.CurrentThread.CurrentUICulture.IetfLanguageTag;
            }

            Dictionary <string, object> resDict = null;

            if (string.IsNullOrEmpty(resourceType) || resourceType == "auto")
            {
                resourceType = "resdb";
            }

            var basePath  = hostingEnvironment.MapPath(configuration.ResxBaseFolder);
            var converter = new DbResXConverter(configuration, basePath);

            if (resourceType.ToLower() == "resdb")
            {
                // use existing/cached resource manager if previously used
                // so database is accessed only on first hit
                var resManager = DbRes.GetResourceManager(resourceSet);

                resDict = converter.GetResourcesNormalizedForLocale(resManager, localeId);

                //resDict = manager.GetResourceSetNormalizedForLocaleId(localeId, resourceSet);
                if (resDict == null || resDict.Keys.Count < 1)
                {
                    // try resx instead
                    var resxPath = converter.FormatResourceSetPath(resourceSet);
                    resDict = converter.GetResXResourcesNormalizedForLocale(resxPath, localeId);
                }
            }
            else // Resx Resources
            {
                resDict = converter.GetCompiledResourcesNormalizedForLocale(resourceSet,
                                                                            configuration.ResourceBaseNamespace,
                                                                            localeId);

                if (resDict == null)
                {
                    // check for .resx disk resources
                    var resxPath = converter.FormatResourceSetPath(resourceSet);
                    resDict = converter.GetResXResourcesNormalizedForLocale(resxPath, localeId);
                }
                else
                {
                    resDict = resDict.OrderBy(kv => kv.Key).ToDictionary(k => k.Key, v => v.Value);
                }
            }


            if (resourceMode == "0")
            {
                resDict = resDict.Where(res => !res.Key.Contains('.') && res.Value is string)
                          .ToDictionary(dict => dict.Key, dict => dict.Value);
            }
            else
            {
                resDict = resDict.Where(res => res.Value is string)
                          .ToDictionary(dict => dict.Key, dict => dict.Value);
            }

            var javaScript = SerializeResourceDictionary(resDict, varname);

            return(javaScript);
        }