4
If I have one String
fixed within a method is it possible to change it using reflection or something like that?
Example:
public static void main(String[] args) {
String nome = getName();
boolean valid = isValidName(nome);
if (valid) {
System.out.print("Seu nome é valido!");
} else {
System.out.println("Seu nome é inválido!");
}
}
I would need to change the message "Your name is invalid!" to "Invalid name." that at runtime, that is, after compiling and running the program I would need to edit this message.
I am working with an API that is in English, the client asked me to translate it 100%. The API has configurable messages, where you can simply go in the lang.txt file and exchange the messages, but there are some messages that are not available in that lang.txt file so I had to edit-were using reflection, but I came across some messages that are "fixed" (I don’t know if that’s the correct term) and I would need to edit these messages... these messages follow the example above.
Change how? It is not very clear what you want to do
– user28595
I want to change the message "Your name is invalid!" to "Not valid name" for example.
– Eduardo Mior
When? Click [Dit] and explain what Oce is doing, what she is trying to develop and is not succeeding. Your doubt is too superficial. Explaining in these details that I told you, it is easier to understand.
– user28595
@Articuno did an issue of the post now explaining the case better, I hope you understand... I honestly think that what I’m trying to do is impossible... I’ve worked a few times with Reflection but I think not everything in this life is possible ><
– Eduardo Mior
the message calls are always with
System.out
? Or was it a demonstrative example– Pedro
It was a demonstrative example... I just studied and did MANY tests with refleciton and methods, and I think that what I’m trying to do is impossible :(
– Eduardo Mior
I think the only "way" to do this is to try to interpret the method that sends the message to the user, as the API is a game API, I think it shouldn’t be too difficult to interpret the packages that are sent in the player’s chat.
– Eduardo Mior