Download the PHP package filamerce/filament-translatable without Composer

On this page you can find all versions of the php package filamerce/filament-translatable. 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-translatable

Filament Translatable

Latest Version on Packagist Total Downloads

Filament Translatable is a set of tools that help manage translations.

translatable component

Installation

Filament Version Filament Translate Field Version
v4.x v2.x
v4.x v3.x

You can install the package via composer:

Publish the assets:

Configuration

With spatie/laravel-translatable

The package from Spatie is the default supported way of handling translations. Follow the instructions in the README to properly configure your models.

With astrotomic/laravel-translatable

The package from Astrotomic is an alternative supported way of handling translations.

Follow the instructions to properly configure your models, but instead of using the Translatable trait from the Astrotomic package, please use Filamerce\FilamentTranslatable\Traits\AstrotomicTranslatable.

If you use the Astrotomic package, please configure the plugin to work in Astrotomic mode:

You can also configure translationMode per component:

Or per field:

Setup

Setting translatable locales

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

You can set locale labels using key => value array:

Also, you can pass a Closure:

Setting default locale

You can set the default locale using the defaultLocale() method:

Enable or disable flags in locale labels

You can enable or disable flags in locale labels (disabled by default):

Setting flag width

You can set the flag width using:

Enable or disable names in locale labels

You can enable or disable locale names in locale labels (enabled by default):

Otherwise, the config value app.locale will be used.

This affects several methods that can be used on fields.

Usage

translatable() macro

By using the translatable() macro, you can quickly configure a single form field to support multiple languages and provide translations for each locale.

translatable macro

Marking field as required for specified locale

This way, the "name" field will only be required in the "en" language.

Marking field as required for default locale

This way, the "name" field will only be required in the default language.

Decorating language specified fields

You can fully customize language-specific fields using the decorateTranslationField() method.

Customizing Translations component

After using the translatable() method, the context of the field is switched to the Translations component, so you can use any method that belongs to the component.

translatable custom macro

[!CAUTION] Be sure to set field-specific methods like required() or requiredDefaultLocale() before calling the translatable() method.

Translations component

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

translatable horizontal component

[!NOTE] Using the translatable() method within the Translations component is not needed.

[!IMPORTANT] Be sure to set different names for each Translations component when using multiple instances.

Setting the translatable locales for a particular fields

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

Setting the translatable label for a particular field

You have the flexibility to customize the translation 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 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.

Setting the locale display name

By default, the prefix/suffix locale display name is generated from the 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 apply conditions based on the field being processed.

Adding action

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

Injecting the locale on current child container

If you wish to access the locale that has 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, the translate component and its content are wrapped in a container styled as a card. You may remove the styled container using contained():

Vertical tabs

You can display translations as vertical tabs:

Changing plugin settings

You can customize plugin settings directly on the component:

Exclude

The exclude feature allows you to specify fields that you don't want to include 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, run:

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 Translatable is open-sourced software licensed under the MIT license.


All versions of filament-translatable with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
filament/filament Version ^4.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 filamerce/filament-translatable contains the following files

Loading the files please wait ....