Skip to content

Commit

Permalink
Merge pull request #748 from Speech-Rule-Engine/feature/depth_transla…
Browse files Browse the repository at this point in the history
…tion

Adds depth and actionable computations to speech generator.
  • Loading branch information
zorkow committed Feb 9, 2024
2 parents 8f0458c + df05256 commit 0aed955
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ts/speech_generator/abstract_speech_generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { SpeechGenerator } from './speech_generator.js';
import * as SpeechGeneratorUtil from './speech_generator_util.js';
import * as EngineConst from '../common/engine_const.js';
import { SemanticNode } from '../semantic_tree/semantic_node.js';
import { LOCALE } from '../l10n/locale.js';

import { ClearspeakPreferences } from '../speech_rules/clearspeak_preferences.js';

Expand Down Expand Up @@ -181,4 +182,21 @@ export abstract class AbstractSpeechGenerator implements SpeechGenerator {
return style;
}

/**
* @override
*/
public getLevel(depth: string) {
return LOCALE.MESSAGES.navigate.LEVEL + ' ' + depth;
}

/**
* @override
*/
public getActionable(actionable: number) {
return actionable ? (
actionable < 0 ? LOCALE.MESSAGES.navigate.EXPANDABLE :
LOCALE.MESSAGES.navigate.COLLAPSIBLE
) : '';
}

}
17 changes: 17 additions & 0 deletions ts/speech_generator/speech_generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,21 @@ export interface SpeechGenerator {
*/
nextStyle(id: string): void;

/**
* Returns the localised message if an element is actionable.
* <1: exandable
* >1: collapsible
* 0 : empty
*
* @param {number} actionable The actionable value.
*/
getActionable(actionable: number): string;

/**
* The localised depth message.
*
* @param {string} depth The nesting level of a node.
*/
getLevel(depth: string): string;

}
1 change: 1 addition & 0 deletions ts/speech_generator/summary_speech_generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ export class SummarySpeechGenerator extends AbstractSpeechGenerator {
const speech = node.getAttribute(Attribute.SUMMARY);
return speech;
}

}

0 comments on commit 0aed955

Please sign in to comment.