private static string GetJsOutputFileName(Options options, ResourceFile resourceFile) { var jsFileName = string.IsNullOrEmpty(options.JavaScriptFileName) ? resourceFile.ResourceFilePathName.Substring(resourceFile.ResourceFilePathName.LastIndexOf("\\") + 1) : options.JavaScriptFileName; //var jsFileNameWithoutPath = jsFileName + ".js"; // CT: Made the file replace the resx with json var jsFileNameWithoutPath = jsFileName.Replace("resx","json"); var outputJsFilePathName = Path.Combine(options.OutputFolder, jsFileNameWithoutPath); return outputJsFilePathName; }
private void GenerateJsResourceFiles(Options options, IEnumerable<ResourceFile> resourceFiles, ResourceFile baseResourceFile) { ////var baseResourceDict = resxReader.GetKeyValuePairsFromResxFile(baseResourceFile); foreach (var resourceFile in resourceFiles) { var outputJsFilePathName = GetJsOutputFileName(options, resourceFile); // CT: Treat all files the same //if (resourceFile.IsBaseResourceType) //{ // this.WriteOutput(options, baseResourceDict, outputJsFilePathName); //} //else //{ // var cultureSpecificResourceDict = this.GetCultureSpecificResourceDictFromBaseDict(baseResourceDict, resourceFile); // this.WriteOutput(options, cultureSpecificResourceDict, outputJsFilePathName); //} Dictionary<string, string> resourceDict = resxReader.GetKeyValuePairsFromResxFile(resourceFile); if (resourceDict.Count == 0) { resourceDict.Add("__comment", "Empty"); } this.WriteOutput(options, resourceDict, outputJsFilePathName); } }
private Dictionary<string, string> GetCultureSpecificResourceDictFromBaseDict(Dictionary<string, string> baseResourceDict, ResourceFile resourceFile) { var cultureSpecificResourceDict = this.objectCopier.Copy(baseResourceDict); var rsxr = new ResXResourceReader(resourceFile.ResourceFilePathName); try { foreach (DictionaryEntry d in rsxr) { var key = d.Key as string; if (key != null) { cultureSpecificResourceDict[key] = d.Value.ToString(); } } } finally { rsxr.Close(); } return cultureSpecificResourceDict; }