如何使用Lotusscript和SSJS库中的xPages转换文件 [英] How to use xPages translation files from Lotusscript and SSJS libraries

查看:108
本文介绍了如何使用Lotusscript和SSJS库中的xPages转换文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用资源包将我所有的xpage都翻译成不同的语言. 这对于在xPages中翻译标签等非常有用.

I am using resource bundles to translate all my xpages into different languages. this works great for translating labels etc in xPages.

但是,我确实在数据库中具有向用户发送邮件的Lotusscript代理和服务器端javascript代码,我希望也可以使用翻译文件来翻译这些电子邮件.

I do however have Lotusscript agents and server side javascript code in the database that send mail to users and I want these emails to also be translated using the translation files.

所以我的问题很简单.是否可以从SSJS脚本库和Lotusscript代理读取翻译文件.如果是这样,请让我知道如何?

so my question is simple. is it possible to read the translation files from SSJS scriptlibraries and Lotusscript agents. If so please let me know how?

下面的图片显示了我所有的翻译文件,每种语言一个.

string _ *.properties

string_*.properties

推荐答案

在SSJS中,您可以使用 getResourceAsStream 方法访问属性文件.

In SSJS you can access the property files with getResourceAsStream method.

var data = "";
var ex = facesContext.getExternalContext();
var io:java.io.InputStream = ex.getResourceAsStream("strings_en.properties");

var i;
do{
   i = io.read();
   data += @Char(i)
}while( i != (-1) ) 

变量 data 现在包含整个* strings_en. properties 文件.

The variable data contains now the whole *strings_en.properties file.

可以在下面找到直接在 java.util.Properties 实例中加载属性的示例:

An example to load the properties directly in a java.util.Properties instance can be found here:

http://openntf.org/XSnippets.nsf /snippet.xsp?id=access-.properties-files

在LS中,它更复杂:

  1. 您需要使用 $ FileNames 字段作为键的设计元素的查找视图
  2. 这使您可以搜索属性文件.
  3. 然后您可以使用dxl导出设计文档
  4. 在导出的DXL中,您必须搜索 $ FileData
  5. 该项目中有BASE64编码的属性文件
  6. 对其进行解码,跳过前30个字符(标题信息,例如RT的大小)
  7. 逐行解析
  1. You need a lookup view for the design elements, with the field $FileNames as key
  2. This allows you to search for the property file.
  3. Then you can export the design document with dxl
  4. In the exported DXL, you have to search for the $FileData item
  5. In the item there is the BASE64 encoded property file
  6. Decode it, skip the first 30 characters (header informations like size of the RT)
  7. Parse it line by line

这篇关于如何使用Lotusscript和SSJS库中的xPages转换文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