1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-11 11:44:59 -05:00

I18N: All handlers now read their string from resources

This commit is contained in:
Sebastian Kaspari 2010-09-05 16:25:18 +02:00
parent 84fedf8be2
commit 5ea7d49c34
16 changed files with 30 additions and 26 deletions

View File

@ -55,7 +55,7 @@ public class HelpHandler extends BaseHandler
} else if (params.length == 1) {
showAllCommands(service, server, conversation);
} else {
throw new CommandException("Invalid number of params");
throw new CommandException(service.getString(R.string.invalid_number_of_params));
}
}
@ -70,7 +70,9 @@ public class HelpHandler extends BaseHandler
{
CommandParser cp = CommandParser.getInstance();
StringBuffer commandList = new StringBuffer("Available commands: \n");
StringBuffer commandList = new StringBuffer(service.getString(R.string.available_commands));
commandList.append("\n");
HashMap<String, BaseHandler> commands = cp.getCommands();
HashMap<String, String> aliases = cp.getAliases();
@ -81,7 +83,7 @@ public class HelpHandler extends BaseHandler
String alias = "";
for (Object aliasCommand : aliasesKeys) {
if (command.equals(aliases.get(aliasCommand))) {
alias = " or /" + aliasCommand;
alias = " " + service.getString(R.string.logical_or) + " /" + aliasCommand;
break;
}
}
@ -116,6 +118,7 @@ public class HelpHandler extends BaseHandler
HashMap<String, BaseHandler> commands = cp.getCommands();
if (commands.containsKey(command)) {
// XXX:I18N - String building salad :)
Message message = new Message("Help of /" + command + "\n" + commands.get(command).getUsage() + "\n" + commands.get(command).getDescription(service) + "\n");
message.setColor(Message.COLOR_YELLOW);
conversation.addMessage(message);
@ -128,7 +131,7 @@ public class HelpHandler extends BaseHandler
service.sendBroadcast(intent);
} else {
throw new CommandException("Unknown command: " + command);
throw new CommandException(service.getString(R.string.unknown_command, command));
}
}

View File

@ -47,7 +47,7 @@ public class JoinHandler extends BaseHandler
} else if (params.length == 3) {
service.getConnection(server.getId()).joinChannel(params[1], params[2]);
} else {
throw new CommandException("Invalid number of params");
throw new CommandException(service.getString(R.string.invalid_number_of_params));
}
}

View File

@ -45,13 +45,13 @@ public class KickHandler extends BaseHandler
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
{
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
throw new CommandException("Only usable from within a channel");
throw new CommandException(service.getString(R.string.only_usable_from_channel));
}
if (params.length == 2) {
service.getConnection(server.getId()).kick(conversation.getName(), params[1]);
} else {
throw new CommandException("Invalid number of params");
throw new CommandException(service.getString(R.string.invalid_number_of_params));
}
}

View File

@ -46,7 +46,7 @@ public class MeHandler extends BaseHandler
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
{
if (conversation.getType() == Conversation.TYPE_SERVER) {
throw new CommandException("Only usable from within a channel or a query");
throw new CommandException(service.getString(R.string.only_usable_from_channel_or_query));
}
if (params.length > 1) {
@ -66,7 +66,7 @@ public class MeHandler extends BaseHandler
service.getConnection(server.getId()).sendAction(conversation.getName(), action);
} else {
throw new CommandException("Text is missing");
throw new CommandException(service.getString(R.string.text_missing));
}
}

View File

@ -49,7 +49,7 @@ public class ModeHandler extends BaseHandler
service.getConnection(server.getId()).setMode(params[1], modes);
} else {
throw new CommandException("Invalid number of params");
throw new CommandException(service.getString(R.string.invalid_number_of_params));
}
}

View File

@ -66,7 +66,7 @@ public class MsgHandler extends BaseHandler
service.sendBroadcast(intent);
}
} else {
throw new CommandException("Invalid number of params");
throw new CommandException(service.getString(R.string.invalid_number_of_params));
}
}

View File

