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

前端 未结 8 1816
死守一世寂寞
死守一世寂寞 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 18:05

    As well as Eclipse's string externalizer, which generates properties files, Eclipse has a warning for non-externalized strings, which is helpful for finding files that you haven't internationalized.

    String msg = "Hello " + name;
    

    gives the warning "Non-externalized string literal; it should be followed by //$NON-NLS-$". For strings that truly do belong in the code you can add an annotation (@SuppressWarnings("nls")) or you can add a comment:

    String msg = "Hello " + name; //$NON-NLS-1$
    

    This is very helpful for converting a project to proper internationalization.

提交回复
热议问题