Add some forgotten code
This commit is contained in:
@ -66,6 +66,11 @@ defmodule Outlook.Translators do
|
|||||||
Task.start_link(Deepl, :translate, args)
|
Task.start_link(Deepl, :translate, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def process_translation_result(result, tunit_ids, current_user) do
|
||||||
|
increase_our_character_count(current_user, result.billed_characters)
|
||||||
|
process_translation(result.translation, tunit_ids)
|
||||||
|
end
|
||||||
|
|
||||||
defp deepl_account_for_user(user) when is_struct(user), do: deepl_account_for_user(user.id)
|
defp deepl_account_for_user(user) when is_struct(user), do: deepl_account_for_user(user.id)
|
||||||
defp deepl_account_for_user(user_id) do
|
defp deepl_account_for_user(user_id) do
|
||||||
DeeplAccount |> where(user_id: ^user_id)
|
DeeplAccount |> where(user_id: ^user_id)
|
||||||
@ -78,11 +83,6 @@ defmodule Outlook.Translators do
|
|||||||
|> IO.iodata_to_binary()
|
|> IO.iodata_to_binary()
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_translation_result(result, tunit_ids) do
|
|
||||||
# TODO: update :our_character_count
|
|
||||||
process_translation(result.translation, tunit_ids)
|
|
||||||
end
|
|
||||||
|
|
||||||
def process_translation(translation, tunit_ids) do
|
def process_translation(translation, tunit_ids) do
|
||||||
tunit_map = translation
|
tunit_map = translation
|
||||||
|> Floki.parse_fragment!
|
|> Floki.parse_fragment!
|
||||||
|
|||||||
@ -147,7 +147,8 @@ defmodule OutlookWeb.TranslationLive.FormComponent do
|
|||||||
InternalTree.add_phx_click_event(translation.article.content,
|
InternalTree.add_phx_click_event(translation.article.content,
|
||||||
nodes: :tunits,
|
nodes: :tunits,
|
||||||
click: "select_current_tunit",
|
click: "select_current_tunit",
|
||||||
target: socket.assigns.myself))
|
target: socket.assigns.myself)
|
||||||
|
|> InternalTree.garnish(%{tunits: %{class: "tunit"}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
defp update_translation_with_current_tunit(socket, nil), do: socket
|
defp update_translation_with_current_tunit(socket, nil), do: socket
|
||||||
|
|||||||
Reference in New Issue
Block a user