-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
String improvements & use SQLite for storage
- Loading branch information
Showing
14 changed files
with
304 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,4 +74,5 @@ bin/ | |
service.properties | ||
|
||
common/src/main/generated/ | ||
service/src/main/generated/ | ||
service/src/main/generated/ | ||
*.db |
72 changes: 72 additions & 0 deletions
72
common/src/main/java/eu/mizerak/alemiz/translationlib/common/string/JoinLocalString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package eu.mizerak.alemiz.translationlib.common.string; | ||
|
||
import java.util.Locale; | ||
import java.util.function.Function; | ||
|
||
public class JoinLocalString<T> implements LocalString<T> { | ||
|
||
private final LocalString<T> left; | ||
private final LocalString<T> right; | ||
|
||
private final String delimiter; | ||
|
||
public JoinLocalString(LocalString<T> left, LocalString<T> right) { | ||
this(left, right, ""); | ||
} | ||
|
||
public JoinLocalString(LocalString<T> left, LocalString<T> right, String delimiter) { | ||
this.left = left; | ||
this.right = right; | ||
this.delimiter = delimiter; | ||
} | ||
|
||
@Override | ||
public String getKey() { | ||
return this.left.getKey() + "_" + this.right.getKey(); | ||
} | ||
|
||
@Override | ||
public LocalString<T> reload() { | ||
this.left.reload(); | ||
this.right.reload(); | ||
return this; | ||
} | ||
|
||
@Override | ||
public LocalString<T> enableReload(boolean enable) { | ||
this.left.enableReload(enable); | ||
this.right.enableReload(enable); | ||
return this; | ||
} | ||
|
||
@Override | ||
public LocalString<T> withArgument(String name, Function<TranslationContext<T>, String> mapper) { | ||
throw new UnsupportedOperationException("Joined string does not support arguments"); | ||
} | ||
|
||
@Override | ||
public LocalString<T> clearArguments() { | ||
throw new UnsupportedOperationException("Joined string does not support arguments"); | ||
} | ||
|
||
@Override | ||
public String getFormatted() { | ||
return this.left.getFormatted() + this.delimiter + this.right.getFormatted(); | ||
} | ||
|
||
@Override | ||
public String getFormatted(Locale locale) { | ||
return this.left.getFormatted(locale) + this.delimiter + this.right.getFormatted(locale); | ||
} | ||
|
||
@Override | ||
public String getText(T object) { | ||
return this.left.getText(object) + this.delimiter + this.right.getText(object); | ||
} | ||
|
||
@Override | ||
public void uploadFallbackMessage() { | ||
this.left.uploadFallbackMessage(); | ||
this.right.uploadFallbackMessage(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
common/src/main/java/eu/mizerak/alemiz/translationlib/common/string/StringWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package eu.mizerak.alemiz.translationlib.common.string; | ||
|
||
import java.util.Locale; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* A very simple implementation of a LocalString, which does not do any translations or formatting | ||
* nor does support language translations. | ||
*/ | ||
public class StringWrapper<T> implements LocalString<T> { | ||
public static StringWrapper<Object> EMPTY = new StringWrapper<>(""); | ||
|
||
private final String text; | ||
|
||
protected StringWrapper(String text) { | ||
this.text = text; | ||
} | ||
|
||
@Override | ||
public String getKey() { | ||
return "wrapper"; | ||
} | ||
|
||
@Override | ||
public LocalString<T> reload() { | ||
throw new UnsupportedOperationException("Static string does not support reload"); | ||
} | ||
|
||
@Override | ||
public LocalString<T> enableReload(boolean b) { | ||
throw new UnsupportedOperationException("Static string does not support reload"); | ||
} | ||
|
||
@Override | ||
public LocalString<T> withArgument(String s, Function<TranslationContext<T>, String> function) { | ||
return this; | ||
} | ||
|
||
@Override | ||
public LocalString<T> clearArguments() { | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getFormatted() { | ||
return this.text; | ||
} | ||
|
||
@Override | ||
public String getFormatted(Locale locale) { | ||
return this.text; | ||
} | ||
|
||
@Override | ||
public String getText(T t) { | ||
return this.text; | ||
} | ||
|
||
@Override | ||
public void uploadFallbackMessage() { | ||
throw new UnsupportedOperationException("Static can not be uploaded"); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.text; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.