Translation config in json instead of yaml

This commit is contained in:
Vankka 2024-12-28 01:00:51 +02:00
parent 8f639259e5
commit 6498c5af2c
No known key found for this signature in database
GPG Key ID: 62E48025ED4E7EBB
8 changed files with 12 additions and 9 deletions

View File

@ -40,7 +40,7 @@ jobs:
project_id: ${{ secrets.CROWDIN_PROJECT_ID }}
token: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
source: "i18n/build/source.yaml"
source: "i18n/build/source.json"
translation: "/i18n/src/main/resources/translations/%two_letters_code%.%file_extension%"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -32,7 +32,7 @@ jobs:
project_id: ${{ secrets.CROWDIN_PROJECT_ID }}
token: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
source: "i18n/build/source.yaml"
source: "i18n/build/source.json"
translation: "/i18n/src/main/resources/translations/%two_letters_code%.%file_extension%"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -79,6 +79,7 @@ dependencies {
// Config
runtimeDownloadApi(libs.configurate.yaml)
runtimeDownloadApi(libs.configurate.jackson)
// Logging
compileOnly(libs.log4j.core)

View File

@ -300,7 +300,7 @@ public abstract class ConfigurateConfigManager<T, LT extends AbstractConfigurati
return (value, destination) -> {
processor.process(value, destination);
if (destination instanceof CommentedConfigurationNode) {
if (commentSubstitutions && destination instanceof CommentedConfigurationNode) {
String comment = ((CommentedConfigurationNode) destination).comment();
if (comment != null) {
// Yaml doesn't render empty lines correctly, so we add a space when there are double line breaks

View File

@ -25,9 +25,9 @@ import org.jetbrains.annotations.Nullable;
import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.ConfigurateException;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.jackson.JacksonConfigurationLoader;
import org.spongepowered.configurate.loader.AbstractConfigurationLoader;
import org.spongepowered.configurate.serialize.SerializationException;
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
import java.net.URL;
import java.nio.file.Path;
@ -127,7 +127,7 @@ public abstract class TranslatedConfigManager<T extends Config, LT extends Abstr
return null;
}
return YamlConfigurationLoader.builder().url(resourceURL).build().load();
return JacksonConfigurationLoader.builder().url(resourceURL).build().load();
}
private void translateNode(

View File

@ -20,6 +20,7 @@ dependencies {
implementation(project(':velocity')) { transitive = false }
api(libs.configurate.yaml)
api(libs.configurate.jackson)
}
application {

View File

@ -28,10 +28,10 @@ import com.discordsrv.common.core.logging.backend.impl.JavaLoggerImpl;
import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.ConfigurateException;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.jackson.JacksonConfigurationLoader;
import org.spongepowered.configurate.objectmapping.ObjectMapper;
import org.spongepowered.configurate.objectmapping.meta.Processor;
import org.spongepowered.configurate.serialize.SerializationException;
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
import java.nio.file.Path;
import java.nio.file.Paths;
@ -103,8 +103,8 @@ public final class DiscordSRVTranslation {
section.set(configSection);
}
YamlConfigurationLoader.builder()
.path(Paths.get("i18n", "build", "source.yaml"))
JacksonConfigurationLoader.builder()
.path(Paths.get("i18n", "build", "source.json"))
.build()
.save(node);
}

View File

@ -83,8 +83,9 @@ dependencyResolutionManagement {
library('jackson-databind', 'com.fasterxml.jackson.core', 'jackson-databind').version('2.16.1')
// Config(urate)
version('configurate', '4.2.0-yamlbranch-4')
version('configurate', '4.2.0-yamlbranch-5')
library('configurate-yaml', 'org.spongepowered', 'configurate-yaml').versionRef('configurate')
library('configurate-jackson', 'org.spongepowered', 'configurate-jackson').versionRef('configurate')
// DB
library('hikaricp', 'com.zaxxer', 'HikariCP').version {