gpt4 book ai didi

c# - String.Format ("Your query {0} with {1} Placeholders", theQuery, results.Count) 在 XSLT 中等效

转载 作者:太空狗 更新时间:2023-10-29 23:18:44 26 4
gpt4 key购买 nike

在 XSLT 中是否有与字符串格式等效的函数?

我正在使用 umbraco 开发一个多语言网站。我不知道需要什么语言,但事实上,一种语言可以对单词进行不同的排序,例如

English “您的查询‘Duncan’匹配了 5 个结果。”可以逐字翻译成“5 个结果与‘Duncan’查询匹配”。

出于这个原因,在我的 umbraco 翻译中包含“您的查询”、“匹配”和“结果”项是不可行的。如果我要将其作为 C# 的用户控件,我会让翻译人员提供一个字典项,例如“您的查询‘{0}’匹配了 {1} 个结果”。

最佳答案

Is there an equivalent function to string format in XSLT?

这是 XSLT 中的一个近似模拟:

字典条目具有以下格式:

<t>Your query "<query/>" matched <nResults/> results</t>

转换(对应string.format())很简单:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>

<xsl:param name="pQuery" select="'XPath and XSLT'"/>
<xsl:param name="pNumResults" select="3"/>

<xsl:template match="query">
<xsl:value-of select="$pQuery"/>
</xsl:template>

<xsl:template match="nResults">
<xsl:value-of select="$pNumResults"/>
</xsl:template>
</xsl:stylesheet>

它会产生想要的、正确的结果:

Your query "XPath and XSLT" matched 3 results

关于c# - String.Format ("Your query {0} with {1} Placeholders", theQuery, results.Count) 在 XSLT 中等效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4166764/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com