diff --git a/src/API/Akkoma/Translation.vala b/src/API/Akkoma/Translation.vala new file mode 100644 index 000000000..ed84ceeb8 --- /dev/null +++ b/src/API/Akkoma/Translation.vala @@ -0,0 +1,8 @@ +public class Tuba.API.AkkomaTranslation : Entity { + public string text { get; set; default = ""; } + public string detected_language { get; set; default = ""; } + + public static AkkomaTranslation from (Json.Node node) throws Error { + return Entity.from_json (typeof (API.AkkomaTranslation), node) as API.AkkomaTranslation; + } +} diff --git a/src/API/Akkoma/meson.build b/src/API/Akkoma/meson.build index 97b0667ae..b72b57412 100644 --- a/src/API/Akkoma/meson.build +++ b/src/API/Akkoma/meson.build @@ -1,3 +1,3 @@ sources += files( - 'Source.vala', + 'Translation.vala', ) \ No newline at end of file diff --git a/src/API/Attachment.vala b/src/API/Attachment.vala index 2dec5fb70..f8fa3cccf 100644 --- a/src/API/Attachment.vala +++ b/src/API/Attachment.vala @@ -10,6 +10,7 @@ public class Tuba.API.Attachment : Entity, Widgetizable { set { this.t_preview_url = value; } get { return (this.t_preview_url == null || this.t_preview_url == "") ? url : t_preview_url; } } + public string? tuba_translated_alt_text { get; set; default = null; } public File? source_file { get; set; } diff --git a/src/API/Instance.vala b/src/API/Instance.vala index 21df3ba8a..9ccb8833d 100644 --- a/src/API/Instance.vala +++ b/src/API/Instance.vala @@ -16,6 +16,8 @@ public class Tuba.API.Instance : Entity { public API.Pleroma.Instance? pleroma { get; set; default = null; } public Gee.ArrayList? rules { get; set; } + public bool tuba_can_translate { get; set; default=false; } + public override Type deserialize_array_type (string prop) { switch (prop) { case "languages": diff --git a/src/API/InstanceV2.vala b/src/API/InstanceV2.vala new file mode 100644 index 000000000..ccdc2d718 --- /dev/null +++ b/src/API/InstanceV2.vala @@ -0,0 +1,14 @@ +public class Tuba.API.InstanceV2 : Entity { + public class Configuration : Entity { + public class Translation : Entity { + public bool enabled { get; set; default = false; } + } + public Translation translation { get; set; default = null; } + } + + public Configuration configuration { get; set; default = null; } + + public static InstanceV2 from (Json.Node node) throws Error { + return Entity.from_json (typeof (API.InstanceV2), node) as API.InstanceV2; + } +} diff --git a/src/API/PollOption.vala b/src/API/PollOption.vala index a07a8b639..5c6de0a30 100755 --- a/src/API/PollOption.vala +++ b/src/API/PollOption.vala @@ -1,4 +1,5 @@ public class Tuba.API.PollOption : Entity { public string? title { get; set; } public int64 votes_count { get; set; default=0; } + public string? tuba_translated_title { get; set; default = null; } } diff --git a/src/API/Status.vala b/src/API/Status.vala index 79239cbf6..d17e66f9e 100644 --- a/src/API/Status.vala +++ b/src/API/Status.vala @@ -91,6 +91,7 @@ public class Tuba.API.Status : Entity, Widgetizable { public Tuba.Views.Thread.ThreadRole tuba_thread_role { get; set; default = Tuba.Views.Thread.ThreadRole.NONE; } public bool tuba_spoiler_revealed { get; set; default = settings.show_spoilers; } + public bool tuba_translatable { get; set; default = false; } // public string clean_content { // get { @@ -108,6 +109,7 @@ public class Tuba.API.Status : Entity, Widgetizable { return _language; } set { + if (value != null) tuba_translatable = true; _language = value ?? settings.default_language; } } diff --git a/src/API/Translation.vala b/src/API/Translation.vala new file mode 100644 index 000000000..c1aaaa3c1 --- /dev/null +++ b/src/API/Translation.vala @@ -0,0 +1,43 @@ +public class Tuba.API.Translation : Entity { + public class Poll : Entity { + public class Option : Entity { + public string title { get; set; default = ""; } + } + public string id { get; set; default = ""; } + public Gee.ArrayList