{"record":{"id":"8019d7a808bfc126","repo":"abpframework/abp","slug":"failed-to-get-localization-information-from-refer","errorCode":null,"errorMessage":"Failed to get localization information from {referenceFile} file.","messagePattern":"Failed to get localization information from (.+?) file\\.","errorType":"exception","errorClass":"CliUsageException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/TranslateCommand.cs","lineNumber":193,"sourceCode":"                    $\"Failed to get localization information from {targetFile} file.\" +\n                    Environment.NewLine + Environment.NewLine +\n                    GetUsageInfo()\n                );\n            }\n\n            var referenceFile = Path.Combine(resource.ResourcePath, translateInfo.ReferenceCulture + \".json\");\n            if (!File.Exists(referenceFile))\n            {\n                throw new CliUsageException(\n                    $\"{referenceFile} file does not exist..\" +\n                    Environment.NewLine + Environment.NewLine +\n                    GetUsageInfo()\n                );\n            }\n            var referenceLocalizationInfo = GetAbpLocalizationInfoOrNull(referenceFile);\n            if (referenceLocalizationInfo == null)\n            {\n                throw new CliUsageException(\n                    $\"Failed to get localization information from {referenceFile} file.\" +\n                    Environment.NewLine + Environment.NewLine +\n                    GetUsageInfo()\n                );\n            }\n\n            var translator = new Translator(authKey);\n\n            var texts = resource.Texts.Select(x => x.Reference);\n\n            var translations = await translator.TranslateTextAsync(texts, await GetDeeplLanguageCode(referenceCulture), await GetDeeplLanguageCode(targetCulture));\n            for (var i = 0; i < translations.Length; i++)\n            {\n                resource.Texts[i].Target = translations[i].Text;\n            }\n\n            foreach (var text in resource.Texts)\n            {","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/TranslateCommand.cs#L175-L211","documentation":"Thrown during online translation (TranslateAbpTranslateInfoAsync) when the reference culture JSON file exists but GetAbpLocalizationInfoOrNull returns null. Same parsing failure as error 173 but for the reference file instead of the target. The file exists (File.Exists returned true at line 182) but its content is invalid JSON or lacks the 'culture'/'texts' properties.","triggerScenarios":"The reference culture JSON file (e.g., en.json) exists in a resource directory but is malformed. GetAbpLocalizationInfoOrNull returns null after failing JObject.Parse or finding missing culture/texts properties.","commonSituations":"Corrupted reference localization file, non-ABP format JSON file accidentally placed in the localization directory, manually edited file with syntax errors, file from an incompatible ABP version.","solutions":["Validate the reference JSON file with a JSON linter","Ensure the file has both 'culture' and 'texts' top-level properties","Restore the file from version control if corrupted","Run 'abp translate --verify' to identify which files have JSON issues"],"exampleFix":"// before (malformed en.json)\n{\"culture\": \"en\", \"texts\":}\n\n// after (valid)\n{\"culture\": \"en\", \"texts\": {\"Welcome\": \"Welcome\"}}","handlingStrategy":"validation","validationCode":"// Pre-validate reference culture JSON files\nforeach (var refFile in Directory.GetFiles(localizationDir, $\"{referenceCulture}.json\", SearchOption.AllDirectories))\n{\n    try\n    {\n        var obj = JObject.Parse(File.ReadAllText(refFile));\n        if (obj[\"culture\"] == null || obj[\"texts\"] == null)\n            Console.Error.WriteLine($\"Warning: {refFile} missing required properties\");\n    }\n    catch\n    {\n        Console.Error.WriteLine($\"Error: {refFile} is not valid JSON\");\n    }\n}","typeGuard":"// Check if reference file is valid ABP localization JSON\npublic static bool IsValidReferenceLocalization(string path)\n{\n    if (!File.Exists(path)) return false;\n    try\n    {\n        var obj = JObject.Parse(File.ReadAllText(path));\n        return obj[\"culture\"] != null && obj[\"texts\"] != null;\n    }\n    catch { return false; }\n}","tryCatchPattern":"try\n{\n    await TranslateAbpTranslateInfoAsync(directory, targetCulture, referenceCulture, allValues, authKey);\n}\ncatch (CliUsageException ex) when (ex.Message.Contains(\"Failed to get localization information\") && ex.Message.Contains(referenceCulture))\n{\n    Console.Error.WriteLine($\"Reference localization file is corrupted. Restore from version control.\");\n}","preventionTips":["Run 'abp translate --verify' before online translation to catch malformed JSON","Never directly edit reference (en.json) localization files without validation","Keep reference files under version control and avoid manual edits","Use ABP's localization JSON schema if your IDE supports schema validation"],"tags":["translate","localization","json","file-validation","reference-culture","online"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}