Is there a semi-automated way to perform string extraction for i18n?

前端 未结 8 1798
死守一世寂寞
死守一世寂寞 2021-02-07 17:15

We have a Java project which contains a large number of English-language strings for user prompts, error messages and so forth. We want to extract all the translatable strings i

8条回答
  •  我在风中等你
    2021-02-07 17:54

    Eclipse will externalize every individual string and does not automatically build substitution like you are looking for. If you have a very consistent convention of how you build your strings you could write a perl script to do some intelligent replacement on .java files. But this script will get quite complex if you want to handle

    • String msg = new String("Hello");
    • String msg2 = "Hello2";
    • String msg3 = new StringBuffer().append("Hello3").toString();
    • String msg4 = "Hello" + 4;
    • etc.

    I think there are some paid tools that can help with this. I remember evaluating one, but I don't recall its name. I also don't remember if it could handle variable substitution in external strings. I'll try to find the info and edit this post with the details.

    EDIT: The tool was Globalyzer by Lingport. The website says it supports string externalization, but not specifically how. Not sure if it supports variable substitution. There is a free trial version so you could try it out and see.

提交回复
热议问题