You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

This document relates to Grouper and internationalization.  Note,

Note, my environment is windows, mysql, tomcat.

Grouper and UTF-8

For Grouper to handle utf-8 characters:

  • Make sure java starts with this setting: -Dfile.encoding=UTF-8   for example, in tomcat, put something like this in your startup script:

    export JAVA_OPTS="-server -Xms50M -Xmx200M -XX:MaxPermSize=95M -Dfile.encoding=UTF-8"
  • Make sure URIEncoding is set to UTF-8 in the server.xml in tomcat in the Connector element, here is an example

    <Connector port="8111" protocol="AJP/1.3" request.tomcatAuthentication="false"
            URIEncoding="UTF-8" />
  • Make sure your database tables are using UTF-8.  If not, e.g. for mysql, you might need to SQL dump, delete the DB, create with default UTF-8 bin collation, and import the SQL.
  • Make sure your connect string to the database is configured to use UTF-8 (if applicable).  For mysql, here is an example (see the stuff after the question mark).  Note, in windows mysql this isnt necessary

    hibernate.connection.url = jdbc:mysql://localhost:3306/grouper_v2_2?CharSet=utf8&useUnicode=true&characterEncoding=utf8
    
    

 

Grouper v2.2+ translations

If you want to add a localization to the grouper UI text (example for french):

Add this to your grouper-ui.properties (index must increment from the base file:

# language for this bundle
grouper.text.bundle.1.language = fr

# country for this bundle
grouper.text.bundle.1.country = fr

# filename in the package grouperText that is before the .base.properties, and .properties
grouper.text.bundle.1.fileNamePrefix = grouperText/grouper.text.fr.fr

Add a grouperText/grouper.text.fr.fr.base.properties and grouper.text.fr.fr.properties

Have this at the top of grouper.text.fr.fr.base.properties

########################################
## Config chaining hierarchy
########################################

# comma separated config files that override each other (files on the right override the left)
# each should start with file: or classpath:
# e.g. classpath:grouperText/grouper.text.en.us.base.properties, file:c:/temp/grouperText/grouper.text.en.us.properties
text.config.hierarchy = classpath:grouperText/grouper.text.fr.fr.base.properties, classpath:grouperText/grouper.text.fr.fr.properties

Change your browser to prefer french from france, (either wait a bit or bounce app server), and hit the UI and you should see your french text

Code changes

In the tomcat server.xml  Edit the <Connectors to have uri encoding of utf8, e.g.  <Connector  URIEncoding="UTF-8"

edu.internet2.middleware.grouper.ui.util.HttpContentType.java

FROM:

  TEXT_XML("text/xml"),
 
  /** text html content type */
  TEXT_HTML("text/html"),
 
  /** application json content type */
  APPLICATION_JSON("application/json"),

TO:

  TEXT_XML("text/xml;charset=utf-8"),
 
  /** text html content type */
  TEXT_HTML("text/html"),
 
  /** application json content type */
  APPLICATION_JSON("application/json;charset=utf-8"),

Insert some subjects in the DB/LDAP (if you dont already have some in an existing source, note, you need the default source enabled if you use this sql):

insert into subject (subjectId, subjectTypeId, name) values ("joñ", "person", "joñ");

insert into subjectattribute (subjectId, name, value, searchValue) values ("joñ", "description", "Joñ", "joñ");
insert into subjectattribute (subjectId, name, value, searchValue) values ("joñ", "loginid", "joñ", "joñ");
insert into subjectattribute (subjectId, name, value, searchValue) values ("joñ", "name", "Joñ", "joñ");
commit;

grouper/grouper-ui.base.properties:

 ###################################
 ## Internationalization
 ###################################

 # as of 2014/09/01 and Grouper 2.2.1+, this should be false
 convertInputToUtf8 = false

edu.internet2.middleware.grouper.j2ee.GrouperRequestWrapper:

FROM:

  public String getParameter(String name) {
 
    if (!this.multipart) {
      
      return this.wrapped.getParameter(name);
    }
 
    Object objectSubmitted = this.parameterMap.get(name);


TO:

  public String getParameter(String name) {
 
    if (!this.multipart) {
      String param = this.wrapped.getParameter(name);
      if (param != null && StringUtils.equals("GET", this.getMethod()) && TagUtils.mediaResourceBoolean("convertInputToUtf8", true)) {
        try {
          byte[] bytes = param.getBytes("ISO-8859-1");
          param = new String(bytes, "UTF-8");
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }
      return param;
    }
 
    Object objectSubmitted = this.parameterMap.get(name);

edu.internet2.middleware.grouper.ui.GrouperUiFilter:

FROM:

   public void doFilter(ServletRequest servletRequest, ServletResponse response,
       FilterChain filterChain) throws IOException, ServletException {

     GrouperRequestWrapper httpServletRequest = null;
    
     try {
      
       httpServletRequest = new GrouperRequestWrapper((HttpServletRequest) servletRequest);


 TO:

   public void doFilter(ServletRequest servletRequest, ServletResponse response,
       FilterChain filterChain) throws IOException, ServletException {

     GrouperRequestWrapper httpServletRequest = null;
    
     try {
      
       servletRequest.setCharacterEncoding("UTF-8");
      
       httpServletRequest = new GrouperRequestWrapper((HttpServletRequest) servletRequest);


sdf

Testing

  • Create folder on new UI with special char
  • Create group in that folder with special char
  • Click on the folder breadcrumb to test is
  • Search for the folder in a folder combobox, select it
  • Put accented chars in the grouper text file and see those on the UI
  • Do the tests below too

Text on admin UI

custom/nav.properties

groups.action.show-summary=Group summáry

Looks like this on Group screen:



Text on Lite UI

Set this on custom/media.properties

ui-lite.link-from-admin-ui = true

login.ui-lite.show-link = true

custom/nav.properties

simpleMembershipUpdate.updateTitle=Group mêmbership update lite


Tooltip on the lite UI

custom/nav.properties

 tooltipTargetted.simpleMembershipUpdate.viewInAdminUi=Switçh to the Admin UI for a more complete set of features


Menu item lite

custom/nav.properties

simpleMembershipUpdate.advancedMenuShowMemberFilter=Séarch for member


Menu tooltip lite

custom/nav.properties

simpleMembershipUpdate.advancedMenuShowMemberFilterTooltip=Sèlecting this option will show a search box above the membership list where you can search for members in this group


Lite combo and submitting



sdf

  • No labels