Translation Check - update changes due to new option, issue #149

This commit is contained in:
alexkravin 2014-12-16 14:10:57 +04:00 committed by Roman Ivanov
parent 284b505ace
commit 7e36b3cbd1
5 changed files with 71 additions and 1 deletions

View File

@ -52,6 +52,18 @@ import java.util.Map.Entry;
* <pre>
* &lt;module name="Translation"/&gt;
* </pre>
* Check has a property <b>basenameSeparator</b> which allows setting separator in file names,
* default value is '_'.
* <p>
* E.g.:
* </p>
* <p>
* messages_test.properties //separator is '_'
* </p>
* <p>
* app-dev.properties //separator is '-'
* </p>
* <br>
* @author Alexandra Bunge
* @author lkuehne
*/

View File

@ -61,4 +61,23 @@ public class TranslationCheckTest
// key2=y
// should not result in error message about key1 missing in the y bundle
@Test
public void testBaseNameSeparator() throws Exception
{
final DefaultConfiguration checkConfig = createCheckConfig(TranslationCheck.class);
checkConfig.addAttribute("basenameSeparator", "-");
final String[] expected = {
"0: Key 'only.english' missing.",
};
final File[] propertyFiles = new File[] {
new File(getPath("app-dev.properties")),
new File(getPath("app-stage.properties")),
};
verify(
createChecker(checkConfig),
propertyFiles,
getPath("app-dev.properties"),
expected);
}
}

View File

@ -0,0 +1,12 @@
# input file for TranslationCheck
# a key that is available in all translations
hello=Hallo
# whitespace at end of key should be trimmed before comparing.
# the german translation does not contain whitespace, no error should
# be reported here
cancel=Abbrechen
# a key that is missing in german translation
#only.english=only english

View File

@ -0,0 +1,12 @@
# input file for TranslationCheck
# a key that is available in all translations
hello=Hello
# whitespace at end of key should be trimmed before comparing.
# the german translation does not contain whitespace, no error should
# be reported here
cancel = Cancel
# a key that is missing in german translation
only.english=only english

View File

@ -215,16 +215,31 @@ messages.properties: Key 'ok' missing.
<td><a href="property_types.html#stringSet">String Set</a></td>
<td><code>properties</code></td>
</tr>
<tr>
<td>basenameSeparator</td>
<td>Allows setting file names separator</td>
<td><a href="property_types.html#string">String</a></td>
<td><code>_</code></td>
</tr>
</table>
</subsection>
<subsection name="Example">
<p>
To configure the check:
To configure the check for files with '_' name separator:
</p>
<source>
&lt;module name=&quot;Translation&quot;/&gt;
</source>
<p>
To configure the check for files with user-set name separator:
</p>
<source>
&lt;module name=&quot;Translation&quot;&gt;
&lt;property name=&quot;basenameSeparator&quot; value=&quot;STRING_LITERAL&quot;/&gt;
&lt;/module&gt;
</source>
</subsection>
<subsection name="Package">