google / google/closure-templates
SoyMsgExtractor crashes when given a plural
- Dominant language
- Java
- Stars
- 700
- Forks
- 199
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 26
Description
Repro steps:
1) Create a soy template with a plural
```
/**
* Say hello to a list of people.
* @param names List of names of the people to say hello to.
*/
{template .helloNames}
{msg desc="names"}
{plural length($names)}
{case 0}Hello nobody!
{case 1}Hello {$names[0]}
{default}Hello sheeple
{/plural}
{/msg}
{/template}
```
2) `java -jar target/soy-2016-07-21-SoyMsgExtractor.jar --srcs example.soy --outputFile foo.xlf`
Expected result:
should output a valid xlf
Actual result:
```
java.lang.ClassCastException: com.google.template.soy.msgs.restricted.SoyMsgPluralPart cannot be cast to com.google.template.soy.msgs.restricted.SoyMsgPlaceholderPart
at com.google.template.soy.xliffmsgplugin.XliffGenerator.generateXliff(XliffGenerator.java:114)
at com.google.template.soy.xliffmsgplugin.XliffMsgPlugin.generateExtractedMsgsFile(XliffMsgPlugin.java:45)
at com.google.template.soy.msgs.SoyMsgBundleHandler.writeToExtractedMsgsFile(SoyMsgBundleHandler.java:182)
```
Contributor guide
Research direction
Reproduce the crash with the provided Soy template and SoyMsgExtractor command. Start at XliffGenerator.java:114, then inspect XliffMsgPlugin.java:45 and SoyMsgBundleHandler.java:182 to trace XLIFF generation. Done means the command completes without ClassCastException and writes a valid foo.xlf file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- localization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100