forked from sakaiproject/sakai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAK-23521 - Adding endorsed project from svn/contrib to Git. (sakaipr…
- Loading branch information
1 parent
d0e897a
commit b66db4d
Showing
19 changed files
with
1,227 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
Project Purpose: | ||
|
||
Basque and Mongolian languages are not fully supported in Java. e.g., DateFormat, NumberFormat, and | ||
locale name are not. | ||
This project is in order to support them by implementing the locale sensitive service provider which | ||
is offered in the Java Extension Mechanism. | ||
|
||
|
||
---------------------------------------------------------------------------------------------------- | ||
Usage: | ||
|
||
It is needed to store sakai-endorsed-i18n-x.x.jar into the proper location. | ||
|
||
For Tomcat 6 or 7, the target location is $CATALINA_HOME/endorsed. The following Maven builds command | ||
will store it there. | ||
|
||
mvn clean install -Dmaven.tomcat.home=$CATALINA_HOME | ||
|
||
|
||
For Tomcat 5.x, the target location is $CATALINA_HOME/common/endorsed. Please manually build and copy | ||
it there. | ||
|
||
mvn clean install | ||
copy target/sakai-endorsed-i18n-*.jar $CATALINA_HOME/common/endorsed/ | ||
|
||
|
||
Additionally, $JAVA_HOME/jre/lib/ext can be the target instead of the above locations. | ||
|
||
mvn clean install | ||
copy target/sakai-endorsed-i18n-*.jar $JAVA_HOME/jre/lib/ext/ | ||
|
||
|
||
---------------------------------------------------------------------------------------------------- | ||
Remarks: | ||
|
||
1.In order to enable the extension of the service provider, please use | ||
|
||
DateFormatSymbols.getInstance(locale); | ||
DecimalFormatSymbols.getInstance(locale); | ||
|
||
instead of | ||
|
||
new DateFormatSymbols(locale); | ||
new DecimalFormatSymbols(locale); | ||
|
||
in your code, because the latters do not support the extension. For example, the day of week in | ||
Section Info tool will not be displayed in Basque or Mongolian even if the extension was properly | ||
stored. It is because 'new DateFormatSymbols(locale);' is used in the tool in Sakai 2.9.1. | ||
|
||
2.The first day of week can not be extended by the service provider currently. It wiil be offered in | ||
Java 8 as java.util.spi.CalendarDataProvider. | ||
|
||
|
||
---------------------------------------------------------------------------------------------------- | ||
Adding more locales: | ||
|
||
If you'd like to add another unsupported locale except for Basque and Mongolian, please follow the | ||
steps below. | ||
|
||
1. Add the locale string into 'locales=' within src/resources/SakaiLocaleServiceProvider.config | ||
2. Create the resource bundle file as src/resources/SakaiLocaleServiceProvider_XX.properties | ||
3. Localize the content of the resource bundle. | ||
4. Build and store it into the proper location. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.sakaiproject.endorsed</groupId> | ||
<artifactId>endorsed</artifactId> | ||
<version>12-SNAPSHOT</version> | ||
</parent> | ||
|
||
<name>Sakai Endorsed I18n</name> | ||
<groupId>org.sakaiproject.endorsed</groupId> | ||
<artifactId>sakai-endorsed-i18n</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<deploy.target>endorsed</deploy.target> | ||
</properties> | ||
|
||
<build> | ||
<sourceDirectory>src/main/java</sourceDirectory> | ||
<testSourceDirectory>src/test/java</testSourceDirectory> | ||
<resources> | ||
<resource> | ||
<directory>${basedir}/src</directory> | ||
<includes> | ||
<include>META-INF/services/*</include> | ||
</includes> | ||
</resource> | ||
<resource> | ||
<directory>${basedir}/src/resources</directory> | ||
<includes> | ||
<include>*.properties</include> | ||
<include>*.config</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
</build> | ||
</project> |
1 change: 1 addition & 0 deletions
1
endorsed/i18n/src/META-INF/services/java.text.spi.DateFormatProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.sakaiproject.endorsed.i18n.spi.SakaiDateFormatProvider |
1 change: 1 addition & 0 deletions
1
endorsed/i18n/src/META-INF/services/java.text.spi.DateFormatSymbolsProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.sakaiproject.endorsed.i18n.spi.SakaiDateFormatSymbolsProvider |
1 change: 1 addition & 0 deletions
1
endorsed/i18n/src/META-INF/services/java.text.spi.DecimalFormatSymbolsProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.sakaiproject.endorsed.i18n.spi.SakaiDecimalFormatSymbolsProvider |
1 change: 1 addition & 0 deletions
1
endorsed/i18n/src/META-INF/services/java.text.spi.NumberFormatProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.sakaiproject.endorsed.i18n.spi.SakaiNumberFormatProvider |
1 change: 1 addition & 0 deletions
1
endorsed/i18n/src/META-INF/services/java.util.spi.LocaleNameProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.sakaiproject.endorsed.i18n.spi.SakaiLocaleNameProvider |
157 changes: 157 additions & 0 deletions
157
endorsed/i18n/src/main/java/org/sakaiproject/endorsed/i18n/spi/SakaiDateFormatProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
/********************************************************************************** | ||
* | ||
* Copyright (c) 2013 The Sakai Foundation | ||
* | ||
* Licensed under the Educational Community License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.osedu.org/licenses/ECL-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
**********************************************************************************/ | ||
|
||
package org.sakaiproject.endorsed.i18n.spi; | ||
|
||
import java.text.DateFormat; | ||
import java.text.SimpleDateFormat; | ||
import java.text.spi.DateFormatProvider; | ||
import java.util.Locale; | ||
|
||
/** | ||
* An implementation class for {@link DateFormatProvider} which provides a | ||
* localized {@link DateFormat}. | ||
* | ||
* @author Yuki Yamada | ||
* | ||
*/ | ||
public class SakaiDateFormatProvider extends DateFormatProvider { | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Locale[] getAvailableLocales() { | ||
return SakaiLocaleServiceProviderUtil.getAvailableLocales(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public DateFormat getDateInstance(final int style, final Locale locale) throws IllegalArgumentException, | ||
NullPointerException { | ||
return new SimpleDateFormat(getDateFormatString(style, locale), locale); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public DateFormat getDateTimeInstance(final int dateStyle, final int timeStyle, final Locale locale) | ||
throws IllegalArgumentException, NullPointerException { | ||
return new SimpleDateFormat(getDateFormatString(dateStyle, locale) + " " | ||
+ getTimeFormatString(timeStyle, locale), locale); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public DateFormat getTimeInstance(final int style, final Locale locale) throws IllegalArgumentException, | ||
NullPointerException { | ||
DateFormat dateFormat = null; | ||
|
||
String format = getTimeFormatString(style, locale); | ||
if (format != null) { | ||
dateFormat = new SimpleDateFormat(format, locale); | ||
} | ||
|
||
return dateFormat; | ||
} | ||
|
||
/** | ||
* Returns a date pattern with the given formatting style for the specified | ||
* locale. | ||
* | ||
* @param style the given date formatting style. | ||
* @param locale the desired locale. | ||
* @return a date pattern. | ||
* @throws IllegalArgumentException if <code>style</code> is invalid, or if | ||
* <code>locale</code> isn't available. | ||
* @throws NullPointerException if <code>locale</code> is <code>null</code>. | ||
*/ | ||
protected String getDateFormatString(final int style, final Locale locale) throws IllegalArgumentException, | ||
NullPointerException { | ||
if (locale == null) { | ||
throw new NullPointerException("locale:null"); | ||
} else if (!SakaiLocaleServiceProviderUtil.isAvailableLocale(locale)) { | ||
throw new IllegalArgumentException("locale:" + locale.toString()); | ||
} | ||
|
||
String key; | ||
switch (style) { | ||
case DateFormat.SHORT: | ||
key = "DateFormat.SHORT"; | ||
break; | ||
case DateFormat.MEDIUM: | ||
key = "DateFormat.MEDIUM"; | ||
break; | ||
case DateFormat.LONG: | ||
key = "DateFormat.LONG"; | ||
break; | ||
case DateFormat.FULL: | ||
key = "DateFormat.FULL"; | ||
break; | ||
default: | ||
throw new IllegalArgumentException("style:" + style); | ||
} | ||
|
||
return SakaiLocaleServiceProviderUtil.getString(key, locale); | ||
} | ||
|
||
/** | ||
* Returns a time pattern with the given formatting style for the specified | ||
* locale. | ||
* | ||
* @param style the given time formatting style. | ||
* @param locale the desired locale. | ||
* @return a time pattern. | ||
* @throws IllegalArgumentException if <code>style</code> is invalid, or if | ||
* <code>locale</code> isn't available. | ||
* @throws NullPointerException if <code>locale</code> is <code>null</code>. | ||
*/ | ||
protected String getTimeFormatString(final int style, final Locale locale) throws IllegalArgumentException, | ||
NullPointerException { | ||
if (locale == null) { | ||
throw new NullPointerException("locale:null"); | ||
} else if (!SakaiLocaleServiceProviderUtil.isAvailableLocale(locale)) { | ||
throw new IllegalArgumentException("locale:" + locale.toString()); | ||
} | ||
|
||
String key; | ||
switch (style) { | ||
case DateFormat.SHORT: | ||
key = "TimeFormat.SHORT"; | ||
break; | ||
case DateFormat.MEDIUM: | ||
key = "TimeFormat.MEDIUM"; | ||
break; | ||
case DateFormat.LONG: | ||
key = "TimeFormat.LONG"; | ||
break; | ||
case DateFormat.FULL: | ||
key = "TimeFormat.FULL"; | ||
break; | ||
default: | ||
throw new IllegalArgumentException("style:" + style); | ||
} | ||
|
||
return SakaiLocaleServiceProviderUtil.getString(key, locale); | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
...i18n/src/main/java/org/sakaiproject/endorsed/i18n/spi/SakaiDateFormatSymbolsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/********************************************************************************** | ||
* | ||
* Copyright (c) 2013 The Sakai Foundation | ||
* | ||
* Licensed under the Educational Community License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.osedu.org/licenses/ECL-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
**********************************************************************************/ | ||
|
||
package org.sakaiproject.endorsed.i18n.spi; | ||
|
||
import java.text.DateFormatSymbols; | ||
import java.text.spi.DateFormatSymbolsProvider; | ||
import java.util.Locale; | ||
|
||
/** | ||
* An implementation class for {@link DateFormatSymbolsProvider} which provides a | ||
* localized {@link DateFormatSymbols}. | ||
* | ||
* @author Yuki Yamada | ||
* | ||
*/ | ||
public class SakaiDateFormatSymbolsProvider extends DateFormatSymbolsProvider { | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Locale[] getAvailableLocales() { | ||
return SakaiLocaleServiceProviderUtil.getAvailableLocales(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public DateFormatSymbols getInstance(final Locale locale) throws IllegalArgumentException, NullPointerException { | ||
if (locale == null) { | ||
throw new NullPointerException("locale:null"); | ||
} else if (!SakaiLocaleServiceProviderUtil.isAvailableLocale(locale)) { | ||
throw new IllegalArgumentException("locale:" + locale.toString()); | ||
} | ||
|
||
DateFormatSymbols symbols = new DateFormatSymbols(); | ||
symbols.setEras(new String[] { | ||
SakaiLocaleServiceProviderUtil.getString("Eras.BC", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Eras.AD", locale) }); | ||
symbols.setMonths(new String[] { | ||
SakaiLocaleServiceProviderUtil.getString("Months.JAN", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Months.FEB", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Months.MAR", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Months.APR", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Months.MAY", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Months.JUN", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Months.JUL", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Months.AUG", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Months.SEP", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Months.OCT", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Months.NOV", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Months.DEC", locale) }); | ||
symbols.setShortMonths(new String[] { | ||
SakaiLocaleServiceProviderUtil.getString("ShortMonths.JAN", locale), | ||
SakaiLocaleServiceProviderUtil.getString("ShortMonths.FEB", locale), | ||
SakaiLocaleServiceProviderUtil.getString("ShortMonths.MAR", locale), | ||
SakaiLocaleServiceProviderUtil.getString("ShortMonths.APR", locale), | ||
SakaiLocaleServiceProviderUtil.getString("ShortMonths.MAY", locale), | ||
SakaiLocaleServiceProviderUtil.getString("ShortMonths.JUN", locale), | ||
SakaiLocaleServiceProviderUtil.getString("ShortMonths.JUL", locale), | ||
SakaiLocaleServiceProviderUtil.getString("ShortMonths.AUG", locale), | ||
SakaiLocaleServiceProviderUtil.getString("ShortMonths.SEP", locale), | ||
SakaiLocaleServiceProviderUtil.getString("ShortMonths.OCT", locale), | ||
SakaiLocaleServiceProviderUtil.getString("ShortMonths.NOV", locale), | ||
SakaiLocaleServiceProviderUtil.getString("ShortMonths.DEC", locale) }); | ||
symbols.setWeekdays(new String[] {"", | ||
SakaiLocaleServiceProviderUtil.getString("Weekdays.SUN", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Weekdays.MON", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Weekdays.TUE", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Weekdays.WED", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Weekdays.THU", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Weekdays.FRI", locale), | ||
SakaiLocaleServiceProviderUtil.getString("Weekdays.SAT", locale) }); | ||
symbols.setShortWeekdays(new String[] {"", | ||
SakaiLocaleServiceProviderUtil.getString("ShortWeekdays.SUN", locale), | ||
SakaiLocaleServiceProviderUtil.getString("ShortWeekdays.MON", locale), | ||
SakaiLocaleServiceProviderUtil.getString("ShortWeekdays.TUE", locale), | ||
SakaiLocaleServiceProviderUtil.getString("ShortWeekdays.WED", locale), | ||
SakaiLocaleServiceProviderUtil.getString("ShortWeekdays.THU", locale), | ||
SakaiLocaleServiceProviderUtil.getString("ShortWeekdays.FRI", locale), | ||
SakaiLocaleServiceProviderUtil.getString("ShortWeekdays.SAT", locale) }); | ||
symbols.setAmPmStrings(new String[] { | ||
SakaiLocaleServiceProviderUtil.getString("AmPmStrings.AM", locale), | ||
SakaiLocaleServiceProviderUtil.getString("AmPmStrings.PM", locale) }); | ||
symbols.setLocalPatternChars(SakaiLocaleServiceProviderUtil.getString( | ||
"LocalPatternChars", locale)); | ||
|
||
// Not support Zone Strings | ||
|
||
return symbols; | ||
} | ||
} |
Oops, something went wrong.