Download the PHP package icodr8/contao-translation-fields without Composer
On this page you can find all versions of the php package icodr8/contao-translation-fields. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download icodr8/contao-translation-fields
More information about icodr8/contao-translation-fields
Files in icodr8/contao-translation-fields
Package contao-translation-fields
Short Description Translation fields for Contao OpenSource CMS
License LGPL-3.0+
Homepage http://craffft.de
Informations about the package contao-translation-fields
Contao extension Translation Fields
What is Translation Fields?
Translation Fields is a library for Contao developers to get nice translation fields in the Contao Open Source CMS. Every translation field gets a language flag and can be translated by changing the flag to another language. The translations will be saved in the table tl_translation_fields and a key from this table will be stored in the field self.
Dependencies
- none
Troubleshooting
Directly on github! See https://github.com/Craffft/contao-translation-fields/issues
Documentation
Input types
There are three input types that you can use in the back end.
- TranslationTextField (the same as input type text)
- TranslationTextArea (the same as input type textarea)
- TranslationInputType (the same as input type inputType)
How to define a field in the DCA
To use the translation fields, you have to do the following changes in your DCA code.
- Add an index to your field
- Change the input type
- Change the sql to int(10)
- Add a relation to your field
Each field uses different settings. You can see this in the following codes.
Examples
Text Field
The original field:
`
The field after the changes:
Textarea Field
The original field:
The field after the changes:
Input Unit Field
The original field:
The field after the changes:
How to translate the field values
To translate the key from your current field, you can use the following methods
Translate value
Translates the field key to the translation value in the current language.
Optional you can add a force language to the translateValue method.
Translate DataContainer object
Translates all translation field values in the data container object to a translated value.
Translate DCA
Translates all translation field values in the data container array to a translated value.
Runonce
If you already have content in your application fields, you have to ensure that translation fields doesn't remove your content data. Therefore you have to create a runonce which inserts the current values into the tl_translation_fields table and associate the key with the field.
You can do this like in the following code:
E.g. you can have a look at the runconce.php from my extension Photoalbums2: https://github.com/Craffft/contao-photoalbums2/blob/master/config/runonce.php
All versions of contao-translation-fields with dependencies
contao/core-bundle Version ^3.2 || ^4.2
contao-community-alliance/composer-plugin Version ^2.4.0 || 3.*