sinso/translationapi

This package is abandoned and no longer maintained. The author suggests using the visol/translationapi package instead.

API to fetch translation units.

Installs: 9 823

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 7

Forks: 0

Type:typo3-cms-extension

2.0.1 2018-02-07 13:45 UTC

This package is auto-updated.

Last update: 2021-12-02 15:57:38 UTC


README

This extension lets you fetch localized labels from TYPO3. It will automatically export labels as JSON from any locallang.xlf file, given its extension key.

Routing

Please add following rewrite rules to your .htaccess:

RewriteRule ^t3api/translation/(.*)$ /index.php?eID=routing&route=translationapi/$1 [QSA,L]

or nginx configuration

rewrite ^/t3api/translation/(.*)$ /index.php?eID=routing&route=translationapi/$1 last;

How-To Use as Web Service

In order to fetch labels from extension xyz, call:

/t3api/translation/en/xyz

If you want to only return labels whose key is prefixed by, say, "module", then call:

/t3api/translation/en/xyz/module

This will effectively filter XLIFF keys and keep those starting with "module." (mind the period). You may of course use a longer prefix, such as "module.foo", which would filter keys starting with "module.foo.".

How-To Use within Fluid

This extension is able to export the labels as JSON to be embedded into a HTML snippet:

<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>

Options

  • ?omitPrefix=yes (default "no") will strip the prefix from the key. E.g. with "module" as prefix,

    key "module.foo.bar" will be returned as "foo.bar"

  • ?expand=yes (default "no") will "expand" the keys as subarrays:

    {
        "module.foo.bar.key1": "value1",
        "module.foo.bar.key2": "value2",
    }
    

    becomes

    {
        "module": {
            "foo": {
                "bar": {
                    "key1": "value1",
                    "key2": "value2"
                }
            }
        }
    }