Download the PHP package solution-forest/filament-translate-field without Composer

On this page you can find all versions of the php package solution-forest/filament-translate-field. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package filament-translate-field

Filament Translate Field

Latest Version on Packagist Total Downloads

Filament Translate Field is a library for Filament CMS that simplifies managing multiple translatable fields in different languages.

filament-translate-field-1

Installation

You can install the package via composer:

Important

Configuration:

Setup

For version before 1.x.x

Adding the plugin to a panel

To add a plugin to a panel, you must include it in the configuration file using the plugin() method:

Setting the default translatable locales

To set up the locales that can be used to translate content, you can pass an array of locales to the `defaultLocales()` plugin method:

For version equal or after 1.x.x

Setting the default translatable locales

Since the plugin after 1.x.x is a standalone plugin, which does not need to be related to Filament Panel, so you need to globally set it up in the config file or use the boot method in `AppServiceProvider`.

To set up the locales that can be used to translate content, you can pass an array of locales to the `defaultLocales()` plugin method:

Or, you can publish configuration file `config/filament-translate-field.php` and add default locales on `locales`:

Usage

Form component

By using the Translate component, you can easily configure your form fields to support multiple languages and provide translations for each locale.

Setting the translatable locales for a particular fields

By default, the translatable locales can be set globally for all translate form component in the plugin configuration. Alternatively, you can customize the translatable locales for a particular resource by overriding the locales() method in Translate class:

Label

Setting the translatable label for a particular field

You have the flexibility to customize the translate label for each field in each locale. You can use the fieldTranslatableLabel() method to provide custom labels based on the field instance and the current locale.

Adding prefix/suffix locale label to the field

If you simply want to add a prefix or suffix locale label to the form field, you can use the prefixLocaleLabel() or suffixLocaleLabel() method. This makes it easier for users to identify the language associated with each field.

`prefixLocaleLabel:

filament-translate-field-3

suffixLocaleLabel:

filament-translate-field-4

Setting the locale display name

By default, the prefix/suffix locale display name is generated by locale code and enclosed in parentheses, "()". You may customize this using the preformLocaleLabelUsing() method:

Injecting the current form field

Additionally, if you need to access the current form field instance, you can inject the $field parameter into the callback functions. This allows you to perform specific actions or conditions based on the field being processed.

filament-translate-field-5

Adding action

You may add actions before each container of children components using the actions() method:

If have multiple Translate components and have action in each component, please add id to Translate component by id() method

Injecting the locale on current child container

If you wish to access the locale that have been passed to the action, define an $arguments parameter and get the value of locale from $arguments:

Injecting the locale to form field

If you wish to access the current locale instance for the field, define a $locale parameter:

Removing the styled container

By default, translate component and their content are wrapped in a container styled as a card. You may remove the styled container using contained():

Exclude

The exclude feature allows you to specify fields that you don't want to be included in the translation process. This can be useful for fields that contain dynamic content or that shouldn't be translated into other languages.

Without exclude

With Exclude

Publishing Views

To publish the views, use:

Publishing Configuration file

To publish the configuration file, use:

Example

Demo

https://github.com/solutionforest/filament-translate-field/assets/68525320/b088d632-2df5-4594-b91c-56b708425e41

Sample Code

In Filament panel:

In app/Filament/Resources/NewsResource.php:

In app/Models/News.php:

In resources/lang/en.json:

In resources/lang/es.json:

In resources/lang/fr.json:

In the given example, when you save the model, the data will be stored in the following format:

Testing

Changelog

See the CHANGELOG for more information on what has changed recently.

Contributing

See CONTRIBUTING for details.

Security Vulnerabilities

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

Filament Tree is open-sourced software licensed under the MIT license.

About Solution Forest

Solution Forest Web development agency based in Hong Kong. We help customers to solve their problems. We Love Open Soruces.

We have built a collection of best-in-class products:


All versions of filament-translate-field with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
filament/filament Version ^3.0
spatie/laravel-package-tools Version ^1.15.0
illuminate/contracts Version ^10.0|^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package solution-forest/filament-translate-field contains the following files

Loading the files please wait ....