Skip to content

Commit 73d79c3

Browse files
committed
Allow languages in problem name
1 parent 43ecaaa commit 73d79c3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

webapp/src/Service/ImportExportService.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ public function importContestData(mixed $data, ?string &$errorMessage = null, ?s
395395
/**
396396
* @param array{name?: string, short-name?: string, id?: string, label?: string,
397397
* letter?: string, time_limit?: int, rgb?: string, color?: string,
398-
* problems?: array{name?: string, short-name?: string, id?: string, label?: string,
398+
* problems?: array{name?: string|array<string, string>, short-name?: string, id?: string, label?: string,
399399
* letter?: string, label?: string, letter?: string}} $problems
400400
* @param string[]|null $ids
401401
* @param array<string, string[]> $messages
@@ -413,6 +413,16 @@ public function importProblemsData(Contest $contest, array $problems, ?array &$i
413413
$problemName = $problemData['name'] ?? $problemData['short-name'] ?? $problemData['id'] ?? null;
414414
$problemLabel = $problemData['label'] ?? $problemData['letter'] ?? null;
415415

416+
// The 2025-09 problem spec allows a 'language code'->'name' map.
417+
if (is_array($problemName)) {
418+
if (array_key_exists('en', $problemName)) {
419+
$problemName = $problemName['en'];
420+
} else {
421+
$errorMessage = sprintf("Problem '%s' should have an English name", $problemName['id']);
422+
return false;
423+
}
424+
}
425+
416426
$problem = new Problem();
417427
$problem
418428
->setName($problemName)

0 commit comments

Comments
 (0)