mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-i18n] Fix starting format handling (IDEA-247626)
GitOrigin-RevId: d5b824f0321faee830d0691ed77e2352dbc0695e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7f61594082
commit
12d0396905
+4
-2
@@ -270,11 +270,13 @@ public class TitleCapitalizationInspection extends AbstractBaseJavaLocalInspecti
|
||||
MessageFormat clone = (MessageFormat)myFormat.clone();
|
||||
clone.setFormats(new Format[formats.length]);
|
||||
if (!NlsCapitalizationUtil.isCapitalizationSatisfied(clone.toPattern(), capitalization)) return false;
|
||||
for (Format format : formats) {
|
||||
boolean startsWithFormat = myFormat.toPattern().startsWith("{");
|
||||
for (int i = 0; i < formats.length; i++) {
|
||||
Format format = formats[i];
|
||||
if (format instanceof ChoiceFormat) {
|
||||
for (Object subValue : ((ChoiceFormat)format).getFormats()) {
|
||||
String str = subValue.toString();
|
||||
if (capitalization == Nls.Capitalization.Sentence) {
|
||||
if (capitalization == Nls.Capitalization.Sentence && (i > 0 || !startsWithFormat)) {
|
||||
str = "The " + str;
|
||||
}
|
||||
if (!NlsCapitalizationUtil.isCapitalizationSatisfied(str, capitalization)) return false;
|
||||
|
||||
@@ -31,5 +31,8 @@ class X {
|
||||
test2(message("property.choice.lower", x));
|
||||
|
||||
test2(message("property.sentence.with.quote"));
|
||||
|
||||
test(<warning descr="String '{0,choice,0#No|1#{0}} {0,choice,0#occurrences|1#occurrence|2#occurrences} found so far' is not properly capitalized. It should have title capitalization">message("property.choice.sentence.start", x)</warning>);
|
||||
test2(message("property.choice.sentence.start", x));
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -67,7 +67,8 @@ public class CapitalizationInspectionTest extends LightJavaCodeInsightFixtureTes
|
||||
"property.parameterized=Hello {0}\n" +
|
||||
"property.choice.title=Hello {0,choice,0#World|1#Universe}\n" +
|
||||
"property.choice.mixed=Hello {0,choice,0#World|1#universe}\n" +
|
||||
"property.choice.lower=Hello {0,choice,0#world|1#universe}\n" +
|
||||
"property.choice.lower=Hello {0,choice,0#world|1#universe}\n" +
|
||||
"property.choice.sentence.start={0,choice,0#No|1#{0}} {0,choice,0#occurrences|1#occurrence|2#occurrences} found so far\n" +
|
||||
"property.sentence.with.quote='return' is not allowed here";
|
||||
myFixture.addFileToProject("MyBundle.properties", props);
|
||||
doTest(false);
|
||||
|
||||
Reference in New Issue
Block a user