Skip to content

Commit 90a12c2

Browse files
add CONTRIBUTING.md with information on translations, esp. alias translations
1 parent c2b17f2 commit 90a12c2

File tree

3 files changed

+89
-2
lines changed

3 files changed

+89
-2
lines changed

CONTRIBUTING.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Contributing
2+
3+
Thank you for your interest in contributing to Enigma!
4+
5+
We recommend discussing your contribution with other members of the community - either directly in your pull request,
6+
or in our other community spaces. We're always happy to help if you need us!
7+
8+
Enigma is distributed under the [LGPL-3.0](LICENSE).
9+
10+
## Translating
11+
Translations are loaded from [enigma/src/main/resources/lang/](enigma/src/main/resources/lang/).
12+
13+
These are the currently supported languages and there corresponding files:
14+
15+
| Language | File |
16+
|----------------------------|--------------|
17+
| English (U.S.) **default** | `en_us.json` |
18+
| Chinese (Simplified) | `zh_cn.json` |
19+
| French | `fr_fr.json` |
20+
| German | `de_de.json` |
21+
| Japanese | `ja_jp.json` |
22+
23+
If a language you'd like to translate isn't on the list, feel free to ask for help on
24+
[Quilt's Discord Server](https://discord.quiltmc.org/)!
25+
26+
### Search Aliases
27+
Many elements in Enigma's GUI support search aliases, but most don't have any aliases.
28+
A full list of search alias translation keys is [below](#complete-list-of-search-alias-translation-keys).
29+
Search aliases are alternative names for an element that a user might search for when looking for that element.
30+
For example, the `Dev` menu element has two search aliases: `"Development"` and `"Debugging"`. This means that if a user
31+
searches for "Debug", the `Dev` menu will be a search result.
32+
33+
Search aliases are language-specific, so there's no need to translate the English aliases if they aren't likely
34+
to be searched for in your target language. In fact, any language may add additional aliases that aren't present in the
35+
English translation.
36+
37+
Since elements can have multiple search aliases, their translations can be lists. Aliases are separated by `;`.<br>
38+
For example, the `Dev` menu's aliases look like this in the translation file: `"Development;Debugging"`
39+
This means that aliases may not contain the `;` character.
40+
41+
Some things to keep in mind when adding search aliases:
42+
- elements' names are always searchable; there's no need to add their names to their aliases
43+
- searching is case-insensitive, so there's no need to add variations that only differ in capitalization
44+
- searching matches prefixes, so there's no need to add variations that are prefixes of one another,
45+
just add the longest variation (note that the element name may be a prefix of an alias, as is the case with `Dev`'s
46+
`"Development"` alias)
47+
48+
If you'd like to add search aliases to an element that doesn't already have aliases, add its alias translation key to
49+
its translation file.
50+
51+
#### Complete list of search alias translation keys
52+
| Element | Translation Key |
53+
|-----------------------------|-------------------------------------------|
54+
| `Dev` menu | `"dev.menu.aliases"` |
55+
| `Collab` menu | `"menu.collab.aliases"` |
56+
| `Decompiler` menu | `"menu.decompiler.aliases"` |
57+
| `Help` menu | `"menu.help.aliases"` |
58+
| `Search` menu | `"menu.search.aliases"` |
59+
| `Crash History` menu | `"menu.file.crash_history.aliases"` |
60+
| `File` menu | `"menu.file.aliases"` |
61+
| `Open Recent Project` menu | `"menu.file.open_recent_project.aliases"` |
62+
| `Save Mappings As...` menu | `"menu.file.mappings.save_as.aliases"` |
63+
| `View` menu | `"menu.view.aliases"` |
64+
| `Entry Tooltips` menu | `"menu.view.entry_tooltips.aliases"` |
65+
| `Languages` menu | `"menu.view.languages.aliases"` |
66+
| `Server Notifications` menu | `"menu.view.notifications.aliases"` |
67+
| `Scale` menu | `"menu.view.scale.aliases"` |
68+
| `Stat Icons` menu | `"menu.view.stat_icons.aliases"` |
69+
| `Themes` menu | `"menu.view.themes.aliases"` |

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
A tool for deobfuscation of Java bytecode. Forked from <https://bitbucket.org/cuchaz/enigma>, originally created by [Jeff Martin](https://www.cuchazinteractive.com/).
44

5+
## Contributing
6+
7+
See [CONTRIBUTING.md](CONTRIBUTING.md)
8+
59
## License
610

711
Enigma is distributed under the [LGPL-3.0](LICENSE).

enigma-swing/src/main/java/org/quiltmc/enigma/gui/element/SearchableElement.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,32 @@
77
import java.util.stream.Stream;
88

99
public interface SearchableElement extends MenuElement {
10+
11+
String ALIASES_SUFFIX = ".aliases";
12+
String ALIAS_DELIMITER = ";";
13+
1014
default Stream<String> streamSearchAliases() {
1115
final String aliases = I18n
12-
.translateOrNull(this.getAliasesTranslationKeyPrefix() + ".aliases");
16+
.translateOrNull(this.getAliasesTranslationKeyPrefix() + ALIASES_SUFFIX);
1317

1418
return Stream.concat(
1519
Stream.of(this.getSearchName()),
16-
aliases == null ? Stream.empty() : Arrays.stream(aliases.split(";"))
20+
aliases == null ? Stream.empty() : Arrays.stream(aliases.split(ALIAS_DELIMITER))
1721
);
1822
}
1923

2024
String getSearchName();
2125

26+
/**
27+
* Returns a translation key prefix used to retrieve translatable search aliases.<br>
28+
* Usually the prefix is the translation key of the translatable element.
29+
*
30+
* <p> {@value ALIASES_SUFFIX} is appended to create the complete translation key.<br>
31+
* Alias translations hold multiple aliases separated by {@value ALIAS_DELIMITER}.
32+
*
33+
* <p> <em>All</em> alias translation key prefixes should be documented in {@code CONTRIBUTING.md} under<br>
34+
* {@code Translating > Search Aliases > Complete list of search alias translation keys}
35+
*/
2236
String getAliasesTranslationKeyPrefix();
2337

2438
void onSearchClicked();

0 commit comments

Comments
 (0)