NickeManarin/ScreenToGif · error · WebException
Can't get language codes. Path to language codes is null
Error message
Can't get language codes. Path to language codes is null
What it means
Thrown by GetLanguageCodesAsync when GetLanguageCodesPathAsync returns null or empty. GetLanguageCodesPathAsync fetches datahub.io/core/language-codes/datapackage.json and extracts the 'path' of the 'ietf-language-tags_json' resource via XPath. If the JSON structure changed or the request failed internally, the path comes back empty.
Source
Thrown at Other/Translator/TranslatorWindow.xaml.cs:699
"en-NL;en-NR;en-NU;en-NZ;en-PG;en-PH;en-PK;en-PN;en-PW;en-RW;en-SB;en-SC;en-SD;en-SE;en-SG;en-SH;en-SI;en-SL;en-SS;en-SX;en-SZ;en-TK;en-TO;en-TT;en-TV;" +
"en-TZ;en-UG;en-VC;en-VU;en-WS;en-ZA;en-ZM;en-ZW;eo;es;es-419;es-AR;es-BO;es-BR;es-BZ;es-CL;es-CO;es-CR;es-CU;es-DO;es-EC;es-GQ;es-GT;es-HN;es-MX;es-NI;" +
"es-PA;es-PE;es-PH;es-PR;es-PY;es-SV;es-US;es-UY;es-VE;et;eu;ewo;fa;ff;ff-Latn-GH;ff-Latn-GM;ff-Latn-GN;ff-Latn-LR;ff-Latn-MR;ff-Latn-NG;ff-Latn-SL;fi;fil;" +
"fo;fo-DK;fr;fr-BE;fr-BI;fr-CA;fr-CD;fr-CH;fr-CI;fr-CM;fr-DJ;fr-DZ;fr-GF;fr-GN;fr-HT;fr-KM;fr-LU;fr-MA;fr-MG;fr-ML;fr-MR;fr-MU;fr-RE;fr-RW;fr-SC;fr-SN;fr-SY;" +
"fr-TD;fr-TN;fr-VU;fur;fy;ga;gd;gl;gsw;gu;guz;gv;ha;haw;he;hi;hr;hr-BA;hsb;hu;hy;ia;id;ig;ii;is;it;it-CH;ja;jgo;jmc;jv;ka;kab;kam;kde;kea;khq;ki;kk;kkj;kl;kln;" +
"km;kn;ko;ko-KP;kok;ks;ksb;ksf;ksh;ku;kw;ky;lag;lb;lg;lkt;ln;ln-AO;lo;lrc;lrc-IQ;lt;lu;luo;luy;lv;mas;mas-TZ;mer;mfe;mg;mgh;mgo;mi;mk;ml;mn;mni;mr;ms;ms-BN;ms-SG;" +
"mt;mua;my;mzn;naq;nb;nd;nds;nds-NL;ne;ne-IN;nl;nl-AW;nl-BE;nl-BQ;nl-CW;nl-SR;nl-SX;nmg;nn;nnh;nus;nyn;om;om-KE;or;os;os-RU;pa;pa-Arab;pl;prg;ps;ps-PK;pt;pt-AO;" +
"pt-CV;pt-GW;pt-LU;pt-MO;pt-MZ;pt-PT;pt-ST;pt-TL;rm;rn;ro;ro-MD;rof;ru;ru-BY;ru-KG;ru-KZ;ru-MD;ru-UA;rw;rwk;sah;saq;sbp;sd;sd-Deva;se;se-FI;se-SE;seh;ses;sg;shi;" +
"shi-Latn;si;sk;sl;smn;sn;so;so-DJ;so-ET;so-KE;sq;sq-MK;sq-XK;sr;sr-Cyrl-BA;sr-Cyrl-ME;sr-Cyrl-XK;sr-Latn;sr-Latn-BA;sr-Latn-ME;sr-Latn-XK;sv;sv-FI;sw;sw-CD;sw-KE;" +
"sw-UG;ta;ta-LK;ta-MY;ta-SG;te;teo;teo-KE;tg;th;ti;ti-ER;tk;to;tr;tr-CY;tt;twq;tzm;ug;uk;ur;ur-IN;uz;uz-Arab;uz-Cyrl;vai;vai-Latn;vi;vo;vun;wae;wo;xh;xog;yav;yi;yo;" +
"yo-BJ;zgh;zh;zh-Hans-HK;zh-Hans-MO;zh-Hant;zu").Split(';').ToList();
}
private async Task<IEnumerable<string>> GetLanguageCodesAsync()
{
var path = await GetLanguageCodesPathAsync();
if (string.IsNullOrEmpty(path))
throw new WebException("Can't get language codes. Path to language codes is null");
var request = (HttpWebRequest)WebRequest.Create(path);
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393";
var response = (HttpWebResponse)await request.GetResponseAsync();
using (var resultStream = response.GetResponseStream())
{
if (resultStream == null)
throw new WebException("Empty response from server when getting language codes");
using (var reader = new StreamReader(resultStream))
{
var result = await reader.ReadToEndAsync();
var jsonReader = JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(result),
new System.Xml.XmlDictionaryReaderQuotas());
View on GitHub (pinned to a4d0a67c21)
Solutions
- Manually browse to https://datahub.io/core/language-codes/datapackage.json and verify the 'resources' array still contains an entry with name 'ietf-language-tags_json' and a 'path' field.
- Check network connectivity and proxy settings for datahub.io.
- If datahub.io restructured, update the XPath filter in GetLanguageCodesPathAsync to match the new resource name.
- Cache the language codes list locally as a fallback when the remote service is unavailable.
Example fix
// before
var path = await GetLanguageCodesPathAsync();
if (string.IsNullOrEmpty(path))
throw new WebException("Can't get language codes. Path to language codes is null");
// after: fall back to the hardcoded list rather than throwing
var path = await GetLanguageCodesPathAsync();
if (string.IsNullOrEmpty(path))
return GetCachedLanguageCodes(); // returns the built-in hardcoded list Defensive patterns
Strategy: fallback
Validate before calling
var path = await GetLanguageCodesPathAsync();
// Instead of throwing, check and fall back to the hardcoded list
if (string.IsNullOrEmpty(path))
return GetCachedLanguageCodesFromHardcodedList(); Try / catch
try
{
return await GetLanguageCodesAsync();
}
catch (WebException)
{
return GetCachedLanguageCodesFromHardcodedList(); // built-in list at top of class
} Prevention
- Cache the language codes path after the first successful fetch so subsequent calls don't depend on datahub.io.
- Maintain the hardcoded language code list as the authoritative source and use the remote fetch as a refresh only.
- Monitor datahub.io availability and switch to a mirror if the primary endpoint goes down.
When it happens
Trigger: GetLanguageCodesPathAsync returns null/empty because: datahub.io is unreachable or returns a non-JSON error page, the 'resources' array or the 'ietf-language-tags_json' entry no longer exists in the datapackage.json, or the XPath query 'path' element is missing.
Common situations: Datahub.io API endpoint changed or was deprecated. Network/proxy blocks access to datahub.io. The datapackage.json schema was updated and the resource name 'ietf-language-tags_json' was renamed.
Related errors
- Empty response from server when getting language codes path
- File not found
- Empty response from server when getting language codes
- Can't get language codes. Path to language codes is null
- Empty response from server when getting language codes path
AI-assisted analysis of NickeManarin/ScreenToGif@a4d0a67c21 (2026-08-13).
Data as JSON: /api/errors/842f42d806753c0e.
Report an issue: GitHub.