git-machete-intellij-plugin
git-machete-intellij-plugin copied to clipboard
Consider using {<param-pos>,choice,<#n-cases>} in the bundle
I found the following property:
rebase.notification.successful.rebased.checkout.message=Checked out{0,choice,0#|1# {1}} and rebased it{2,choice,0#|1# on {3}}
and here is its usage:
if (withCheckout) {
return GitBundle.message(
"rebase.notification.successful.rebased.checkout.message",
convertBooleanToInt(currentBranch != null), currentBranch,
convertBooleanToInt(baseBranch != null), baseBranch);
}
And another example to better understand how it works (as there is no documentation for it Xd):
branch.worker.could.not.create.tag=Couldn''t create tag {0}{1,choice,0#|1#|2# in {2}}
String error = GitBundle.message("branch.worker.could.not.create.tag",
name,
GitUtil.getRepositoryManager(repository.getProject()).getRepositories().size(),
getShortRepositoryName(repository));
Action points:
- [x] when this functionality has been introduced? can we safely use it (in the scope of backward compatibility)?
- [ ] if we can use it; do we have use cases for it?
- [ ] if we do have them; apply it to our bundle
And question number ~one~ zero, WTF it even does? 😯 as in, what's the syntax/semantics of these expressions... from a quick look it seems to be some if-then-else (?)
Yup, it is if (else if) else
- First is the index of param - length/size/etc (some int)
- Then "choice" keyword
- Options separated with
|, e.g. 0# is applied when the param value is equal to 0, 1# if it equals to 1, etc
I assume that last case works like else (so all not met before values go for it)
Looking at a source code, this feature is provided by java.text.MessageFormat from Java 1.1 and has been implemented in IntelliJ from at least 2012
One more thing: whether https://checkerframework.org/dev/api/org/checkerframework/checker/i18nformatter/I18nFormatterChecker.html that we heavily rely on even supports it
It works very well. Not only does it detect the number of arguments, but also the type (the switching argument must be a number)
Looking though the tutorials, this feature is mostly used when dealing with numbers, example being:
We have {0, choice, 0#no messages|1#a message|2#two messages|2<{2, number, integer} messages} for you
Probably not worth pursuing, closing