{"record":{"id":"bd77ab6e05ba05ab","repo":"abpframework/abp","slug":"failed-to-get-localization-information-from-targe","errorCode":null,"errorMessage":"Failed to get localization information from {targetFile} 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":174,"sourceCode":"        {\n            Logger.LogInformation(\"Include all keys\");\n        }\n\n        var translateInfo = GetAbpTranslateInfo(directory, targetCulture, referenceCulture, allValues);\n        foreach (var resource in translateInfo.Resources)\n        {\n            var targetFile = Path.Combine(resource.ResourcePath, translateInfo.TargetCulture + \".json\");\n            var targetLocalizationInfo = File.Exists(targetFile)\n                ? GetAbpLocalizationInfoOrNull(targetFile)\n                : new AbpLocalizationInfo()\n                {\n                    Culture = translateInfo.TargetCulture,\n                    Texts = new List<NameValue>()\n                };\n\n            if (targetLocalizationInfo == null)\n            {\n                throw new CliUsageException(\n                    $\"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            {","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/TranslateCommand.cs#L156-L192","documentation":"Thrown during online translation (TranslateAbpTranslateInfoAsync) when the target culture JSON file exists on disk but GetAbpLocalizationInfoOrNull returns null. This occurs when the file contains invalid JSON (JObject.Parse throws) or is missing the required 'culture' and/or 'texts' top-level properties. The target file path is constructed as Path.Combine(resource.ResourcePath, translateInfo.TargetCulture + '.json').","triggerScenarios":"The target culture JSON file (e.g., zh-Hans.json) exists in a resource directory but is malformed. GetAbpLocalizationInfoOrNull catches the JObject.Parse exception and returns null, or the culture/texts properties are missing, causing the null check at line 172 to fire.","commonSituations":"Manually edited localization file with syntax errors, BOM or encoding issues, incomplete file from a failed git merge, file from an incompatible ABP version with a different JSON schema, accidental truncation.","solutions":["Validate the target culture JSON file with a JSON linter (e.g., 'jq empty zh-Hans.json')","Ensure the file has both 'culture' and 'texts' top-level properties","Fix any JSON syntax errors (missing commas, trailing commas, unescaped quotes)","If the file is corrupted beyond repair, delete it and let the translate command create a fresh one"],"exampleFix":"// before (malformed zh-Hans.json)\n{\"culture\": \"zh-Hans\", \"texts\":}\n\n// after (valid)\n{\"culture\": \"zh-Hans\", \"texts\": {\"Welcome\": \"欢迎\"}}","handlingStrategy":"validation","validationCode":"// Pre-validate all target culture JSON files before online translation\nforeach (var jsonFile in Directory.GetFiles(localizationDir, $\"{targetCulture}.json\", SearchOption.AllDirectories))\n{\n    try\n    {\n        var obj = JObject.Parse(File.ReadAllText(jsonFile));\n        if (obj[\"culture\"] == null || obj[\"texts\"] == null)\n            Console.Error.WriteLine($\"Warning: {jsonFile} missing 'culture' or 'texts' property\");\n    }\n    catch\n    {\n        Console.Error.WriteLine($\"Error: {jsonFile} is not valid JSON\");\n    }\n}","typeGuard":"// Check if a JSON file is a valid ABP localization file\npublic static bool IsValidAbpLocalizationFile(string path)\n{\n    try\n    {\n        var obj = JObject.Parse(File.ReadAllText(path));\n        return obj[\"culture\"] != null && obj[\"texts\"] != null;\n    }\n    catch\n    {\n        return false;\n    }\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\"))\n{\n    Console.Error.WriteLine($\"Target localization file is invalid. Run 'abp translate --verify' to check.\");\n}","preventionTips":["Run 'abp translate --verify' before --online to validate all JSON files","Never manually edit localization JSON without validating afterward","Use a JSON linter or IDE with JSON validation","Commit clean localization files to avoid merge conflicts"],"tags":["translate","localization","json","file-validation","online"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}