Skip to content

Commit

Permalink
Translation of latest updates to French (#90)
Browse files Browse the repository at this point in the history
* Started translating updates to french

* Translated some of the new articles

* Finished translating all the new stuff

* Integrating recommanded changes
  • Loading branch information
c-leri authored Mar 29, 2024
1 parent b0f2761 commit 7ecec85
Show file tree
Hide file tree
Showing 12 changed files with 560 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/lib/translations/fr/application.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"title": "Wiki pour Développeur·euse·s de Quilt :P",
"title": "Wiki pour Développeur·euse·s Quilt :P",
"dev-notice": "Attention : Ce site est encore en cours de développement. Veuillez signaler les problèmes (en anglais) ici : <{{placeholder}}>",
"translation-notice": "Veuillez noter que la langue originale de ce wiki est l'anglais et que les versions traduites peuvent ne pas être à jour en comparaison à la version anglaise",
"draft-notice": "Cette page du wiki est prévue mais n'a pas encore été implémentée. Vous pouvez participer à la création de ce wiki ici : <{{placeholder}}>",
Expand Down
19 changes: 17 additions & 2 deletions src/lib/translations/fr/wiki.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"not-translated": "Cette page du wiki n'est pas encore été traduite en {{placeholder}}",
"not-translated": "Cette page du wiki n'a pas encore été traduite en {{placeholder}}",
"not-found": "Aucune page du wiki trouvée à l'adresse : `{{placeholder}}`",
"blocks": {
"title": "Blocs",
Expand Down Expand Up @@ -79,7 +79,7 @@
"title": "Ajouter une Armure"
},
"first-item": {
"title": "Créez votre Premier Item"
"title": "Créer votre Premier Item"
},
"food": {
"title": "Ajouter de la Nourriture"
Expand All @@ -88,6 +88,21 @@
"title": "Ajouter des Outils Personnalisés"
}
},
"configuration": {
"title": "Configuration",
"getting-started": {
"title": "Débuter avec Quilt Config"
},
"advanced-configuring": {
"title": "Configuration Avancée"
},
"config-screen": {
"title": "Mettre en place un Écran de Configuration"
},
"metadata": {
"title": "Référence pour les Annotations et les Métadonnées"
}
},
"misc": {
"title": "Divers",
"commands": {
Expand Down
17 changes: 7 additions & 10 deletions wiki/configuration/advanced-configuring/en.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
---
title: Advanced Configuring
index: 2
---

# Advanced configuring
# Advanced Configuring

Simple values are nice and all, but if you have a lot of them it can begin to get unwieldy. In this tutorial, we'll discuss how to organize your config and use processors to get the most out of it.

Expand Down Expand Up @@ -49,9 +44,10 @@ We simply create a new class, inside our config class, that extends `ReflectiveC

## Serializing custom values

In Java, you can print to different output streams in the console. These aren't basic integer or float objects, so we can't just save them in our config! This is where the `ConfigSerializableObject<T>` interface comes in. By implementing its three methods, we can set up any class to be usable as a config object.
In Java, you can print to different output streams in the console. These aren't basic serializable objects like integers or `String`, so we can't just save them in our config! This is where the `ConfigSerializableObject<T>` interface comes in. By implementing its three methods, we can set up any class to be usable as a config object.

The interface works via generics, just like `TrackedValue`. The `<T>` in `ConfigSerializableObject<T>` can be swapped out with any serializable class (remember, by default that's primitive types, `String`, `ValueList`, and `ValueMap`), and the value of your object will be translated into that type to be saved to disk, and then converted back into your custom object when read. To do that translating, we need to implement three methods:

- `T getRepresentation()`: here, your value is converted to the serializable class that you specified in the generics (represented by `T`) so that it can be saved.
- `YourSerializableClass convertFrom(T)`: this one is called when reading the config file, and converts the representation created by `getRepresentation` back to its original type.
- `YourSerializableClass copy()`: makes a copy of the value, which Quilt Config uses internally.
Expand Down Expand Up @@ -167,6 +163,7 @@ public class ExampleModConfig extends ReflectiveConfig {

With that, our config will print "Loading config!" before any of its values are deserialized. Note despite the method name passed to `@Processor` not coming with any parameter information, we still had to put a `Config.Builder` on our method: what's up with that?
Processors can be attached to three different types: tracked values, config sections, and config classes. For each, the parameter will be different, as documented in `Processor`'s Javadoc:

- When used on a tracked value, the processor method will take a `TrackedValue.Builder` as its parameter.
- When used on a section, the processor method will take a `SectionBuilder` as its parameter.
- When used on a config class, the processor method will take a `Config.Builder` as its parameter.
Expand All @@ -190,7 +187,7 @@ public class ExampleModConfig extends ReflectiveConfig {

With that line, we've expanded our logging to now tell us whenever a config value is updated! Neat, but what else can we do with callbacks?

One example of a callback usage is syncing a value between your config field and another. This could be needed for many reasons: your config value is complicated, and you want to make it easier to access, or maybe you need to update the configuration of one of the libraries you depend on when the value is changed ([enigma](<https://github.com/QuiltMC/enigma>) does just that!).
One example of a callback usage is syncing a value between your config field and another. This could be needed for many reasons: your config value is complicated, and you want to make it easier to access, or maybe you need to update the configuration of one of the libraries you depend on when the value is changed ([enigma](https://github.com/QuiltMC/enigma) does just that!).
We're going to set up a shortcut to accessing the print stream made available in `printStream`, that doesn't force you to go through two separate getters to use. To do that, we can use a processor applied to the field!

`src/main/com/example/example_mod/ExampleModConfig`:
Expand All @@ -208,7 +205,7 @@ public class ExampleModConfig extends ReflectiveConfig {
public void processPrintStream(TrackedValue.Builder<PrintStreamOption> builder) {
builder.callback(value -> activeStream = printStream.value().getStream());
}

// ...
}
}
Expand Down Expand Up @@ -238,7 +235,7 @@ public class ExampleModConfig extends ReflectiveConfig {
}
```

With our knowledge of processors, this is simple! You can also use the config builder to add new fields, new sections, and update [metadata](https://wiki.quiltmc.org/en/configuration/metadata), on top of changing the format and using callbacks as we've already covered.
With our knowledge of processors, this is simple! You can also use the config builder to add new fields, new sections, and update [metadata](../configuration/metadata), on top of changing the format and using callbacks as we've already covered.

## Adding multiple files

Expand Down
Loading

1 comment on commit 7ecec85

@Cozy-GitHub
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See preview on Cloudflare Pages: https://f5cda1c7.developer-wiki.pages.dev

Please sign in to comment.