I am looking for a project to automatically translate my java properties files!
-
1EDIT: As per error message, you call a non static method in a static way... – Usagi Miyamoto Jul 07 '17 at 13:13
-
Is the relative path `lib/google-api-translate-java-0.97.jar` reachable from the location where you are executing `javac`? First thing that comes to mind is that Java can't actually see the JAR even though you think you are including it. – Tim Biegeleisen Jul 07 '17 at 13:19
-
1You are using the API the wrong way. You cannot just call `Translate.execute()`, first you need to create a `Translate` object. About what the second error means: see [Cannot make a static reference to the non-static method](https://stackoverflow.com/questions/4969171/cannot-make-a-static-reference-to-the-non-static-method) – Jesper Jul 07 '17 at 13:22
-
1See this [Google Cloud Translate Sample](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/translate/) – Jesper Jul 07 '17 at 13:24
-
Thank you! I changed the variable. Now I cannot instantiate an abstract class: `Translate is abstract; cannot be instantiated` I am busted... – Leder Jul 07 '17 at 13:30
-
1That's because `Translate` is an interface, and you can't just do `new Translate(...)` with an interface. You'll need to learn how to use this API, take a look at the example in my comment above. – Jesper Jul 07 '17 at 13:40
-
OK, I first thought of a missing library, too, therefore the classpath question: do not know how to check for it! – Leder Jul 07 '17 at 13:40
-
Google Cloud Translate Sample seems to translate text as command line arguments: I have complete en_US java .properties file, how to translate these? – Leder Jul 07 '17 at 13:42
-
StackOverflow is not a suitable place to learn you step by step how to write a Java program. You'll need to learn some basics of Java programming. You can use `java.util.Properties` to read and write properties files. – Jesper Jul 07 '17 at 13:49
3 Answers
I just tried copy/paste the entirety of a properties file in translate.google.com and it the translator respected the file format keeping the keys intact while translating only the values!!!! Amazing job Google.
Depending on the number of files you have to translate it might be a long process to do it one by one (there is also 5000 character limit) but in the case of few files, it is a very viable solution to automation.

- 1,329
- 2
- 12
- 21
I cannot recommend to auto-translate. But I can recommend to maintain your translations in better way than properties files. This plugin will automatically compile your translations into properties files: https://github.com/hoereth/i18n-maven-plugin/blob/master/doc/README_JAVA.md
Feel free to ask me if you have troubles using it.

- 954
- 7
- 17
-
Thank you Mick for your answer. But I think this is one step of added complexity. Furthermore I am not already using maven for building. But I will reconsider, when I switch to maven. – Leder Aug 21 '18 at 19:35