@Override public void broadcast(String source, CommandSource[] receivers, String clazz, Object[] args) { int key = getKey(source, clazz); for (CommandSource receiver : receivers) { String use = source; LanguageDictionary dict = getDictionary(receiver.getPreferredLocale()); if (dict != null) { String translation = dict.getTranslation(key); if (translation != null) { use = translation; } } receiver.sendMessage(use); } }
/** * Returns the translation of source into the receivers preferred language * * @param source the string to translate * @param receiver the receiver who will see the message * @param args any object given will be inserted into the target string for each %0, %1 asf * @param foundClass the class that called the translation (used for determining which translation * is correct) * @return the translation */ @Override public String tr(String source, CommandSource receiver, String foundClass, Object[] args) { String use = source; Locale preferred = receiver.getPreferredLocale(); // Search for translation LanguageDictionary dict = getDictionary(preferred); Number num = 0; if (args.length >= 1 && args[0] instanceof Number) { num = (Number) args[0]; } if (dict != null) { int key = getKey(source, foundClass); if (key != NO_ID) { String translation = dict.getTranslation(key, num); if (translation != null) { use = translation; } } } return use; }