|
1 | 1 | import { makeIssue } from '../core/errors' |
2 | 2 | import type { IssueCode, IssueInputData, LingoIssue, Messages, Severity, Span } from '../core/types' |
3 | | -import { isLocaleLoaded, resolveLanguageProfile } from '../locale/profile' |
| 3 | +import { resolveLanguageProfile } from '../locale/profile' |
4 | 4 | import type { LocalePack } from '../locale/types' |
5 | 5 | import { normalizeInput, toSourceSpan } from '../parse/normalize' |
6 | 6 | import type { SerializedResult } from '../parse/serialize' |
@@ -155,30 +155,18 @@ export function parseDate(text: string, opts?: DateOptions): DateResult | DateFa |
155 | 155 | function parseDateImpl(text: string, opts?: DateOptions): DateResult | DateFail<DateResult> { |
156 | 156 | const now = opts?.now === undefined ? anchorNow() : new Date(opts.now.getTime()) |
157 | 157 | const n = normalizeInput(text) |
158 | | - const localeNotLoaded = |
159 | | - opts?.locale !== undefined && !isLocaleLoaded(opts.localePacks, opts.locale) |
160 | | - ? makeIssue( |
161 | | - 'LOCALE_NOT_LOADED', |
162 | | - { locale: opts.locale }, |
163 | | - toSourceSpan(n, 0, n.text.length), |
164 | | - opts.messages, |
165 | | - ) |
166 | | - : undefined |
167 | 158 | const p: P = { |
168 | 159 | src: text, |
169 | 160 | n, |
170 | 161 | text: n.text, |
171 | 162 | tokens: tokenize(n), |
172 | 163 | now, |
173 | 164 | opts: opts ?? {}, |
174 | | - profile: resolveLanguageProfile(opts?.localePacks, localeNotLoaded ? 'en' : opts?.locale), |
| 165 | + profile: resolveLanguageProfile(opts?.localePacks, opts?.locale), |
175 | 166 | weekStart: normalizeWeekStart(opts?.weekStart), |
176 | 167 | forwardDates: opts?.forwardDates ?? true, |
177 | 168 | escalate: dateEscalate(opts), |
178 | 169 | } |
179 | | - if (localeNotLoaded) { |
180 | | - return { ok: false, text: p.src, issues: [localeNotLoaded] } |
181 | | - } |
182 | 170 | const { start, end } = trimRange(n.text, 0, n.text.length) |
183 | 171 | if (start === end) { |
184 | 172 | return fail(p, 'NO_VALUE', { example: '"tomorrow"' }, start, end) |
@@ -394,30 +382,18 @@ export function parseDateRange(text: string, opts?: DateOptions): DateRange | Da |
394 | 382 | function parseDateRangeImpl(text: string, opts?: DateOptions): DateRange | DateRangeFail { |
395 | 383 | const now = opts?.now === undefined ? anchorNow() : new Date(opts.now.getTime()) |
396 | 384 | const n = normalizeInput(text) |
397 | | - const localeNotLoaded = |
398 | | - opts?.locale !== undefined && !isLocaleLoaded(opts.localePacks, opts.locale) |
399 | | - ? makeIssue( |
400 | | - 'LOCALE_NOT_LOADED', |
401 | | - { locale: opts.locale }, |
402 | | - toSourceSpan(n, 0, n.text.length), |
403 | | - opts.messages, |
404 | | - ) |
405 | | - : undefined |
406 | 385 | const p: P = { |
407 | 386 | src: text, |
408 | 387 | n, |
409 | 388 | text: n.text, |
410 | 389 | tokens: tokenize(n), |
411 | 390 | now, |
412 | 391 | opts: opts ?? {}, |
413 | | - profile: resolveLanguageProfile(opts?.localePacks, localeNotLoaded ? 'en' : opts?.locale), |
| 392 | + profile: resolveLanguageProfile(opts?.localePacks, opts?.locale), |
414 | 393 | weekStart: normalizeWeekStart(opts?.weekStart), |
415 | 394 | forwardDates: opts?.forwardDates ?? true, |
416 | 395 | escalate: dateEscalate(opts), |
417 | 396 | } |
418 | | - if (localeNotLoaded) { |
419 | | - return { ok: false, type: 'date-range-failure', text, issues: [localeNotLoaded] } |
420 | | - } |
421 | 397 | let source = n.text.trim() |
422 | 398 | const issues: LingoIssue[] = [] |
423 | 399 | // Point the span at the trimmed content, not the padded input. |
|
0 commit comments