File tree Expand file tree Collapse file tree
main/java/dev/isxander/yacl3/config/v2/impl
testmod/resources/assets/yacl_test/lang Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010import dev .isxander .yacl3 .config .v2 .impl .autogen .YACLAutoGenException ;
1111import dev .isxander .yacl3 .impl .utils .YACLConstants ;
1212import dev .isxander .yacl3 .platform .YACLPlatform ;
13+ import net .minecraft .locale .Language ;
1314import net .minecraft .network .chat .Component ;
1415import net .minecraft .resources .Identifier ;
1516import org .apache .commons .lang3 .Validate ;
@@ -134,8 +135,14 @@ public YetAnotherConfigLib generateGui() {
134135 OptionAddable group = groups .groups ().computeIfAbsent (autoGen .group ().orElse ("" ), k -> {
135136 if (k .isEmpty ())
136137 return groups .category ();
137- return OptionGroup .createBuilder ()
138- .name (Component .translatable ("yacl3.config.%s.category.%s.group.%s" .formatted (id ().toString (), autoGen .category (), k )));
138+ String groupKey = "yacl3.config.%s.category.%s.group.%s" .formatted (id ().toString (), autoGen .category (), k );
139+ OptionGroup .Builder groupBuilder = OptionGroup .createBuilder ()
140+ .name (Component .translatable (groupKey ));
141+ String descriptionKey = groupKey + ".desc" ;
142+ if (Language .getInstance ().has (descriptionKey )) {
143+ groupBuilder .description (OptionDescription .of (Component .translatable (descriptionKey )));
144+ }
145+ return groupBuilder ;
139146 });
140147
141148 Option <?> option ;
Original file line number Diff line number Diff line change 1+ {
2+ "yacl3.config.yacl3-test:config.category.test.group.master_test" : " My group!" ,
3+ "yacl3.config.yacl3-test:config.category.test.group.master_test.desc" : " This group has a description via a translation key."
4+ }
You can’t perform that action at this time.
0 commit comments