How to make a inspection description localization (or internationalization)?
Answered
I made a plugin which includes a set of inspection rules. Now I want to make these inspection descriptions adapt localization.
Let's say an inspector called "FooInspector", follow this guide I make two dir called "inspectionDescriptions" and "inspectionDescriptions_zh", both contain "FooInspector.html" but with different contents.
When I run IDEA with this plugin and Locale set to LOCALE.CHINESE, inspector show "FooInspector.html" which in "inspectionDescriptions" but not "inspectionDescriptions_zh".
So, is there any way make inspection description use "inspectionDescriptions_zh" when the IDEA environment uses LOCALE.CHINESE ?
Please sign in to leave a comment.
Please check Locale is really active by inspection idea.log file for message
"---------------------- IDE STARTED ------------------------------------------------------"
and look for message shortly after
INFO - #com.intellij.idea.Main - locale=de_DE JNU=UTF-8 file.encoding=UTF-8
containing "locale"
it shows
#com.intellij.idea.Main - locale=zh_CN_#Hans JNU=UTF-8 file.encoding=UTF-8
Thie value looks strange, is it intended?
locale=zh_CN_#Hans
What is _#Hans?
zh means Language, CN means country 'China' , #Hans means Simplified Chinese.
And it shows in IDEA log.
Does this suffix '_#Hans' make something wrong?
Could you please try with "locale=zh_CN"? Thanks.
"local=zh_CN_#Hans" is set by IDEA automatically.
I think the key problem is "loadDescription" method on "com/intellij/codeInspection/ex/InspectionToolWrapper.java" file.
On 2018.3 inspection description loads by "getDescriptionUrl" method, and on 2019.3 it loads by "getDescriptionStream" method.
Both of then use the default folder named "inspectionDescriptions" but not try with locale setting when myEP(InspectionExtentionPoint) exists.
For me, may be I can only use "inspectionDescriptions" folder to solve this problem. But I don't think it is a good choice for plugin developer.
Thanks for the update, we are investigating current behavior.