Download the PHP package ali-translator/buffered-translation without Composer
On this page you can find all versions of the php package ali-translator/buffered-translation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ali-translator/buffered-translation
More information about ali-translator/buffered-translation
Files in ali-translator/buffered-translation
Package buffered-translation
Short Description Manually pasted text on document for translation, by means of buffering is translated by one approach (helpful for DB sources)
License MIT
Informations about the package buffered-translation
Buffered Translation
Manually pasted text in a document for translation, using buffering, is translated by one approach (helpful for DB sources). This package includes the following vendors:
Installation
Quick start
Since this package extends from ali-translator/translator,
you need to create $translator
and a wrapper with the vector of its translation - $plainTranslator
.
Move the created $bufferTranslation
to the document creation process:
Use "logical variables" for plural templates:
Custom post-translation modification:
And then translate this buffered document:
Multiple Level Parameters and Their Options
Translation is recursive.
Logical variables
Template support is implemented on the basis of the "ali-translator/text-template" package, which also supports "logical variables". These are variables that use "functions" to modify content. More details can be found at the link to the package.
Example:
Options
Every buffered phrase has translation options parameters, with the following features:
BufferContentOptions::WITH_CONTENT_TRANSLATION
- This boolean parameter indicates whether to translate included parameters. By default, this value is set to "false".BufferContentOptions::WITH_FALLBACK
This boolean parameter determines whether the original text will be returned if no translation is found. By default, this value is set to "true".BufferContentOptions::WITH_HTML_ENCODING
- Use HTML encoding for output text.BufferContentOptions::MODIFIER_CALLBACK
- Custom post-translation modifier.BufferContentOptions::FINALLY_MODIFIER_CALLBACK
- A custom modifier that is called after translation and after resolving all children.
Translation of a Fragment of Buffered Text
If you only need to translate a single piece of buffered text, use the translateBufferFragment method:
This method only translates the found keys in the given context, not all buffered text.
Translation of Buffered Array
Note: Translation of buffered arrays is less efficient than normal translation of compiled text and should not be considered as a primary option.
Hints
-
If you already have a buffered key and want to use it in another template, you can use this script:
- If you use several BufferedTranslation services at once (for example, if the language of texts in the code and dynamic texts from the database is different) and you need to use the translation of one of the texts in the second template, it is recommended to do so:
Later, before "resolve", you need to call the preTranslateAllInsideTextTemplates method, which will translate all registered templates:
More details can be found in the test code: ./tests/unit/FewBufferTranslationServiceAtOnceTest.php
Suggest packets
- ali-translator/translator-js-integrate - Integrate this packet to frontend js
- ali-translator/auto-html-translation - Parses html document, and translate included texts
- ali-translator/url-template - Helps on url language resolving
Tests
In packet exist docker-compose file, with environment for testing.
All versions of buffered-translation with dependencies
ali-translator/translator Version ^0
ali-translator/text-template Version ^1.1.0
ext-intl Version *