Download the PHP package happenv-com/filament-translatable without Composer

On this page you can find all versions of the php package happenv-com/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

FILAMENT 3.x FILAMENT 4.x FILAMENT 5.x Packagist Tests Passing PHPStan Passing Rector Passing Downloads

Filament Translatable is a flexible package that provides a complete solution for managing multilingual content in Filament admin panels. It allows you to easily create translatable form fields with an intuitive tabbed interface, supporting multiple locales and translation packages.

Key Features

translatable component

Installation

Filament Version Filament Translate Field Version
3.x 2.x (old namespace)
4.x 4.x
5.x 4.x

You can install the package via composer:

Publish the assets:

Configuration

With spatie/laravel-translatable

The Spatie package is the default translation backend. Follow the instructions in the Spatie documentation to properly configure your models.

With astrotomic/laravel-translatable

The Astrotomic package is an alternative translation backend.

Follow the Astrotomic documentation to configure your models. However, instead of using the Translatable trait from the Astrotomic package, use Happenv\FilamentTranslatable\Traits\AstrotomicTranslatable.

When using the Astrotomic package, configure the plugin to use 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 app.fallback_locale config value will be used.

Usage

translatable() macro

The translatable() macro allows you to quickly convert any form field into a multilingual field that supports translations for each configured locale.

translatable macro

Marking a field as required for a specific locale

You can make a field required only for specific locales. In this example, the "name" field will only be required for the English language:

Marking a field as required for the default locale

You can make a field required only for the default locale. The default locale is determined by the defaultLocale() plugin setting or the app.fallback_locale config value:

Decorating language-specific fields

You can customize the appearance of fields for specific locales using the decorateTranslationField() method. This is useful for adding locale-specific prefixes, suffixes, or other modifications:

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

The Translations component provides a more powerful way to configure multiple form fields for multilingual support. It displays translations in a tabbed interface, with each tab representing a different 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 specific components

By default, locales are configured globally in the plugin settings. However, you can override the locales for a specific Translations component:

Setting custom field labels per locale

You can customize field labels for each locale using the fieldTranslatableLabel() method. This is useful for translating field labels themselves:

Adding prefix/suffix locale labels to fields

You can add the locale name as a prefix or suffix to field labels using the prefixLocaleLabel() or suffixLocaleLabel() methods. This helps users identify which language they are editing:

Customizing the locale label format

By default, the prefix/suffix locale label is generated from the locale code and enclosed in parentheses (e.g., "(English)"). You can customize this format using the preformLocaleLabelUsing() method:

Conditionally adding locale labels

You can conditionally add prefix/suffix labels by injecting the $field parameter into the callback. This allows you to apply locale labels only to specific fields:

Adding actions to locale tabs

You can add custom Filament actions to each locale tab using the actions() method. Actions appear in the tab header and can be used for operations like auto-translation or copying content between locales:

Accessing the locale in actions

To access the current locale within an action, use the $arguments parameter and retrieve the locale value:

Accessing the locale in schema

You can access the current locale within the schema definition by defining a $locale parameter. This is useful for conditional logic based on the locale:

Removing the styled container

By default, the Translations component is wrapped in a card-styled container. You can remove this styling using the contained() method:

Vertical tabs

You can display translations as vertical tabs:

Overriding plugin settings per component

You can override the global plugin settings directly on individual components:

Excluding fields from translation

The exclude() method allows you to specify fields that should not be translated. Excluded fields will appear in the form but will not be duplicated for each locale. This is useful for fields that contain non-translatable content:

Without exclude:

With exclude:

Including only specific fields for translation

The include() method allows you to specify which fields should be translated. This is useful when only a small subset of fields in a large form requires translations.

Without include:

With include(['title']):

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.3
filament/filament Version ^4.3.1|^5.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 happenv-com/filament-translatable contains the following files

Loading the files please wait ...