Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c37768c
introduce an enum to control that shit
teamcons Feb 4, 2026
ffd3cf6
Go go Control Enter for translation
teamcons Feb 10, 2026
4e12d1d
App Icon (#33)
wpkelso Feb 16, 2026
ee53713
Cleanup refactor (#36)
teamcons Feb 16, 2026
3ee4bf4
create PNG counterparts for flathub
teamcons Feb 16, 2026
3edefa7
remove unused item
teamcons Feb 16, 2026
ec2aa4d
touchups
teamcons Feb 16, 2026
a71b11f
refresh translations
teamcons Feb 16, 2026
ea79472
update PO and ready up for release
teamcons Feb 16, 2026
b2a4613
set highlight on by default
teamcons Feb 16, 2026
e778f29
release date
teamcons Feb 16, 2026
a782463
URL
teamcons Feb 16, 2026
6a14097
Create FUNDING.yml
teamcons Feb 17, 2026
4192e97
Create bug_report.yml
teamcons Feb 17, 2026
7798bde
Add files via upload
teamcons Feb 17, 2026
ec98dd9
Create li
teamcons Feb 17, 2026
94f4e68
Add files via upload
teamcons Feb 17, 2026
bc5769f
Delete .github/workflows/li
teamcons Feb 17, 2026
239e9ea
Update bug_report.yml
teamcons Feb 17, 2026
0d89641
Update bug_report.yml
teamcons Feb 17, 2026
137dfe6
fix building png
teamcons Feb 17, 2026
61749a0
lets roll
teamcons Feb 17, 2026
c09ac35
updated commit hash
teamcons Feb 17, 2026
5bdc6a6
demangle URL
teamcons Feb 17, 2026
45a4a5f
Merge branch 'main' into switch-backend+libretranslate
teamcons Feb 18, 2026
8362d8c
Progress
teamcons Feb 18, 2026
dffc3ad
Progress
teamcons Feb 18, 2026
9d56c28
Progress
teamcons Feb 19, 2026
17f913b
Progress
teamcons Feb 19, 2026
9fe7ff6
Add dropdown
teamcons Feb 19, 2026
06293d9
progress
teamcons Feb 19, 2026
5bbbaf9
progress
teamcons Feb 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You can download and install Inscriptions from various sources:

## 🛣️ Roadmap

-Switch backends
-Switch BackendType

## 💝 Donations

Expand Down
89 changes: 89 additions & 0 deletions data/inscriptions.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<value value='3' nick="prefer-less"/>
<value value='4' nick="less"/>
</enum>
<enum id="io.github.elly_code.inscriptions.backend">
<value value='0' nick="deepl"/>
<value value='1' nick="libretranslate"/>
<value value='2' nick="dummy"/>
</enum>

<schema path="/io/github/elly_code/inscriptions/" id="io.github.elly_code.inscriptions">
<key name="window-height" type="i">
Expand Down Expand Up @@ -69,5 +74,89 @@
<summary>Whether to highlight both source and target</summary>
<description>Highlights alternating colours on both source and target in the TextView</description>
</key>
<key enum="io.github.elly_code.inscriptions.backend" name="backend">
<default>'deepl'</default>
<summary>Level of formality</summary>
<description>For supported languages, how format the output should be</description>
</key>
</schema>

<schema path="/io/github/elly_code/inscriptions/dummy/" id="io.github.elly_code.inscriptions.dummy">
<key name="source-language" type="s">
<default>"source"</default>
<summary>Language code to translate from</summary>
<description>Represents a language code. "idk" is to autodetect, and "system" for the system language.</description>
</key>
<key name="target-language" type="s">
<default>"echo"</default>
<summary>Language code to translate to</summary>
<description>Represents a language code. "system" for the system language.</description>
</key>
</schema>

<schema path="/io/github/elly_code/inscriptions/deepl/" id="io.github.elly_code.inscriptions.deepl">
<key name="source-language" type="s">
<default>"idk"</default>
<summary>Language code to translate from</summary>
<description>Represents a language code. "idk" is to autodetect, and "system" for the system language.</description>
</key>
<key name="target-language" type="s">
<default>"system"</default>
<summary>Language code to translate to</summary>
<description>Represents a language code. "system" for the system language.</description>
</key>
<key name="context" type="s">
<default>""</default>
<summary>context for translations</summary>
<description>Passed as context parameter to the DeepL API</description>
</key>
<key enum="io.github.elly_code.inscriptions.formality" name="formality">
<default>'default'</default>
<summary>Level of formality</summary>
<description>For supported languages, how format the output should be</description>
</key>
<key name="current-usage" type="i">
<default>0</default>
<summary>Current API usage</summary>
<description>How many characters have been translated</description>
</key>
<key name="max-usage" type="i">
<default>0</default>
<summary>Max API usage</summary>
<description>How many characters can be translated</description>
</key>
</schema>

<schema path="/io/github/elly_code/inscriptions/libretranslate/" id="io.github.elly_code.inscriptions.libretranslate">
<key name="source-language" type="s">
<default>"idk"</default>
<summary>Language code to translate from</summary>
<description>Represents a language code. "idk" is to autodetect, and "system" for the system language.</description>
</key>
<key name="target-language" type="s">
<default>"system"</default>
<summary>Language code to translate to</summary>
<description>Represents a language code. "system" for the system language.</description>
</key>
<key name="context" type="s">
<default>""</default>
<summary>context for translations</summary>
<description>Passed as context parameter to the DeepL API</description>
</key>
<key enum="io.github.elly_code.inscriptions.formality" name="formality">
<default>'default'</default>
<summary>Level of formality</summary>
<description>For supported languages, how format the output should be</description>
</key>
<key name="current-usage" type="i">
<default>0</default>
<summary>Current API usage</summary>
<description>How many characters have been translated</description>
</key>
<key name="max-usage" type="i">
<default>0</default>
<summary>Max API usage</summary>
<description>How many characters can be translated</description>
</key>
</schema>
</schemalist>
1 change: 1 addition & 0 deletions po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ src/Widgets/Panes/TargetPane.vala
src/Widgets/Buttons/RetryButton.vala
src/Widgets/LogToolbar.vala
src/Widgets/TextView.vala
src/Enums/PossibleBackendType.vala
src/Backend/DeepL/DeepL.vala
src/Constants.vala
src/Application.vala
4 changes: 2 additions & 2 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class Inscriptions.Application : Gtk.Application {

internal static Settings settings;
internal static DeepL backend;
internal static DeepL.Backend backend;
internal static MainWindow main_window;

public const string ACTION_PREFIX = "app.";
Expand Down Expand Up @@ -36,7 +36,7 @@ public class Inscriptions.Application : Gtk.Application {

// Backend takes care of the async for us. We give it the text
// And it will emit a signal whenever finished, which we can connect to
backend = new DeepL ();
backend = new DeepL.Backend ();
}

protected override void startup () {
Expand Down
38 changes: 16 additions & 22 deletions src/Backend/BackendTemplate.vala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The object has two signals:

If you want to write your own backend, everything would pretty much work if you
do a drop in replacement with send_request (text) and the two signals to retrieve
i may open up a bit more the possibilities to do other backends in the future
i may open up a bit more the possibilities to do other BackendType in the future


public void send_request (text);
Expand All @@ -44,38 +44,33 @@ public const SUPPORTED_TARGET
*/

// Translation service that use translate
public abstract class MrWorldWide.DeepL : Object {
public interface Inscriptions.BackendTemplate : Object {

private string source_lang;
private string target_lang;
private string api_key;
private string base_url;
public string system_language;
private string context;
public abstract string source_lang {get; set;}
public abstract string target_lang {get; set;}
public abstract uint status_code {get; set;}

/**
/**
* Connect to this signal to receive translated text
*/
public signal void answer_received (string translated_text = "");
public signal void answer_received (uint status_code, string translated_text = "");

/**
* Connect to this signal to know when language is detected
*/
public signal void language_detected (string? detected_language_code = null);

/**
* Connect to this signal to get usage
* Call this
*/
public signal void usage_retrieved (int current_usage, int max_usage);

public const string[] SUPPORTED_FORMALITY = {"DE", "FR", "IT", "ES", "NL", "PL", "PT-BR", "PT-PT", "JA", "RU"};
public int current_usage = 0;
public int max_usage = 0;
public abstract void check_usage ();

/**
* Anything to prepare should go here
/**
* Connect to this signal to get usage
*/
public abstract void init ();
public signal void usage_retrieved (uint status_code, int current_usage, int max_usage);
public abstract int current_usage {get; set; default = 0;}
public abstract int max_usage {get; set; default = 0;}

/**
* Call this method to send asynchronously a request.
Expand All @@ -86,7 +81,6 @@ public abstract class MrWorldWide.DeepL : Object {
/**
* Call this
*/
public abstract void check_usage ();


public abstract Lang[] supported_source_languages {get; internal set;}
public abstract Lang[] supported_target_languages {get; internal set;}
}
47 changes: 18 additions & 29 deletions src/Backend/DeepL/DeepL.vala
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,34 @@
* The backend, responsible for requests and answers.
* This needs to be standardized into a template, and broken up in several files.
*/
public class Inscriptions.DeepL : Object {
public class Inscriptions.DeepL.Backend : Object, BackendTemplate {

private const uint TIMEOUT = 3000;

Soup.Session session;
internal Soup.Logger logger;
Secrets secrets;

string source_lang;
string target_lang;
public uint status_code { get; set; }
public int current_usage { get; set; }
public int max_usage { get; set; }

public Lang[] supported_source_languages { get; set; }
public Lang[] supported_target_languages { get; set; }

string source_lang { get; set; }
string target_lang { get; set; }
string api_key;
string base_url;
public string system_language;
string context;

public signal void answer_received (uint status, string? translated_text = null);
public signal void language_detected (string? detected_language_code = null);
public signal void usage_retrieved (uint status);

const string URL_DEEPL_FREE = "https://api-free.deepl.com";
const string URL_DEEPL_PRO = "https://api.deepl.com";
const string REST_OF_THE_URL = "/v2/translate";
const string URL_USAGE = "/v2/usage";

public const string[] SUPPORTED_FORMALITY = {"DE", "FR", "IT", "ES", "NL", "PL", "PT-BR", "PT-PT", "JA", "RU"};

public int current_usage = 0;
public int max_usage = 0;

// Private debounce to not constantly check usage on key change
int interval = 1000; // ms
uint debounce_timer_id = 0;
Expand All @@ -52,9 +51,12 @@ public class Inscriptions.DeepL : Object {
stderr.printf ("%c %s\n", dir, text);
});

supported_source_languages = DeepL.Utils.supported_source_languages ();
supported_target_languages = DeepL.Utils.supported_target_languages ();

secrets = Secrets.get_default ();

system_language = DeepLUtils.detect_system ();
system_language = DeepL.Utils.detect_system ();

// Fallback
this.current_usage = Application.settings.get_int ("current-usage");
Expand Down Expand Up @@ -138,7 +140,7 @@ public class Inscriptions.DeepL : Object {
unwrapped_text = unwrap_json (answer);

} else {
unwrapped_text = unwrap_error_message (answer);
unwrapped_text = DeepL.Utils.unwrap_error_message (answer);
}

answer_received (msg.status_code, unwrapped_text);
Expand Down Expand Up @@ -229,20 +231,6 @@ public class Inscriptions.DeepL : Object {



public string unwrap_error_message (string text_json) {

var parser = new Json.Parser ();
try {
parser.load_from_data (text_json);
} catch (Error e) {
print ("\nCannot: " + e.message);
return text_json;
}

var root = parser.get_root ();
var objects = root.get_object ();
return objects.get_string_member_with_default ("message", _("Cannot retrieve error message text!"));
}



Expand Down Expand Up @@ -272,12 +260,12 @@ public class Inscriptions.DeepL : Object {
Application.settings.set_int ("max-usage", max_usage);

var msg = session.get_async_result_message (res);
usage_retrieved (msg.status_code);
usage_retrieved (msg.status_code, current_usage, max_usage);

string? error_message = null;

if (msg.status_code != Soup.Status.OK) {
error_message = unwrap_error_message (answer);
error_message = DeepL.Utils.unwrap_error_message (answer);
}

answer_received (msg.status_code, error_message);
Expand All @@ -288,4 +276,5 @@ public class Inscriptions.DeepL : Object {
}



}
Loading
Loading