Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge branch '1.6' into integration/master
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Jul 6, 2012
2 parents 51aefae + f417b70 commit dbdff9c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
Expand Up @@ -126,6 +126,11 @@ public void create()
}
}

static Properties getPluralForms()
{
return pluralForms;
}

/**
* Merges the list of TextFlows into the target HDocument, adding and
* obsoleting TextFlows as necessary.
Expand Down Expand Up @@ -1078,6 +1083,11 @@ public int getNumPlurals(HDocument document, HLocale hLocale)
}

private int getNPluralForms(String entries, HLocale targetLocale)
{
return getNPluralForms(entries, targetLocale.getLocaleId());
}

int getNPluralForms(String entries, LocaleId localeId)
{
int nPlurals = 1;

Expand All @@ -1094,17 +1104,17 @@ private int getNPluralForms(String entries, HLocale targetLocale)
}
else
{
pluralForms = getPluralForms(targetLocale);
pluralForms = getPluralForms(localeId);
}
}
else
{
pluralForms = getPluralForms(targetLocale);
pluralForms = getPluralForms(localeId);
}
if (pluralForms == null)
{
log.error("No plural forms for locale {0} found in {1}", targetLocale, PLURALS_FILE);
throw new RuntimeException("No plural forms found; contact admin. Locale: " + targetLocale);
log.error("No plural forms for locale {0} found in {1}", localeId, PLURALS_FILE);
throw new RuntimeException("No plural forms found; contact admin. Locale: " + localeId);
}
Matcher nPluralsMatcher = NPLURALS_PATTERN.matcher(pluralForms);
String nPluralsString = "";
Expand Down
6 changes: 6 additions & 0 deletions zanata-war/src/main/resources/pluralforms.properties
Expand Up @@ -25,6 +25,7 @@ bg=nplurals=2; plural=(n != 1)
bn=nplurals=2; plural=(n != 1)
bo=nplurals=1; plural=0
br=nplurals=2; plural=(n > 1)
brx=nplurals=2; plural=(n != 1)
bs=nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)

# C
Expand All @@ -39,6 +40,7 @@ cy=nplurals=4; plural= (n==1) ? 0 : (n==2) ? 1 : (n != 8 && n != 11) ? 2 : 3

da=nplurals=2; plural=(n != 1)
de=nplurals=2; plural=(n != 1)
doi=nplurals=2; plural=(n != 1)
dz=nplurals=1; plural=0

# E
Expand Down Expand Up @@ -73,6 +75,7 @@ gun=nplurals=2; plural = (n > 1)
ha=nplurals=2; plural=(n != 1)
he=nplurals=2; plural=(n != 1)
hi=nplurals=2; plural=(n != 1)
hne=nplurals=2; plural=(n != 1)
hy=nplurals=1; plural=0
hr=nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)
hu=nplurals=2; plural=(n != 1)
Expand Down Expand Up @@ -118,6 +121,7 @@ mi=nplurals=2; plural=(n > 1)
mk=nplurals=2; plural= n==1 || n%10==1 ? 0 : 1
ml=nplurals=2; plural=(n != 1)
mn=nplurals=2; plural=(n != 1)
mni=nplurals=2; plural=(n != 1)
mnk=nplurals=3; plural=(n==0 ? 0 : n==1 ? 1 : 2
mr=nplurals=2; plural=(n != 1)
ms=nplurals=1; plural=0
Expand Down Expand Up @@ -158,7 +162,9 @@ ru=nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<1

# S

sat=nplurals=2; plural=(n != 1)
sco=nplurals=2; plural=(n != 1)
sd=nplurals=2; plural=(n != 1)
si=nplurals=2; plural=(n != 1)
sk=nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2
sl=nplurals=4; plural=(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n%100==4 ? 3 : 0)
Expand Down
Expand Up @@ -10,6 +10,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import org.junit.BeforeClass;
import org.slf4j.Logger;
Expand Down Expand Up @@ -293,7 +294,7 @@ public void splitLinesSkipAll()
private static final String[][] urlPatterns = new String[][] { new String[] { ",my,doc,id", "/my/doc/id" }, new String[] { ",my,,doc,id", "/my//doc/id" }, new String[] { "x+y", "x y" }, };

@DataProvider(name = "urlpatterns")
public String[][] createUrlPatterns()
private String[][] createUrlPatterns()
{
return urlPatterns;
}
Expand All @@ -310,4 +311,23 @@ public void encodeDocIds(String encoded, String decoded)
assertThat("Encoding " + decoded, resourceUtils.encodeDocId(decoded), is(encoded));
}

/**
* Tests that all plural information is readable
*/
@Test
public void readPluralForms()
{
ResourceUtils resourceUtils = new ResourceUtils();
resourceUtils.create();
Properties properties = ResourceUtils.getPluralForms();

for (Object key: properties.keySet())
{
String propKey = (String) key;
LocaleId localeId = LocaleId.fromJavaName(propKey);
resourceUtils.getPluralForms(localeId, false);
resourceUtils.getNPluralForms(null, localeId);
}
}

}

0 comments on commit dbdff9c

Please sign in to comment.