Skip to content

Commit

Permalink
feat: add NONE value to languages
Browse files Browse the repository at this point in the history
  • Loading branch information
suuft committed Dec 21, 2022
1 parent c25db38 commit 6680391
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repositories {
dependencies {
// other depends
implementation 'net.clojars.suuft:libretranslate-java:1.0.3'
implementation 'net.clojars.suuft:libretranslate-java:1.0.4'
}
```

Expand All @@ -38,7 +38,7 @@ Depend:
<dependency>
<groupId>net.clojars.suuft</groupId>
<artifactId>libretranslate-java</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
```
### `Usage:`
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/suuft/libretranslate/Language.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public enum Language {
SWEDISH("sv"),
TURKISH("tr"),
UKRAINIAN("ua"),
NONE("none")
;

String code;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/suuft/libretranslate/Translator.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public String translate(@NonNull String from, @NonNull String to, @NonNull Strin
e.printStackTrace();
return "Falled translate!";
}


}

public String translate(@NonNull Language from, @NonNull Language to, @NonNull String request) {
if (to == Language.NONE || from == to) return request;
return translate(from.getCode(), to.getCode(), request);
}

public String translate(@NonNull Language to, @NonNull String request) {
if (to == Language.NONE) return request;
return translate("auto", to.getCode(), request);
}
}

0 comments on commit 6680391

Please sign in to comment.