@ -48,9 +48,10 @@ public class NamesHandler extends BaseHandler
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
{
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
throw new CommandException("Only usable from within a channel");
throw new CommandException(service.getString(R.string.only_usable_from_channel));
}
// XXX:I18N - Translation needed!
StringBuffer userList = new StringBuffer("Users " + conversation.getName() + ":");
User[] mUsers = service.getConnection(server.getId()).getUsers(conversation.getName());

View File

@ -45,7 +45,7 @@ public class NickHandler extends BaseHandler
if (params.length == 2) {
service.getConnection(server.getId()).changeNick(params[1]);
} else {
throw new CommandException("Invalid number of params");
throw new CommandException(service.getString(R.string.invalid_number_of_params));
}
}

View File

@ -63,7 +63,7 @@ public class NoticeHandler extends BaseHandler
service.getConnection(server.getId()).sendNotice(params[1], text);
} else {
throw new CommandException("Invalid number of params");
throw new CommandException(service.getString(R.string.invalid_number_of_params));
}
}

View File

@ -43,13 +43,13 @@ public class OpHandler extends BaseHandler
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
{
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
throw new CommandException("Only usable from within a channel");
throw new CommandException(service.getString(R.string.only_usable_from_channel));
}
if (params.length == 2) {
service.getConnection(server.getId()).op(conversation.getName(), params[1]);
} else {
throw new CommandException("Invalid number of params");
throw new CommandException(service.getString(R.string.invalid_number_of_params));
}
}

View File

@ -46,14 +46,14 @@ public class PartHandler extends BaseHandler
{
if (params.length == 1) {
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
throw new CommandException("Only usable from within a channel");
throw new CommandException(service.getString(R.string.only_usable_from_channel));
}
service.getConnection(server.getId()).partChannel(conversation.getName());
} else if (params.length == 2) {
service.getConnection(server.getId()).partChannel(params[1]);
} else {
throw new CommandException("Invalid number of params");
throw new CommandException(service.getString(R.string.invalid_number_of_params));
}
}

View File

@ -50,13 +50,13 @@ public class QueryHandler extends BaseHandler
if (params.length == 2) {
// Simple validation
if (params[1].startsWith("#")) {
throw new CommandException("You cannot open queries to channels");
throw new CommandException(service.getString(R.string.query_to_channel));
}
Conversation query = server.getConversation(params[1]);
if (query != null) {
throw new CommandException("Query already exists");
throw new CommandException(service.getString(R.string.query_exists));
}
query = new Query(params[1]);
@ -69,7 +69,7 @@ public class QueryHandler extends BaseHandler
);
service.sendBroadcast(intent);
} else {
throw new CommandException("Invalid number of params");
throw new CommandException(service.getString(R.string.invalid_number_of_params));
}
}

View File

@ -48,7 +48,7 @@ public class RawHandler extends BaseHandler
String line = BaseHandler.mergeParams(params);
service.getConnection(server.getId()).sendRawLineViaQueue(line);
} else {
throw new CommandException("Line is missing");
throw new CommandException(service.getString(R.string.line_missing));
}
}

View File

@ -46,7 +46,7 @@ public class TopicHandler extends BaseHandler
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
{
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
throw new CommandException("Only usable from within a channel");
throw new CommandException(service.getString(R.string.only_usable_from_channel));
}
Channel channel = (Channel) conversation;

View File

@ -43,13 +43,13 @@ public class VoiceHandler extends BaseHandler
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
{
if (conversation.getType() != Conversation.TYPE_CHANNEL) {
throw new CommandException("Only usable from within a channel");
throw new CommandException(service.getString(R.string.only_usable_from_channel));
}
if (params.length == 2) {
service.getConnection(server.getId()).voice(conversation.getName(), params[1]);
} else {
throw new CommandException("Invalid number of params");
throw new CommandException(service.getString(R.string.invalid_number_of_params));
}
}

View File

@ -45,7 +45,7 @@ public class WhoisHandler extends BaseHandler
public void execute(String[] params, Server server, Conversation conversation, IRCService service) throws CommandException
{
if (params.length != 2) {
throw new CommandException("Invalid number of params");
throw new CommandException(service.getString(R.string.invalid_number_of_params));
}
service.getConnection(server.getId()).sendRawLineViaQueue("WHOIS " + params[1]);