{"record":{"id":"3100eebc4e9cdc4a","repo":"nodejs/node","slug":"warning-the-top-level-tag-in-the-resource-and-lan","errorCode":null,"errorMessage":"Warning: The top level tag in the resource and language specified are not the same. Please check the input.\n","messagePattern":"Warning: The top level tag in the resource and language specified are not the same\\. Please check the input\\.\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"deps/icu-small/source/tools/genrb/wrtxml.cpp","lineNumber":1158,"sourceCode":"        *status = U_FILE_ACCESS_ERROR;\n        goto cleanup_bundle_write_xml;\n    }\n    write_utf8_file(out, UnicodeString(xmlHeader));\n\n    if(outputEnc && *outputEnc!='\\0'){\n        /* store the output encoding */\n        enc = outputEnc;\n        conv=ucnv_open(enc,status);\n        if(U_FAILURE(*status)){\n            goto cleanup_bundle_write_xml;\n        }\n    }\n    write_utf8_file(out, UnicodeString(bundleStart));\n    write_tabs(out);\n    write_utf8_file(out, UnicodeString(fileStart));\n    /* check if lang and language are the same */\n    if(language != nullptr && uprv_strcmp(lang, srBundle->fLocale)!=0){\n        fprintf(stderr,\"Warning: The top level tag in the resource and language specified are not the same. Please check the input.\\n\");\n    }\n    write_utf8_file(out, UnicodeString(lang));\n    write_utf8_file(out, UnicodeString(file1));\n    write_utf8_file(out, UnicodeString(file2));\n    write_utf8_file(out, UnicodeString(originalFileName));\n    write_utf8_file(out, UnicodeString(file4));\n\n    time(&currTime);\n    strftime(timeBuf, sizeof(timeBuf), \"%Y-%m-%dT%H:%M:%SZ\", gmtime(&currTime));\n    write_utf8_file(out, UnicodeString(timeBuf));\n    write_utf8_file(out, UnicodeString(\"\\\">\\n\"));\n\n    tabCount += 1;\n    write_tabs(out);\n    write_utf8_file(out, UnicodeString(headerStart));\n\n    tabCount += 1;\n    write_tabs(out);","sourceCodeStart":1140,"sourceCodeEnd":1176,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/genrb/wrtxml.cpp#L1140-L1176","documentation":"During XLIFF XML output, genrb compares the language code extracted from the filename/table name (lang) against the bundle's internal locale string (srBundle->fLocale). If they differ, it prints this warning to stderr. This is a non-fatal warning — processing continues. It signals a potential mismatch between the bundle's identity and its declared language.","triggerScenarios":"The language code parsed from the filename (or provided via -l) does not match the locale string stored in the bundle (srBundle->fLocale). For example, the file is named 'en_US.txt' but the top-level table inside is 'root' or 'fr'. The warning is printed but the XLIFF output proceeds with the 'lang' value.","commonSituations":"Renaming a .txt file without updating the top-level table name inside it; copy-pasting a locale file as a template for a different locale and forgetting to update the internal name; specifying -l with a different language than the bundle's actual locale; CLDR data files where the filename convention differs from the table name.","solutions":["Check if the filename and the top-level table name inside the .txt file match — they should use the same locale code","If using -l, ensure it matches the bundle's actual locale","Update the top-level table name to match the filename, or vice versa","If the mismatch is intentional (e.g. alias processing), suppress the warning by redirecting stderr or using --quiet if available","This is a warning only — verify the XLIFF output has the correct xml:lang attribute and proceed if it is correct"],"exampleFix":"// before: filename/table mismatch\nfile: en_US.txt\ncontents:\n    fr {\n        greeting { \"Bonjour\" }\n    }\n// after: filename and table name match\nfile: fr.txt\ncontents:\n    fr {\n        greeting { \"Bonjour\" }\n    }","handlingStrategy":"validation","validationCode":"# Check for filename/table name locale mismatch before genrb --write-xliff\nfor f in data/*.txt; do\n    base=$(basename \"$f\" .txt)\n    # Extract the top-level table name from the file\n    table=$(grep -m1 -oP '^\\s*\\K\\w+(?=\\s*\\{)' \"$f\" 2>/dev/null | head -1)\n    if [ -n \"$table\" ] && [ \"$base\" != \"$table\" ]; then\n        echo \"MISMATCH: $f - filename='$base' table='$table'\"\n    fi\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep resource bundle filenames consistent with their internal top-level table names","When creating locale files from templates, update both the filename and the internal table name","If using -l, ensure it matches the bundle's actual locale","Treat this warning as a prompt to verify the XLIFF xml:lang attribute is correct"],"tags":["icu","genrb","xliff","warning","locale-mismatch"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}