OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 89 → Rev 90

/trunk/OpenConcerto/src/org/openconcerto/utils/i18n/TM.java
18,6 → 18,7
import org.openconcerto.utils.PropertiesUtils;
import org.openconcerto.utils.Tuple2;
 
import java.beans.Introspector;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
40,7 → 41,7
* Translation manager. The translations are provided by {@link Translator} instances, they are
* created either from a class ending in a language tag that implements it, or by properties files
* that must contain values that will be passed to {@link MessageFormat}. In the latter case,
* messages can reference {@link #createValue(Map, String) virtual named arguments}.
* messages can reference {@link #createValue(Map, Object[], String) virtual named arguments}.
*
* @author Sylvain
* @see LocalizedInstances
51,6 → 52,11
EXCEPTION, NULL, STRING
}
 
static public final String NOUN_CLASS_PROP = "nounClass";
static {
assert NOUN_CLASS_PROP.equals(Introspector.decapitalize(NounClass.class.getSimpleName()));
}
 
static private final MissingMode DEFAULT_MISSING_MODE = MissingMode.STRING;
 
static private final TM INSTANCE = new TM();
233,10 → 239,12
/**
* Try to create a value for a missing key. The syntax of keys must be phraseName(__name)+ and
* if you need to have __ in a name it must be doubled (i.e. ____). <code>phraseName</code>, as
* its name implies, must reference an existing phrase in <code>map</code>. Then this phrase and
* the list of <code>name</code> are passed to {@link Grammar#eval(Phrase, Number, List)}. The
* count is <code>phraseNameCount</code> if it exists and is a {@link Number}, then
* <code>count</code> else <code>null</code>.
* its name implies, must reference an existing phrase in <code>map</code>. If this phrase is
* suffixed by {@value #NOUN_CLASS_PROP} then the {@link NounClass#getName() name} of the noun
* class of the phrase is returned. Else this phrase and the list of <code>name</code> are
* passed to {@link Grammar#eval(Phrase, Number, List)}. The count is
* <code>phraseNameCount</code> if it exists and is a {@link Number}, then <code>count</code>
* else <code>null</code>.
*
* @param map the current map.
* @param objects the original map as an array.
282,7 → 290,14
assert first != null;
final Object firstObj = handleGet(map, first);
final Phrase phrase = firstObj instanceof Phrase ? (Phrase) firstObj : null;
if (phrase != null && phrase.getGrammar() != null) {
if (phrase != null && l.size() == 2 && NOUN_CLASS_PROP.equals(l.get(1))) {
if (phrase.getNounClass() == null) {
Log.get().warning("No noun class for " + phrase);
return phrase.getBase();
} else {
return phrase.getNounClass().getName();
}
} else if (phrase != null && phrase.getGrammar() != null) {
Object countObj = handleGet(map, first + "Count");
if (!(countObj instanceof Number))
countObj = handleGet(map, "count");