{"record":{"id":"7324face19bf4ec8","repo":"arduino/Arduino","slug":"no-language-code-s","errorCode":null,"errorMessage":"No language code %s","messagePattern":"No language code (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"arduino-core/src/processing/app/i18n/python/transifex.py","lineNumber":35,"sourceCode":"    r.raise_for_status()\n    d = r.json()\n    self.languages_ = set(lang['code'] for lang in d['available_languages'])\n\n  def canonical_lang(self, lang):\n    lang = lang.lower()\n\n    for l in self.languages_:\n      if l.lower() == lang:\n        return l\n\n    match = []\n    for l in self.languages_:\n      if l.split('_', 1)[0].lower() == lang:\n        match.append(l)\n    if len(match) > 1:\n      raise RuntimeError('Two or more candidates for %s: %s' % (lang, ' '.join(match)))\n    if len(match) == 0:\n      raise RuntimeError('No language code %s' % lang)\n    return match[0]\n\n  def translation(self, lang):\n    r = requests.get(\n      'https://www.transifex.com/api/2/project/arduino-ide-15/resource/ide-15/translation/%s/?file' % lang,\n      auth=self.auth_\n    )\n    r.raise_for_status()\n    r.encoding = 'utf-8'  # workaround for a Transifex issue.\n    return r.text\n\n  def pull(self, lang, fname):\n    new = self.translation(lang).encode('utf-8')\n    new = map(lambda a: a + '\\n', new.split('\\n'))\n    new = update.read_po(new)\n\n    update.dump(new, fname)\n","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/arduino/Arduino/blob/a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee/arduino-core/src/processing/app/i18n/python/transifex.py#L17-L53","documentation":"canonical_lang raises this RuntimeError when no language in the project's language list has a base code matching the requested one. It indicates the requested language does not exist in the Transifex project.","triggerScenarios":"Calling canonical_lang(lang) with a code (after lowercasing and splitting on '_') that matches none of self.languages_, e.g. 'de' when the project only has 'en', 'it', etc.","commonSituations":"Typo in the language code; requesting a language the project never had; project language list fetched before new languages were added; case/format mismatches the split('_')[0].lower() normalization does not cover.","solutions":["Check the exact RuntimeError message to see which code was requested and compare with the project's available languages.","Fetch the current language list from the Transifex project API and request only codes present in it.","Fix typos and use the canonical code used by the project (e.g. 'nb' vs 'no').","Guard the call: skip languages not in the project's list instead of letting the script abort."],"exampleFix":"// before\ncanonical_lang('gr')  # typo, no such code\n# after\ncanonical_lang('el')  # or skip if lang not in project.languages_","handlingStrategy":"validation","validationCode":"if not any(l.split('_', 1)[0].lower() == lang for l in project.languages_):\n    raise ValueError('language %s not in project' % lang)","typeGuard":null,"tryCatchPattern":"try:\n    code = tx.canonical_lang(lang)\nexcept RuntimeError:\n    print('skipping unavailable language', lang)\n    return","preventionTips":["Fetch the project's language list before iterating languages","Validate language codes against the Transifex API","Handle locale code aliases (no/nb, zh) explicitly"],"tags":["python","i18n","transifex","localization"],"backgroundTag":"resource-not-found","analyzedSha":"a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee","analyzedAt":"2026-09-06T10:13:38.901Z","contentChangedAt":"2026-09-06T10:13:38.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}