当前位置:网站首页>Chapter 16 string localization and message Dictionary (2)
Chapter 16 string localization and message Dictionary (2)
2022-07-04 14:25:00 【yaoxin521123】
List of articles
Chapter 16 String localization and message dictionary ( Two )
XML Message file
XML Message file is the export of message dictionary . This is also the required format for any message you want to import .
Whenever possible ,XML Message files should use UTF-8 code . however , In some cases , Developers or translators may use local platform coding , for example shift-jis, For easy editing XML Message file . No matter what XML What kind of encoding is used for the document , The application's locale must support it , And it must be able to express the message of the language .
XML Message files may contain messages in one language and multiple domains .
Element
<MsgFile> The element is XML Top level container for message files , There is only one per file <MsgFile> Elements .
<MsgFile> The element has a required attribute ,Language. <MsgFile>Language The value of the attribute is an all lowercase RFC1766 Code , The language used to identify the file . It consists of one or more parts : Main language labels ( for example en or ja) Optionally followed by a hyphen (-) And secondary language tags (en-gb or ja-jp).
In the following example , This language is “en”( English ).
<?xml version="1.0" encoding="utf-8" ?>
<MsgFile Language="en">
<MsgDomain Domain="sample">
<Message Id="source">Source</Message>
<Message Id="menu">Samples Menu</Message>
</MsgDomain>
</MsgFile>
<MsgFile> Must contain at least one <MsgFile> Elements . It may contain more than one <MsgFile>.
Element
<MsgDomain> The element has a required attribute field . <MsgDomain> Domain The value of the attribute is one of the domain names used to organize messages in the application .
whatever <MsgDomain> Elements can contain zero or more <MsgDomain> Elements .
Element
<Message> The element has a required attribute ,Id. <Message> Id The value of the attribute is the message used to organize messages in the application ID One of the strings .
whatever <Message> Elements can contain a text string . A string can consist of any of the following , Alone or in combination :
- Simple text allowed by file format
- Replace parameters
%1、%2、%3or%4 HTMLFormat- ObjectScript Format string expression
The following example uses %1、%2、 For bold format HTML The tag and two consecutive double quotation mark characters represent a single double quotation mark ObjectScript String conventions :
<Message>
The session $Username="<b>%1</b>" $Roles="<b>%2</b>"
</Message>
Manage message dictionaries
This section summarizes the most commonly used when using message dictionaries %Library.MessageDictionary Method . You can use these methods :
- from
XMLMessage file import message - Export messages to XML Message file
- Delete a message from the message dictionary
- List messages in the message dictionary
Import XML Message file
To import XML Message file , Please open the terminal and perform the following operations :
- Change to the namespace of the application being developed :
set $namespace = "myNamespace"
- Run the Import command . By default , Each language is in a separate XML In the message file , Locale name at the end of file name . therefore :
- Only those messages in a specific language can be imported :
SET file="C:\myLocation\Messages_ja-jp.xml"
DO ##class(%Library.MessageDictionary).Import(file)
- perhaps , Import multiple languages for the same application :
SET myFiles="C:\myLocation"
DO ##class(%Library.MessageDictionary).ImportDir(myFiles,"d")
- Check
^IRIS.MsgGlobal variables to see the results .
The following topics summarize these two import methods .
Import specific XML Message file
%Library.MessageDictionary Class method Import() With the following signature :
classmethod Import(filepath As %String, flag As %String = "") returns %Status
filepath- Import byfilepathdesignatedXMLMessage file . Make sure that only XML Message file , Because of the others XML The file will generate errors .flag- ( Optional ) Provided ,dsign ( Show ) Indicates that the terminal console will display a confirmation message when importing files . otherwise , No confirmation .
Import all in the directory XML Message file
%Library.MessageDictionary Class method ImportDir() With the following signature :
classmethod ImportDir(directory As %String, flag As %String = "") returns %Status
directory- Import all... In the specified directoryXMLMessage file .flag- ( Optional ) Provided ,dsign ( Show ) Indicates that the terminal console will display a confirmation message when importing files . otherwise , No confirmation .
export XML Message file
To export parts of the message dictionary to XML Message file , Please perform the following operations in the terminal :
- Change to the namespace of the application being developed :
set $namespace = "myNamespace"
- Identify the output file and its location :
SET file="C:\myLocation\Messages.xml"
- Run the export command :
- It may be feasible to export only those messages in a specific domain :
DO ##class(%Library.MessageDictionary).ExportDomainList(file,"myDomain")
- perhaps , Export all messages in the namespace :
DO ##class(%Library.MessageDictionary).Export(file)
Export a specific domain in one language
%Library.MessageDictionary Class method ExportDomainList() With the following signature :
classmethod ExportDomainList(file As %String, domainList As %String, language As %String) returns %Status
file- ( It's necessary ) Output file name template in this format :filepath.extThe actual output file name appends the language value to the extensionextIn the file path of .domainList- ( Optional ) Comma separated list of fields to export .language- ( Optional ) Export only the specified language . The value must be all lowercaseRFC1766Code . If not provided , Then this value defaults to the system default language , This value is stored in a special variable$$$DefaultLanguagein .
Export all domains in a specific language
%Library.MessageDictionary Class method Export() With the following signature :
file- ( It's necessary ) Output file name template in this format :filepath.extThe name of the output file isfilepathlanguage-code.extfor example , If the document isc:/temp/mylang_.txtAnd language includes language codeja- jp, Then one of the output files is namedc:/temp/mylang_ja-jp.txtlanguages- ( Optional ) Comma separated list of language codes . Each value in the list must be all lowercaseRFC1766Code . If no language is specified or empty , Then export all languages in the database . Each language is used asfileThe Convention of parameter description is exported to a separate file .flag- ( Optional ) Provided , bessign ( System ) Indicates that the system message dictionary should be exported in addition to the application message dictionary . otherwise , Export only the application message dictionary .
removal message
To delete a message , Please use the following command :
Set status = ##class(%MessageDictionary).Delete(languages,flag)
Languages are optional comma separated lists of languages . If no language is specified , Delete all languages . The default is to delete only application messages . s sign ( System ) It's an optional logo , Indicates whether system messages are also deleted . The message name associated with the containing file is always deleted , But the include file will not . And support d sign ( Show ).
List messages
To get a list of all languages that have loaded messages for the specified domain , Please use GetLanguages() Method :
Set list = ##class(%MessageDictionary).GetLanguages(domain,flag)
GetLanguages() By standard RFC1766 Format returns language code %ListofDateTypes Format list , All lowercase . If a domain is specified , Then the list only contains the languages that exist in the specified domain . otherwise , All languages are included in the list . s sign ( System ) It's an optional logo , Indicates whether to return the language supported by the system or application message . The default is the language in which the application message is returned . And support d sign ( Show ).
边栏推荐
- 92.(cesium篇)cesium楼栋分层
- GCC [6] - 4 stages of compilation
- Mongodb commonly used 28 query statements (forward)
- R语言使用dplyr包的group_by函数和summarise函数基于分组变量计算目标变量的均值、标准差
- R language uses the DOTPLOT function of epidisplay package to visualize the frequency of data points in different intervals in the form of point graph, and uses the by parameter to specify the groupin
- 【MySQL从入门到精通】【高级篇】(五)MySQL的SQL语句执行流程
- Remove duplicate letters [greedy + monotonic stack (maintain monotonic sequence with array +len)]
- LifeCycle
- 流行框架:Glide的使用
- 【信息检索】分类和聚类的实验
猜你喜欢

gin集成支付宝支付

(1)性能调优的标准和做好调优的正确姿势-有性能问题,上HeapDump性能社区!

10.(地图数据篇)离线地形数据处理(供Cesium使用)

Digi XBee 3 RF: 4个协议,3种封装,10个大功能

【信息检索】链接分析

【MySQL从入门到精通】【高级篇】(四)MySQL权限管理与控制

flink sql-client. SH tutorial

Data center concept
![[FAQ] summary of common causes and solutions of Huawei account service error 907135701](/img/43/1a9786c89a5ab21d1fb8903cb7b77e.png)
[FAQ] summary of common causes and solutions of Huawei account service error 907135701

Xcode 异常图片导致ipa包增大问题
随机推荐
ML之shap:基于boston波士顿房价回归预测数据集利用shap值对XGBoost模型实现可解释性案例
SqlServer函数,存储过程的创建和使用
Learning projects are self-made, and growth opportunities are self created
【信息检索】链接分析
递增的三元子序列[贪心训练]
Leetcode T47: 全排列II
ARouter的使用
gin集成支付宝支付
How to package QT and share exe
Test process arrangement (2)
Install and use MAC redis, connect to remote server redis
利用Shap值进行异常值检测
92.(cesium篇)cesium楼栋分层
ML之shap:基于boston波士顿房价回归预测数据集利用Shap值对LiR线性回归模型实现可解释性案例
R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用stress.col参数指定强调线的id子集的颜色(色彩)
Leetcode 61: 旋转链表
Incremental ternary subsequence [greedy training]
Chapter 17 process memory
Ws2818m is packaged in cpc8. It is a special circuit for three channel LED drive control. External IC full-color double signal 5v32 lamp programmable LED lamp with outdoor engineering
Ruiji takeout notes