{"record":{"id":"95e64941e8f0e37d","repo":"cube-js/cube","slug":"failed-to-detect-locale","errorCode":null,"errorMessage":"Failed to detect locale","messagePattern":"Failed to detect locale","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cubejs-client-core/src/format.ts","lineNumber":79,"sourceCode":"  abbr_4: '.4~s',\n  abbr_5: '.5~s',\n  abbr_6: '.6~s',\n\n  accounting: '(,.2~f',\n  accounting_0: '(,.0f',\n  accounting_1: '(,.1~f',\n  accounting_2: '(,.2~f',\n  accounting_3: '(,.3~f',\n  accounting_4: '(,.4~f',\n  accounting_5: '(,.5~f',\n  accounting_6: '(,.6~f',\n};\n\nfunction detectLocale() {\n  try {\n    return new Intl.NumberFormat().resolvedOptions().locale;\n  } catch (e) {\n    console.warn('Failed to detect locale', e);\n\n    return 'en-US';\n  }\n}\n\nconst currentLocale = detectLocale();\n\nconst DEFAULT_DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S';\nconst DEFAULT_DATE_FORMAT = '%Y-%m-%d';\nconst DEFAULT_DATE_WEEK_FORMAT = '%Y-%m-%d W%V';\nconst DEFAULT_DATE_MONTH_FORMAT = '%Y %b';\nconst DEFAULT_DATE_QUARTER_FORMAT = '%Y-Q%q';\nconst DEFAULT_DATE_YEAR_FORMAT = '%Y';\n\nfunction getFormatByGrain(grain?: string): string {\n  // Grains that should show date and time (sub-day granularities)\n  const dateTimeGrains = ['second', 'minute', 'hour'];\n","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-client-core/src/format.ts#L61-L97","documentation":"Cube client detects the runtime's default locale using Intl.NumberFormat().resolvedOptions().locale. If constructing Intl.NumberFormat throws (rare; environments without ICU), detectLocale warns and defaults to 'en-US'.","triggerScenarios":"Module load time: currentLocale = detectLocale() runs when the format module is imported and Intl.NumberFormat() throws in the current runtime.","commonSituations":"Node built without ICU; embedded/minimal JS runtimes; stripped-down browser environments lacking Intl.","solutions":["Run on a runtime with ICU support (standard Node builds include it; use node with full-icu otherwise)","Accept the fallback — formatting proceeds with en-US","Polyfill Intl if targeting minimal environments"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"const hasIntl = typeof Intl !== 'undefined' && typeof Intl.NumberFormat === 'function';","typeGuard":"function hasIntlNumberFormat(): boolean {\n  return typeof Intl !== 'undefined' && typeof Intl.NumberFormat === 'function';\n}","tryCatchPattern":"try {\n  locale = new Intl.NumberFormat().resolvedOptions().locale;\n} catch {\n  locale = 'en-US';\n}","preventionTips":["Deploy on runtimes with ICU support","Polyfill Intl for minimal environments","Treat en-US fallback as expected behavior in locale-less runtimes"],"tags":["i18n","intl","locale","fallback"],"backgroundTag":"intl-unavailable-fallback","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}