Skip to content

Commit

Permalink
[UsageConfig]
Browse files Browse the repository at this point in the history
* add new config.subtitles.ai_connection_speed setting
* add more colors for config.subtitles.ai_subtitle_colors
* change the supported languages for ai translation
  • Loading branch information
jbleyel committed Sep 12, 2024
1 parent 27721d3 commit 5e95b63
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions data/setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@
<item level="2" text="AI-Powered translation language" description="Configure the AI-Powered translation language.">config.subtitles.ai_translate_to</item>
<item level="2" text="AI-Powered translation subscription code" description="Enter your subscription code, the unified code for trial is 15.">config.subtitles.ai_subscription_code</item>
<item level="2" text="AI-Powered translation color" description="Configure the color of the AI-Powered translations.">config.subtitles.ai_subtitle_colors</item>
<item level="2" text="AI-Powered Translation optimization" description="The AI-Powered Translation service will be optimized to provide the best performance based on the the Internet connection speed selected.">config.subtitles.ai_connection_speed</item>
</if>
<item level="2" text="Teletext subtitle color" description="Configure the color of the teletext subtitles.">config.subtitles.ttx_subtitle_colors</item>
<item level="2" text="Use original teletext position" description="When enabled, teletext subtitles will be displayed at their original position.">config.subtitles.ttx_subtitle_original_position</item>
Expand Down
1 change: 1 addition & 0 deletions lib/base/esettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ bool eSubtitleSettings::ai_enabled = false;
std::string eSubtitleSettings::ai_translate_to = "0";
std::string eSubtitleSettings::ai_subscription_code = "15";
int eSubtitleSettings::ai_subtitle_colors = 1;
int eSubtitleSettings::ai_connection_speed = 1;
3 changes: 2 additions & 1 deletion lib/base/esettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ class eSubtitleSettings
static void setAiTranslateTo(std::string value) { ai_translate_to = value; }
static void setAiSubscriptionCode(std::string value) { ai_subscription_code = value; }
static void setAiSubtitleColors(int value) { ai_subtitle_colors = value; }
static void setAiConnectionSpeed(int value) { ai_connection_speed = value; }
static bool ai_enabled;
static std::string ai_translate_to;
static std::string ai_subscription_code;
static int ai_subtitle_colors;

static int ai_connection_speed;//1=Up to 50 Mbps, 2=50-200 Mbps, 3=Above 200 Mbps

};

Expand Down
20 changes: 18 additions & 2 deletions lib/python/Components/UsageConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -1777,18 +1777,34 @@ def setAiSubtitleColors(configElement):

config.subtitles.ai_subtitle_colors = ConfigSelection(default=1, choices=[
(1, _("White")),
(2, _("Yellow"))
(2, _("Yellow")),
(3, _("Red")),
(4, _("Green")),
(5, _("Blue"))
])
config.subtitles.ai_subtitle_colors.addNotifier(setAiSubtitleColors)

def setAiConnectionSpeed(configElement):
eSubtitleSettings.setAiConnectionSpeed(configElement.value)

config.subtitles.ai_connection_speed = ConfigSelection(default=1, choices=[
(1, _("Up to 50 Mbps")),
(2, _("50-200 Mbps")),
(3, _("Above 200 Mbps"))
])
config.subtitles.ai_connection_speed.addNotifier(setAiConnectionSpeed)

langsAI = ['af', 'sq', 'am', 'ar', 'hy', 'az', 'eu', 'be', 'bn', 'bs', 'bg', 'ca', 'zh', 'co', 'hr', 'cs', 'da', 'nl', 'en', 'eo', 'fr', 'fi', 'fy', 'gl', 'ka', 'de', 'el', 'ht', 'ha', 'hu', 'is', 'ig', 'ga', 'it', 'ja', 'jv', 'kn', 'kk', 'km', 'rw', 'ko', 'ku', 'ky', 'lo', 'la', 'lv', 'lt', 'lb', 'mk', 'mg', 'ms', 'mt', 'mi', 'mr', 'mn', 'no', 'ny', 'or', 'ps', 'fa', 'pl', 'pt', 'ro', 'ru', 'sm', 'gd', 'sr', 'st', 'sn', 'sk', 'sl', 'so', 'es', 'su', 'sw', 'sv', 'tl', 'tg', 'te', 'th', 'tr', 'tk', 'uk', 'ur', 'ug', 'uz', 'cy', 'xh', 'yi', 'yo', 'zu']
langsAI = [(x, international.LANGUAGE_DATA[x][1]) for x in langsAI]
langsAI.append(("zh-CN", _("Chinese (Simplified)")))
langsAI.append(("ceb", _("Cebuano")))
langsAI.append(("haw", _("Hawaiian")))
langsAI.append(("iw", _("Hebrew")))
langsAI.append(("hmn", _("Hmong")))
langsAI.append(("ckb", _("Kurdish (Sorani)")))
langsAI.append(("ar_eg", _("Arabic (Egyptian)")))
langsAI.append(("ar_ma", _("Arabic (Moroccan)")))
langsAI.append(("ar_sy", _("Arabic (Syro-Lebanese)")))
langsAI.append(("ar_tn", _("Arabic (Tunisian)")))
langsAI.sort(key=lambda x: x[1])

default = config.misc.locale.value
Expand Down

0 comments on commit 5e95b63

Please sign in to comment.