Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ronove
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kaj Koivunen
Ronove
Commits
7a2fe946
Commit
7a2fe946
authored
2 years ago
by
Kaj Koivunen
Browse files
Options
Downloads
Patches
Plain Diff
rebrändäystä
parent
c272e754
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
build.gradle.kts
+1
-1
1 addition, 1 deletion
build.gradle.kts
src/main/kotlin/Main.kt
+2
-2
2 additions, 2 deletions
src/main/kotlin/Main.kt
src/main/kotlin/TranslationBackend.kt
+15
-6
15 additions, 6 deletions
src/main/kotlin/TranslationBackend.kt
with
18 additions
and
9 deletions
build.gradle.kts
+
1
−
1
View file @
7a2fe946
...
@@ -37,7 +37,7 @@ tasks.withType<KotlinCompile> {
...
@@ -37,7 +37,7 @@ tasks.withType<KotlinCompile> {
}
}
application
{
application
{
mainClass
.
set
(
"guru.kake.
yaku
.MainKt"
)
mainClass
.
set
(
"guru.kake.
ronove
.MainKt"
)
}
}
tasks
{
tasks
{
...
...
This diff is collapsed.
Click to expand it.
src/main/kotlin/Main.kt
+
2
−
2
View file @
7a2fe946
package
guru.kake.
yaku
package
guru.kake.
ronove
import
tornadofx.*
import
tornadofx.*
class
MyApp
:
App
(
MainView
::
class
)
class
MyApp
:
App
(
MainView
::
class
,
RonoveStylesheet
::
class
)
fun
main
(
args
:
Array
<
String
>)
{
fun
main
(
args
:
Array
<
String
>)
{
launch
<
MyApp
>(
args
)
launch
<
MyApp
>(
args
)
...
...
This diff is collapsed.
Click to expand it.
src/main/kotlin/TranslationBackend.kt
+
15
−
6
View file @
7a2fe946
package
guru.kake.
yaku
package
guru.kake.
ronove
import
com.deepl.api.DeepLException
import
com.deepl.api.DeepLException
import
com.deepl.api.Translator
import
com.deepl.api.Translator
...
@@ -7,6 +7,7 @@ import com.google.cloud.translate.TranslateException
...
@@ -7,6 +7,7 @@ import com.google.cloud.translate.TranslateException
import
com.google.cloud.translate.TranslateOptions
import
com.google.cloud.translate.TranslateOptions
import
com.google.cloud.translate.Translation
import
com.google.cloud.translate.Translation
import
javafx.beans.property.SimpleDoubleProperty
import
javafx.beans.property.SimpleDoubleProperty
import
javafx.beans.property.SimpleStringProperty
import
tornadofx.getValue
import
tornadofx.getValue
import
tornadofx.setValue
import
tornadofx.setValue
...
@@ -14,6 +15,7 @@ import tornadofx.setValue
...
@@ -14,6 +15,7 @@ import tornadofx.setValue
class
TranslationBackend
{
class
TranslationBackend
{
companion
object
{
companion
object
{
var
service
:
TranslationService
?
=
null
var
service
:
TranslationService
?
=
null
var
serviceName
=
SimpleStringProperty
()
var
quotaMax
=
0L
var
quotaMax
=
0L
var
quotaUsed
=
0L
var
quotaUsed
=
0L
val
quotaProperty
=
SimpleDoubleProperty
()
val
quotaProperty
=
SimpleDoubleProperty
()
...
@@ -21,11 +23,11 @@ class TranslationBackend {
...
@@ -21,11 +23,11 @@ class TranslationBackend {
var
destinationLanguage
:
String
=
""
var
destinationLanguage
:
String
=
""
var
sourceLanguage
:
String
=
""
var
sourceLanguage
:
String
=
""
operator
fun
invoke
(
text
:
String
,
sourceLang
:
String
=
sourceLanguage
,
destLang
:
String
=
destinationLanguage
)
:
String
=
operator
fun
invoke
(
text
:
String
,
sourceLang
:
String
=
sourceLanguage
,
destLang
:
String
=
destinationLanguage
)
service
!!
.
translate
(
text
,
sourceLang
,
destLang
)
:
String
=
service
!!
.
translate
(
text
,
sourceLang
,
destLang
)
fun
invoke
(
textList
:
List
<
String
>,
sourceLang
:
String
=
sourceLanguage
,
destLang
:
String
=
destinationLanguage
)
:
List
<
String
>
=
fun
invoke
(
textList
:
List
<
String
>,
sourceLang
:
String
=
sourceLanguage
,
destLang
:
String
=
destinationLanguage
)
service
?.
translate
(
textList
,
sourceLang
,
destLang
)
?:
:
List
<
String
>
=
service
?.
translate
(
textList
,
sourceLang
,
destLang
)
?:
throw
TranslationServiceUnitializedException
(
"Translation service uninitialized!"
)
throw
TranslationServiceUnitializedException
(
"Translation service uninitialized!"
)
val
provider
:
String
=
when
(
service
)
{
val
provider
:
String
=
when
(
service
)
{
...
@@ -33,6 +35,11 @@ class TranslationBackend {
...
@@ -33,6 +35,11 @@ class TranslationBackend {
is
DeepLTranslator
->
"DeepL"
is
DeepLTranslator
->
"DeepL"
else
->
"error"
else
->
"error"
}
}
fun
setService
(
service
:
TranslationService
,
name
:
String
)
{
this
.
service
=
service
serviceName
.
value
=
name
}
}
}
}
}
...
@@ -74,7 +81,9 @@ class DeepLTranslator(APIkey: String) : TranslationService {
...
@@ -74,7 +81,9 @@ class DeepLTranslator(APIkey: String) : TranslationService {
TranslationBackend
.
quotaMax
=
usage
.
character
!!
.
limit
TranslationBackend
.
quotaMax
=
usage
.
character
!!
.
limit
TranslationBackend
.
quota
=
usage
.
character
!!
.
count
.
toDouble
()
/
usage
.
character
!!
.
limit
TranslationBackend
.
quota
=
usage
.
character
!!
.
count
.
toDouble
()
/
usage
.
character
!!
.
limit
}
catch
(
e
:
DeepLException
)
{
}
catch
(
e
:
DeepLException
)
{
throw
TranslationServiceException
(
"DeepL API initialization failed with message: ${e.message}"
,
e
)
throw
TranslationServiceException
(
"Error: ${e.message}"
,
e
)
}
catch
(
e
:
IllegalArgumentException
)
{
throw
TranslationServiceException
(
"API key must not be empty"
)
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment