Files
archived-orca/mobile/src/tasks/sparse-preset-draft.ts
OrcaWinandOrcaWin a99bc36593 feat(mobile): localize tasks, new workspaces and source control (#35646)
* feat(mobile): localize tasks, new workspaces and source control

Moves the last ~670 strings (task lists and boards, issue and PR sources, the
new-workspace flow, and source control) to the translation API, with all ten
translations. What remains in the coverage baseline is reviewed non-copy: key
names, schema errors and log lines.

- Source control section titles recompute on a language change

* fix(mobile): align catalog terminology across screens

A whole-catalog pass per language reconciled terms that differed between batches
(host/desktop, dictation, transcripts, address form) with the glossaries and the
desktop catalogs. The page bundle verifier now reports catalog bytes separately.

* fix(mobile): keep fetched history and source error slugs language-independent

History rows are derived from the fetched page at render so relative times follow a
language switch; quality-gate follow-ups for the tasks and source control migration.

* fix(mobile): name Android notification channels in the UI language

* chore(mobile): drop catalog entries for removed source-control copy

* fix(mobile): re-localize the composer source hook on current main

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-10-28 21:11:04 -07:00

76 lines
2.0 KiB
TypeScript

import { translate } from '../i18n/mobile-i18n'
const WINDOWS_DRIVE_PATH_PATTERN = /^[A-Za-z]:/
export type SparsePresetDirectoryParseResult = {
directories: string[]
error: string | null
}
function isAbsoluteSparseDirectoryPath(value: string): boolean {
const entry = value.trim()
return entry.startsWith('/') || entry.startsWith('\\') || WINDOWS_DRIVE_PATH_PATTERN.test(entry)
}
function normalizeSparseDirectoryLines(value: string): string[] {
const seen = new Set<string>()
return value
.split('\n')
.map((entry) =>
entry
.trim()
.replace(/\\/g, '/')
.replace(/^\/+|\/+$/g, '')
)
.filter((entry) => entry.length > 0)
.filter((entry) => {
if (seen.has(entry)) {
return false
}
seen.add(entry)
return true
})
}
export function parseSparsePresetDirectories(value: string): SparsePresetDirectoryParseResult {
const rawEntries = value
.split('\n')
.map((entry) => entry.trim())
.filter((entry) => entry.length > 0)
// Check absolute paths before normalization can make them look repo-relative.
if (rawEntries.some(isAbsoluteSparseDirectoryPath)) {
return {
directories: [],
error: translate(
'tasks.sparsePresetDraft.repoRelativeDirectoriesRequired',
'Use repo-relative directories, not root, absolute paths, or parent segments.'
)
}
}
const directories = normalizeSparseDirectoryLines(value)
if (directories.length === 0) {
return {
directories,
error: translate('tasks.sparsePresetDraft.directoryRequired', 'Add at least one directory.')
}
}
if (directories.some((entry) => entry === '.' || entry.split('/').includes('..'))) {
return {
directories: [],
error: translate(
'tasks.sparsePresetDraft.repoRelativeDirectoriesRequired',
'Use repo-relative directories, not root, absolute paths, or parent segments.'
)
}
}
return {
directories,
error: null
}
}