Skip to content

Commit 8181a33

Browse files
committed
complete in-app documentation
1 parent 3b128ce commit 8181a33

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

phrase/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ ext {
7777
siteUrl = 'https://kingsmentor.github.io/Phrase'
7878
gitUrl = 'https://github.com/KingsMentor/Phrase'
7979

80-
libraryVersion = '1.1.0'
80+
libraryVersion = '1.1.1'
8181

8282
developerId = 'kingsmentor'
8383
developerName = 'Nosakhare Belvi'

phrase/src/main/java/xyz/belvi/phrase/options/PhraseOptions.kt

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,97 @@ import androidx.annotation.ColorInt
66
import java.util.Locale
77
import xyz.belvi.phrase.translateMedium.TranslationMedium
88

9+
/**
10+
* declare preference and translation options. See this as the config object for Phrase.
11+
*/
912
data class PhraseOptions internal constructor(
13+
/**
14+
* setting behaivourOptions for Phrase
15+
* @see BehaviourOptions
16+
*/
1017
var behavioursOptions: BehaviourOptions = BehaviourOptions(),
18+
/**
19+
* define translation preference. You can use this to assign certain TranslationMedium for translating text from a specific source to a specific target languae
20+
*/
1121
var sourcePreferredTranslation: SourceTranslationPreference = SourceTranslationPreference(),
22+
/**
23+
* define mediums to use for language detection based on preference. Phrase uses mediums mentioned in the list as a fallback.
24+
* If this list is empty, Phrase uses list provided in translationMedium for running language detection instead
25+
*/
1226
var preferredDetection: List<TranslationMedium> = emptyList(),
27+
/**
28+
* languageSource included in this list will be excluded from translation
29+
*/
1330
var excludeSources: List<String> = emptyList(),
31+
/**
32+
* languageSource include in this list will only be translated when BEHAVIOR_TRANSLATE_PREFERRED_OPTION_ONLY flag is set
33+
*/
1434
var preferredSources: List<String> = emptyList(),
35+
/**
36+
* target language code of the user. This is the language all text appearing in other language will be translated to
37+
*/
1538
var targetLanguageCode: String = Locale.getDefault().language,
39+
/**
40+
* the text to be displayed to the user that prompt for text translation
41+
* Phrase appends this text depending on whether BEHAVIOR_HIDE_TRANSLATE_PROMPT is set or not.
42+
* @see PhraseDetected
43+
*/
1644
var translateText: ((detected: PhraseDetected?) -> String),
45+
/**
46+
* the text to be displayed to the user that confirms that the original text has been translated.
47+
* Phrase appends this text depending on whether BEHAVIOR_HIDE_TRANSLATE_PROMPT is set or not.
48+
* Phrase appends translationMedium.name() to this text depending on whether BEHAVIOR_HIDE_CREDIT is set or not.
49+
* @see PhraseTranslation
50+
*/
1751
var translateFrom: ((translation: PhraseTranslation) -> String)
1852
)
1953

54+
/**
55+
* define behaivourOptions for phrase
56+
*/
2057
data class BehaviourOptions internal constructor(
58+
/**
59+
* @see Behaviour
60+
*/
2161
val behaviours: Behaviour = Behaviour(),
62+
/**
63+
* set typeface for translationMedium name shown to user after translation. This is to give credit to the medium used for translation.
64+
* use BEHAVIOR_HIDE_CREDIT to hide this credit.
65+
* use BEHAVIOR_HIDE_TRANSLATE_PROMPT to hide prompt entire
66+
*/
2267
val signatureTypeFace: Typeface? = null,
68+
/**
69+
* set color for translationMedium name shown to user after translation. This is to give credit to the medium used for translation.
70+
* use BEHAVIOR_HIDE_CREDIT to hide this credit.
71+
* use BEHAVIOR_HIDE_TRANSLATE_PROMPT to hide prompt entire
72+
*/
2373
@ColorInt val signatureColor: Int = Color.BLACK
2474
)
2575

76+
/**
77+
* define specific rule for SourceTranslationPreference
78+
*/
2679
data class SourceTranslationRule(
80+
/**
81+
* define source language that this rule should apply to
82+
*/
2783
val sourceLanguageCode: String,
84+
/**
85+
* define target language that this rule should apply to in regards to sourceLanguageCode
86+
* This should just include * to refer to all target language
87+
*/
2888
val targetLanguageCode: List<String> = emptyList(),
89+
/**
90+
* define TranslationMedium to be used when this rule is meant. Phrase uses default translateMedium is this is not provided or left empty.
91+
* Defines TranslationMedium in order of fallback preference.
92+
*/
2993
val translate: List<TranslationMedium> = emptyList()
3094
)
3195

3296
data class SourceTranslationPreference internal constructor(
97+
/**
98+
* set of rules to be applied before processing translation.
99+
* Rules are processed from top to bottom. This means if more than one rule applies to same source, the first defined rule will be used if it meets the checking criteria
100+
*/
33101
internal val sourceTranslateRule: List<SourceTranslationRule> = emptyList()
34102
)

0 commit comments

Comments
 (0)