Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update OtherModChanger.java #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,26 @@
import java.io.InputStream;

public class OtherModChanger implements ILangChanger {
@Override
public void changeLanguage(Logger logger, String lang) throws LangNotFoundException {
for (ModContainer container : Loader.instance().getActiveModList()) {
InputStream is = OtherModChanger.class.getResourceAsStream("/assets/" + container.getModId() + "/lang/" + lang + ".lang");
if (is == null) {
continue;
}
LanguageMap.inject(is);
logger.info("Change lang to " + lang + " for " + container.getModId() + " done!");
}
}
@Override
public void changeLanguage(Logger logger, String lang) throws LangNotFoundException {
int len = lang.length();
for (ModContainer container : Loader.instance().getActiveModList()) {
char[][] tmp = new char[2][];
tmp[0] = lang.toLowerCase().toCharArray();
tmp[1] = lang.toUpperCase().toCharArray();
for (int i = 0; i < 1 << len; i++) {
String value = "";
for (int j = 0; j < len; j++) {
value += tmp[(i >> j) % 2][j];
}
InputStream is = OtherModChanger.class.getResourceAsStream("/assets/" + container.getModId() + "/lang/" + value + ".lang");
if (is == null) {
continue;
}
LanguageMap.inject(is);
logger.info("Change lang to " + value + " for " + container.getModId() + " done!");
break;
}
}
}
}