{"record":{"id":"8d24ba0df9f3bf12","repo":"opendatalab/MinerU","slug":"language-lang-not-supported","errorCode":null,"errorMessage":"Language {lang} not supported","messagePattern":"Language (.+?) not supported","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"mineru/model/ocr/pytorch_paddle.py","lineNumber":39,"sourceCode":"    sorted_boxes,\n    merge_det_boxes,\n    update_det_boxes,\n    get_rotate_crop_image_for_text_rec,\n)\nfrom mineru.model.utils.tools.infer.predict_system import TextSystem\nfrom mineru.model.utils.tools.infer import pytorchocr_utility as utility\nimport argparse\n\n\ndef get_model_params(lang, config):\n    if lang in config['lang']:\n        params = config['lang'][lang]\n        det = params.get('det')\n        rec = params.get('rec')\n        dict_file = params.get('dict')\n        return det, rec, dict_file\n    else:\n        raise Exception (f'Language {lang} not supported')\n\n\nroot_dir = os.path.join(Path(__file__).resolve().parent.parent, 'utils')\nDEFAULT_SEAL_DEBUG_DIR = os.path.join(\n    Path(__file__).resolve().parents[3],\n    'output_images',\n    'seal_ocr_debug',\n)\n\n\nclass PytorchPaddleOCR(TextSystem):\n    def __init__(self, *args, **kwargs):\n        parser = utility.init_args()\n        args = parser.parse_args(args)\n\n        requested_lang = kwargs.get('lang', 'ch')\n        self.lang = requested_lang\n        self.is_seal = requested_lang in ['seal', 'seal_lite']","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/model/ocr/pytorch_paddle.py#L21-L57","documentation":"get_model_params looks up the requested language in the OCR config's 'lang' table to fetch det/rec model names and dictionary path. If lang is not a key, it raises a plain Exception with the language name — there is no fallback language.","triggerScenarios":"Calling PytorchPaddleOCR/model-param resolution with lang='fr', 'german', 'zh-Hans', or any string not matching a config key exactly; keys are case-sensitive and typically like 'ch', 'en', 'japan'.","commonSituations":"Passing full locale names or ISO codes instead of the paddle-style short codes, typos, or using a language supported by upstream PaddleOCR but missing from this repo's trimmed config.","solutions":["Use the exact key from the config (inspect config['lang'].keys(), commonly 'ch', 'en', 'japan', 'korean', ...).","Fall back to 'ch' or 'en' if the language is unsupported but Latin/CJK-adjacent.","Add the language to the config with det/rec/dict entries copied from upstream PaddleOCR's config."],"exampleFix":"# before\nocr = PytorchPaddleOCR(lang='french')\n\n# after\nocr = PytorchPaddleOCR(lang='fr')  # exact key from config['lang']","handlingStrategy":"validation","validationCode":"SUPPORTED = set(config['lang'].keys())\nif lang not in SUPPORTED:\n    lang = 'ch' if 'ch' in SUPPORTED else next(iter(SUPPORTED))\n    logger.warning('lang %s unsupported, falling back to %s', lang, lang)","typeGuard":"def is_supported_lang(lang: str, config) -> bool:\n    return lang in config.get('lang', {})","tryCatchPattern":"try:\n    det, rec, dic = get_model_params(lang, config)\nexcept Exception as e:\n    if 'not supported' in str(e):\n        det, rec, dic = get_model_params('ch', config)  # explicit fallback\n    else:\n        raise","preventionTips":["Print config['lang'].keys() once at startup for operators.","Normalize user locale input (fr-FR -> fr) before lookup.","Treat lang as a controlled vocabulary validated at config load."],"tags":["ocr","configuration","validation"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}