sinso / translationapi
2.0.1
2018-02-07 13:45 UTC
Requires
- typo3-ter/routing: >= 0.4.0
This package is auto-updated.
Last update: 2021-12-02 15:57:38 UTC
README
此扩展允许您从TYPO3获取本地化标签。它将自动将标签作为JSON导出,前提是给定其扩展密钥。
路由
请将以下重写规则添加到您的 .htaccess
RewriteRule ^t3api/translation/(.*)$ /index.php?eID=routing&route=translationapi/$1 [QSA,L]
或 nginx 配置
rewrite ^/t3api/translation/(.*)$ /index.php?eID=routing&route=translationapi/$1 last;
如何作为Web服务使用
为了从扩展 xyz
获取标签,请调用
/t3api/translation/en/xyz
如果您只想返回键前缀为 "module"(例如)的标签,请调用
/t3api/translation/en/xyz/module
这将有效地过滤XLIFF键,并保留以 "module." 开始的键(注意点号)。当然,您可以使用更长的前缀,例如 "module.foo",这将过滤以 "module.foo." 开始的键。
如何在Fluid中使用
此扩展可以将标签作为JSON导出,以嵌入到HTML片段中
<div
xmlns="http://www.w3.org/1999/xhtml" lang="en"
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
xmlns:l10n="http://typo3.org/ns/Sinso/Translationapi/ViewHelpers"
>
<!-- standard notation -->
<l10n:exportXliff extensionKey="some-extension" prefix="some-prefix" />
<!-- inline notation -->
<section data-localized-days='{l10n:exportXliff(extensionKey:"some-extension", prefix:"some-prefix")}'>
...
</section>
</div>
选项
-
?omitPrefix=yes
(默认 "no
")将从键中删除前缀。例如,如果前缀为 "module",则键 "module.foo.bar" 将返回为 "foo.bar"
-
?expand=yes
(默认 "no
")将 "展开" 键作为子数组{ "module.foo.bar.key1": "value1", "module.foo.bar.key2": "value2", }
变为
{ "module": { "foo": { "bar": { "key1": "value1", "key2": "value2" } } } }