fix(study): a Japanese word's romaji reading is not typed as pinyin
Any reading in Latin letters counted as pinyin, whatever the studyset's language, so a Japanese word read in romaji (東京 as Tōkyō or toukyou, common in imported decks), which was never typed for having no kana, was typed with pinyin's tone numbers and hint, and tokyo was marked wrong. A reading is now pinyin only when the studied studyset's fronts are in Chinese (zh, in any script or region), its own language or inherited: the session reads it as each round starts, the card the same languages its screen is set in. A Japanese studyset studies as it did before pinyin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
6ea7375376
commit
fd783df649
1 changed files with 80 additions and 24 deletions
|
|
@ -72,12 +72,14 @@ void main() {
|
|||
});
|
||||
|
||||
/// Studies the studyset `japanese`, with the cards the test gave [cards]:
|
||||
/// the app reads them from the same [gateway].
|
||||
/// the app reads them from the same [gateway]. Its fronts are in
|
||||
/// [frontLanguage], none unless given.
|
||||
Future<void> study(
|
||||
WidgetTester tester, {
|
||||
GeoMapRepository? maps,
|
||||
FakeReviewGateway? reviews,
|
||||
StrokeRepository? strokes,
|
||||
String? frontLanguage,
|
||||
double width = 1200,
|
||||
}) async {
|
||||
tester.view.physicalSize = Size(width, 1600);
|
||||
|
|
@ -89,7 +91,13 @@ void main() {
|
|||
studysetGateway: FakeStudysetGateway()
|
||||
..receiveRemoteChange(
|
||||
'japanese',
|
||||
encodeStudysetPayload(StudysetContent.titled('Japanese')),
|
||||
encodeStudysetPayload(
|
||||
StudysetContent(
|
||||
title: 'Japanese',
|
||||
description: RichContent.empty(),
|
||||
frontLanguage: frontLanguage,
|
||||
),
|
||||
),
|
||||
),
|
||||
cardGateway: gateway,
|
||||
tagGateway: tagGateway,
|
||||
|
|
@ -893,7 +901,7 @@ void main() {
|
|||
await settings.update(
|
||||
(each) => each.withStudy(const StudyOptions(typeReadings: true)),
|
||||
);
|
||||
await study(tester);
|
||||
await study(tester, frontLanguage: 'zh-Hans');
|
||||
|
||||
expect(find.text('The pinyin, with tone numbers or marks'), findsOneWidget);
|
||||
await tester.enterText(find.byType(TextField), 'xue2xi2');
|
||||
|
|
@ -905,6 +913,29 @@ void main() {
|
|||
expect(find.text('Right'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('typing readings, a Japanese word read in romaji flips as '
|
||||
"before: they aren't pinyin", (tester) async {
|
||||
await cards.create(
|
||||
'japanese',
|
||||
CardContent(
|
||||
type: CardType.vocabulary,
|
||||
front: paragraph('東京'),
|
||||
back: RichContent.empty(),
|
||||
reading: 'Tōkyō',
|
||||
meanings: const ['Tokyo'],
|
||||
),
|
||||
);
|
||||
final settings = SettingsRepository(settingsGateway);
|
||||
addTearDown(settings.dispose);
|
||||
await settings.update(
|
||||
(each) => each.withStudy(const StudyOptions(typeReadings: true)),
|
||||
);
|
||||
await study(tester, frontLanguage: 'ja');
|
||||
|
||||
expect(find.byType(TextField), findsNothing);
|
||||
expect(find.text('Show answer'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('a reading typed right says so', (tester) async {
|
||||
await cards.create(
|
||||
'japanese',
|
||||
|
|
|
|||
Loading…
Reference in a new issue