浏览 4902 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-05-20
论坛就选开源的mvnForum,我看用的人还不少。 集成的第一件事就是汉化mvnForum.前台没有话说,OOB的就支持中文。关键是管理页面需要汉化。 一 资源文件汉化 在网上找了很久,有网友汉化的资源文件。但都是针对1.0.2版本的。最新的1.1版好像加了不少功能, 资源文件里加了好多条目在1.0.2里没有。没办法只好自立更生了。 二 freemarker模板汉化 mvnForum使用了几个FTL模板,其中viewmemberpermissions.ftl里有hardcode,要改成国际化。 <#assign i = 1 > <#list Rows as row> <#if row.RowType == "Header"> <table class="tborder" width="95%" cellspacing="1" cellpadding="3" align="center"> <tr class="portlet-section-header" align="center"> <td nowrap>${bundle("suncms.Forum")}</td> <td nowrap>${bundle("suncms.Forum.Edit")}</td> <td nowrap>${bundle("suncms.Forum.Delete")}</td> <td nowrap>${bundle("suncms.Forum.Assign")}</td> <td nowrap>${bundle("suncms.Thread")}</td> <td nowrap>${bundle("suncms.Thread.Add")}</td> <td nowrap>${bundle("suncms.Thread.Moderate")}</td> <td nowrap>${bundle("suncms.Post")}</td> <td nowrap>${bundle("suncms.Post.Read")}</td> <td nowrap>${bundle("suncms.Post.Add")}</td> <td nowrap>${bundle("suncms.Post.Edit_Own")}</td> <td nowrap>${bundle("suncms.Post.Edit_Any")}</td> <td nowrap>${bundle("suncms.Post.Delete")}</td> <td nowrap>${bundle("suncms.Attachment")}</td> <td nowrap>${bundle("suncms.Attachment.Add")}</td> <td nowrap>${bundle("suncms.Attachment.Get")}</td> <td nowrap>${bundle("suncms.Poll")}</td> <td nowrap>${bundle("suncms.Poll.Add")}</td> <td nowrap>${bundle("suncms.Poll.Edit_Own")}</td> <td nowrap>${bundle("suncms.Poll.Edit_Any")}</td> <td nowrap>${bundle("suncms.Poll.Delete")}</td> </tr> </#if> <#if row.RowType == "Category"> <#assign i = 1 > <tr class="portlet-section-subheader"> <td colspan="21"> <b>${row.CategoryName}</b> </td> </tr> <#if row.Empty > <tr class="portlet-section-body"><td colspan="21" align="center">${row.no_forum}</td></tr> </#if> </#if> <#if row.RowType == "Forum"> <tr <#if i%2 == 1> class="portlet-section-body" <#else> class="portlet-section-alternate" </#if> align="center"> <td align="left">${row.ForumName}</td> <td><@check permission=row.EditForum/></td> <td><@check permission=row.DeleteForum/></td> <td><@check permission=row.AssignForum/></td> <td class="messageTextBold">${bundle("suncms.Thread")} »</td> <td><@check permission=row.AddThread/></td> <td><@check permission=row.ModerateThread/></td> <td class="messageTextBold">${bundle("suncms.Post")} »</td> <td><@check permission=row.ReadPost/></td> <td><@check permission=row.AddPost/></td> <td><@check permission=row.EditOwnPost/></td> <td><@check permission=row.EditAnyPost/></td> <td><@check permission=row.DeletePost/></td> <td class="messageTextBold">${bundle("suncms.Attachment")} »</td> <td><@check permission=row.AddAttachment/></td> <td><@check permission=row.GetAttachment/></td> <td class="messageTextBold">${bundle("suncms.Poll")} »</td> <td><@check permission=row.AddPoll/></td> <td><@check permission=row.EditOwnPoll/></td> <td><@check permission=row.EditAnyPoll/></td> <td><@check permission=row.DeletePoll/></td> </tr> <#assign i = i+1> </#if> <#if row.RowType == "Footer"> <#if row.checkNoCategory> <tr class="portlet-section-body"> <td colspan="21" align="center">${row.no_category}</td> </tr> </#if> </table> </#if> </#list> <#macro check permission> <#if permission> <font color="#008000">Yes</font> <#else> <font color="#FF0080">No</font> </#if> </#macro 对应的要修改ftlCategoryTreeListener.java,把国际化信息传到模板中 public void init(Template template) { this.template = template; html = new StringWriter(); root = new HashMap(); root.put("Rows", rows); ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle("mvnForum_i18n"); ResourceBundleModel rsbm = new ResourceBundleModel(RESOURCE_BUNDLE,new BeansWrapper()); root.put("bundle", rsbm); } 三 权限管理的汉化 汉化参照http://www.shorelinesolution.com/forum/viewthread?thread=137 里做的。同样的他也是基于1.0.2 做的,他提供的代码直接在1.1里使用会报错,原因也是条目比1.1里的少。修改很简单,把1.1里的AbstractPermission类里的getDescription方法拷出来修改即可。 这时 权限管理界面都是中文了,但是有几个图片的ALT信息还是英文的,继续: 修改MyUtil。java中的getIndividualPermission方法,把hardcode的英文换成国际化。为了不影响其它代码,把该方法复制 改名一份。 public static StringBuffer getIndividualPermissionFsunCMS(int combinePers, boolean globalPermission,String localeName) throws BadInputException { StringBuffer indivialPermissions = new StringBuffer(); int[] individualForumPermissionArray = null; Locale locale = null; if(localeName.length()>2){ String language = localeName.substring(0,2); String country = localeName.substring(3); locale = new Locale(language, country); } else { locale = new Locale(localeName); } switch (combinePers) { case MVNForumPermission.PERMISSION_SYSTEM_ADMIN: //indivialPermissions.append("This permission includes all individual permissions"); String stmp=MVNForumResourceBundle.getString(locale, "suncms.permission.alt_all"); indivialPermissions.append(stmp); break; case MVNForumPermission.PERMISSION_FORUM_ADMIN: if (globalPermission) { individualForumPermissionArray = MVNForumPermission.individualForumAdminPermissionArray; } else { individualForumPermissionArray = MVNForumPermission.individualForumAdminLimitPermissionArray; } break; case MVNForumPermission.PERMISSION_FORUM_MODERATOR: if (globalPermission) { individualForumPermissionArray = MVNForumPermission.individualForumModeratorPermissionArray; } else { individualForumPermissionArray = MVNForumPermission.individualForumModeratorLimitPermissionArray; } break; case MVNForumPermission.PERMISSION_POWER_USER: if (globalPermission) { individualForumPermissionArray = MVNForumPermission.individualPowerUserPermissionArray; } else { individualForumPermissionArray = MVNForumPermission.individualPowerUserLimitPermissionArray; } break; case MVNForumPermission.PERMISSION_NORMAL_USER: if (globalPermission) { individualForumPermissionArray = MVNForumPermission.individualNormalUserPermissionArray; } else { individualForumPermissionArray = MVNForumPermission.individualNormalUserLimitPermissionArray; } break; case MVNForumPermission.PERMISSION_LIMITED_USER: if (globalPermission) { individualForumPermissionArray = MVNForumPermission.individualLimitedUserPermissionArray; } else { individualForumPermissionArray = MVNForumPermission.individualLimitedUserLimitPermissionArray; } break; default: throw new BadInputException("This permission is invalid"); } // end switch if (individualForumPermissionArray != null) { //indivialPermissions.append("This permission includes the individual permission: <br />"); String stmp=MVNForumResourceBundle.getString(locale, "suncms.permission.alt"); indivialPermissions.append(stmp+" <br />"); indivialPermissions.append("<ul>"); for (int i = 0; i < individualForumPermissionArray.length; i++) { //indivialPermissions.append("<li>").append(AbstractPermission.getDescription(individualForumPermissionArray[i])).append("</li>"); indivialPermissions.append("<li>").append(LocalizedPermission.getDescription(individualForumPermissionArray[i],localeName)).append("</li>"); } indivialPermissions.append("</ul>"); } return indivialPermissions; } 四 修改JSP页面。 这个很简单,看到hardcode的英文,就用<fmt:message key="mvnforum.common.not_applicable"/> 语句换成国际化即可。 至此汉化完成。下一步集成用户。 相关文件: 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2008-05-21
推荐下Jforum,很不错的东西,前台和后台都支持中文,而且功能也很强大,
|
|
返回顶楼 | |
发表时间:2008-05-31
目前见到的最好的mvnforum模板
http://bbs.jnvideo.cn |
|
返回顶楼 | |
发表时间:2008-06-30
当然是JForum好,可以参考这里的介绍:http://www.javaread.com/article/show/94
|
|
返回顶楼 | |
发表时间:2008-07-22
感觉JForum还不错,如果支持从其他论坛系统迁移数据就好了。
|
|
返回顶楼 | |
发表时间:2008-07-22
感觉JForum还不错,如果支持从其他论坛系统迁移数据就好了。
|
|
返回顶楼 | |