{"record":{"id":"4f3b35527cdc052d","repo":"Humanizr/Humanizer","slug":"culture-culture-name-does-not-resolve-to-simpl","errorCode":null,"errorMessage":"Culture '{culture.Name}' does not resolve to simplified or traditional Chinese.","messagePattern":"Culture '(.+?)' does not resolve to simplified or traditional Chinese\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Humanizer/ChineseFinancialNumeralExtensions.cs","lineNumber":68,"sourceCode":"    /// </remarks>\n    public static string ToChineseFinancialCharacters(this long number, CultureInfo culture)\n    {\n        ArgumentNullException.ThrowIfNull(culture);\n\n        for (var current = culture; !string.IsNullOrEmpty(current.Name); current = current.Parent)\n        {\n            if (current.Name == \"zh-Hans\")\n            {\n                return SimplifiedConverter.Convert(number);\n            }\n\n            if (current.Name == \"zh-Hant\")\n            {\n                return TraditionalConverter.Convert(number);\n            }\n        }\n\n        throw new NotSupportedException(\n            $\"Culture '{culture.Name}' does not resolve to simplified or traditional Chinese.\");\n    }\n\n    static EastAsianGroupedNumberToWordsConverter CreateConverter(\n        string negativePrefix,\n        string[] digitWords,\n        string[] largeUnits) =>\n        new(new(\n            \"零\",\n            negativePrefix,\n            \"\",\n            \"\",\n            digitWords,\n            [\"\", \"拾\", \"佰\", \"仟\"],\n            largeUnits,\n            false,\n            false,\n            false,","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer/ChineseFinancialNumeralExtensions.cs#L50-L86","documentation":"Thrown by ToChineseFinancialCharacters when the supplied CultureInfo does not resolve, via its parent chain, to either 'zh-Hans' (simplified) or 'zh-Hant' (traditional). The method walks culture.Parent until the name is empty and throws NotSupportedException if neither neutral Chinese culture is found. Only cultures within the simplified or traditional Chinese hierarchy are supported.","triggerScenarios":"Calling number.ToChineseFinancialCharacters(CultureInfo.GetCultureInfo(\"en-US\")), passing CultureInfo.InvariantCulture, passing the neutral \"zh\" culture (which is neither Hans nor Hant), or passing a regional culture like \"zh-SG\" only if its parent chain reaches zh-Hans (it does, so that case succeeds).","commonSituations":"Using the ambient CurrentCulture (e.g. a server set to en-US) and forgetting to pass an explicit Chinese culture; passing a culture built from an ISO code that does not carry the Hans/Hant script subtag; locale-detection logic that maps 'Chinese' to the bare 'zh' tag.","solutions":["Pass an explicit culture in the zh-Hans or zh-Hant family, e.g. CultureInfo.GetCultureInfo(\"zh-Hans\") for simplified or \"zh-Hant\" for traditional.","If the culture comes from user/request data, validate that its name starts with 'zh-' before calling, and choose Hans vs Hant explicitly.","When you only have a bare 'zh' tag, decide the script explicitly and construct the neutral culture yourself rather than relying on resolution."],"exampleFix":"// before\nvar s = amount.ToChineseFinancialCharacters(CultureInfo.CurrentCulture);\n\n// after\nvar culture = CultureInfo.GetCultureInfo(simplified ? \"zh-Hans\" : \"zh-Hant\");\nvar s = amount.ToChineseFinancialCharacters(culture);","handlingStrategy":"validation","validationCode":"static bool ResolvesToChinese(CultureInfo c)\n{\n    for (var cur = c; !string.IsNullOrEmpty(cur.Name); cur = cur.Parent)\n        if (cur.Name is \"zh-Hans\" or \"zh-Hant\") return true;\n    return false;\n}\nif (!ResolvesToChinese(culture))\n    throw new NotSupportedException(\"Pass a zh-Hans or zh-Hant culture.\");\nvar s = number.ToChineseFinancialCharacters(culture);","typeGuard":"static bool IsChineseCulture(CultureInfo c) =>\n    c.Name.StartsWith(\"zh-\", StringComparison.OrdinalIgnoreCase);","tryCatchPattern":"try { return number.ToChineseFinancialCharacters(culture); }\ncatch (NotSupportedException) { /* pick a default script */ return number.ToChineseFinancialCharacters(CultureInfo.GetCultureInfo(\"zh-Hans\")); }","preventionTips":["Always pass an explicit zh-Hans or zh-Hant culture; do not rely on CurrentCulture.","Validate locale strings at the boundary to ensure they carry a script subtag.","Do not pass the bare 'zh' neutral culture."],"tags":["localization","culture","chinese","not-supported"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}