Language class
Defines common characteristics required for tuning locale and text segmentation behaviour for different languages. Override the variables and functions of this abstract class in order to implement a target language.
- Implementers
Constructors
-
Language({required String languageName, required String languageCode, required String threeLetterCode, required String countryCode, required TextDirection textDirection, required bool preferVerticalReading, required bool isSpaceDelimited, required TextBaseline textBaseline, required String helloWorld, required DictionaryFormat standardFormat, required String defaultFontFamily, Future<
int?> prepareSearchResults(DictionarySearchParams params) = prepareSearchResultsStandard}) - Initialise the language with the required details.
Properties
- countryCode → String
-
The ISO 3166-1 code or the international standard name of country.
final
- defaultFontFamily → String
-
Default font for a language.
final
- hashCode → int
-
The hash code for this object.
read-onlyinherited
- helloWorld → String
-
Testing text for the language's basic use. This is useful for testing
and pre-loading the database for use.
final
- indexMaxDistance ↔ int?
-
Some implementations of tap-to-select are very unoptimised for a high
length of text. It is impractical to run text segmentation in some cases.
This value sets a length from the center from which input text for
wordFromIndex should be cut if longer. If null, the limit will not be
used.
read / write
- isSpaceDelimited → bool
-
Whether or not this language essentially relies on spaces to commonly
separate and discern words.
final
- languageCode → String
-
The ISO 639-1 code or the international standard language code.
final
- languageCountryCode → String
-
The language and country code separated by a dash.
read-only
- languageName → String
-
The name of the language, as known to native speakers.
final
- locale → Locale
-
Extract a Locale from the language code and country code.
read-only
- preferVerticalReading → bool
-
Whether or not this language should prefer vertical reading.
final
-
prepareSearchResults
→ Future<
int?> Function(DictionarySearchParams params) -
Overrides the base search function and implements search specific to
a language.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
- standardFormat → DictionaryFormat
-
A standard format that dictionaries of this language can be found in.
This is only to set this as the default last selected format on first
time setup.
final
- textBaseline → TextBaseline
-
If this language uses an alphabetic or ideographic text baseline.
final
- textDirection → TextDirection
-
The reading direction of the language, for which reading should be
given a specific format by default. For example, Arabic is RTL, while
English is LTR.
final
- threeLetterCode → String
-
The ISO 639-3 code or the international standard language code.
final
Methods
-
getFinalHighlightLength(
{required DictionarySearchResult? result, required String searchTerm}) → int - Get final highlight length after a dictionary search.
-
getGuessHighlightLength(
{required String searchTerm}) → int - Get preliminary highlight length before a dictionary search.
-
getPitchWidget(
{required AppModel appModel, required BuildContext context, required String reading, required int downstep}) → Widget - Some languages may have custom widgets for generating pronunciation diagrams.
-
getSearchTermFromIndex(
{required String text, required int index}) → String - Gets a search term and for a space-delimited language, assumes the index is within the range of the first word, with remainder words included. For a language that is not space-delimited, this is simply the substring function.
-
getSentenceFromParagraph(
{required String paragraph, required int index, required int startOffset, required int endOffset}) → JidoujishoTextSelection - Given paragraph text and an index, yield the part of the text such that the result is a sentence. Different languages may decide to use different delimiters.
-
getSentences(
String text) → List< String> - Returns a list of sentences for a block of text.
-
getStartingIndex(
{required String text, required int index}) → int - Returns the starting index from which the search term should be chopped from, given a clicked index and full text. For a space-delimited language, this will return the starting index of a clicked word. Otherwise, this returns the clicked index itself.
-
getTermReadingOverrideWidget(
{required BuildContext context, required AppModel appModel, required DictionaryHeading heading, required dynamic onSearch(String)}) → Widget - Some languages may want to display custom widgets rather than the built in word and reading text that is there by default. For example, Japanese may want to display a furigana widget instead.
-
initialise(
) → Future< void> - This function is run at startup or when changing languages. It is not called again if already run.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
prepareResources(
) → Future< void> - Prepare text segmentation tools and other dependencies necessary for this langauge to function.
-
textToWords(
String text) → List< String> -
Given unsegmented
text
, perform text segmentation particular to the language and return a list of parsed words. -
toString(
) → String -
A string representation of this object.
inherited
-
wordFromIndex(
{required String text, required int index}) → String -
Given an
index
or a character position in giventext
, return a word such that it corresponds to a whole word from the parsed list of words from textToWords.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited