rquinio / l10n-maven-plugin

:abcd: Maven plugin to validate localization resources in Java properties files
MIT License
3 stars 1 forks source link

Support for multi-line property value with parameters and quotes #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Which version of the plugin are you using?
1.7

What steps will reproduce the problem?
1. Let's messages.properties has line 
key=Some text: ''{0}''\n {1}
2. run mvn com.googlecode.l10n-maven-plugin:l10n-maven-plugin:validate
3. Log contains "Resource contains escaped quote '' but no parameters. This may 
be correct if formatter is called with unused parameters."

What would be the expected output?
No Warnings

Please provide any additional information below.
Simplest solution is to change 
com.googlecode.l10nmavenplugin.validators.family.ParametricCoherenceValidator.is
Parametric(String)

    public static boolean isParametric(String message)
    {
        for (String s : message.split("\n"))
        {
            Matcher m = DETECT_PARAMETERS_PATTERN.matcher(s);
            if (m.matches())
            {
                return true;
            }
        }

        return false;
    }
and to add in 
com.googlecode.l10nmavenplugin.validators.family.ParametricCoherenceValidatorTes
t

    @Test
    public void isParametric()
    {
        assertTrue(ParametricCoherenceValidator.isParametric("Some text: ''{0}'' {1}"));
        assertTrue(ParametricCoherenceValidator.isParametric("Some text: ''{0}''\n {1}"));
    }

Original issue reported on code.google.com by aliku...@gmail.com on 14 May 2013 at 6:42

GoogleCodeExporter commented 9 years ago
I reproduced the issue, it seems that by default java.util.regex.Pattern does 
not match newline characters with dot (. character), so the patterns in 
ParametricCoherenceValidator and ParametricMessageValidator where failing as 
soon as a \n was present in property value.

I've passed the flag DOTALL to cover those use cases.

Original comment by romain.q...@gmail.com on 2 Jun 2013 at 4:05

GoogleCodeExporter commented 9 years ago

Original comment by romain.q...@gmail.com on 14 Nov 2013 at 10:28