当前位置:网站首页>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
、%3
or%4
HTML
Format- 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
XML
Message 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.Msg
Global 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 byfilepath
designatedXML
Message file . Make sure that only XML Message file , Because of the others XML The file will generate errors .flag
- ( Optional ) Provided ,d
sign ( 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 directoryXML
Message file .flag
- ( Optional ) Provided ,d
sign ( 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.ext
The actual output file name appends the language value to the extensionext
In 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 lowercaseRFC1766
Code . If not provided , Then this value defaults to the system default language , This value is stored in a special variable$$$DefaultLanguage
in .
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.ext
The name of the output file isfilepathlanguage-code.ext
for example , If the document isc:/temp/mylang_.txt
And language includes language codeja- jp
, Then one of the output files is namedc:/temp/mylang_ja-jp.txt
languages
- ( Optional ) Comma separated list of language codes . Each value in the list must be all lowercaseRFC1766
Code . If no language is specified or empty , Then export all languages in the database . Each language is used asfile
The Convention of parameter description is exported to a separate file .flag
- ( Optional ) Provided , bes
sign ( 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 ).
边栏推荐
- 学内核之三:使用GDB跟踪内核调用链
- Gorm data insertion (transfer)
- 基于51单片机的超声波测距仪
- Talk about 10 tips to ensure thread safety
- golang fmt. Printf() (turn)
- GCC [6] - 4 stages of compilation
- PyTorch的自动求导机制详细解析,PyTorch的核心魔法
- ML:SHAP值的简介、原理、使用方法、经典案例之详细攻略
- sharding key type not supported
- STM32F1与STM32CubeIDE编程实例-MAX7219驱动8位7段数码管(基于GPIO)
猜你喜欢
Excel快速合并多行数据
DDD application and practice of domestic hotel transactions -- Code
flink sql-client. SH tutorial
第十七章 进程内存
Talk about 10 tips to ensure thread safety
【信息检索】分类和聚类的实验
【FAQ】華為帳號服務報錯 907135701的常見原因總結和解决方法
Use of tiledlayout function in MATLAB
Vscode common plug-ins summary
Leetcode 61: rotating linked list
随机推荐
nowcoder重排链表
实时数据仓库
【信息检索】链接分析
Some problems and ideas of data embedding point
LiveData
[FAQ] summary of common causes and solutions of Huawei account service error 907135701
测试流程整理(3)
Data center concept
MySQL的存储过程练习题
[matlab] summary of conv, filter, conv2, Filter2 and imfilter convolution functions
Use of tiledlayout function in MATLAB
MySQL之详解索引
leetcode:6110. 网格图中递增路径的数目【dfs + cache】
sql优化之查询优化器
R语言使用lattice包中的bwplot函数可视化箱图(box plot)、par.settings参数自定义主题模式
The implementation of OSD on rk1126 platform supports color translucency and multi-channel support for Chinese
第十七章 进程内存
产业互联网则具备更大的发展潜能,具备更多的行业场景
The game goes to sea and operates globally
codeforce:C. Sum of Substrings【边界处理 + 贡献思维 + 灵光一现】