Download the PHP package tastyigniter/ti-ext-translate without Composer

On this page you can find all versions of the php package tastyigniter/ti-ext-translate. 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 ti-ext-translate

Build Status Total Downloads Latest Stable Version License

Introduction

The TastyIgniter translate extension provides comprehensive multilingual support. It allows administrators to manage translations for dynamic content (models), and frontend users to choose their preferred language.

Features

Installation

You can install the extension via composer using the following command:

Run the database migrations to create the required tables:

Usage

Configuring default locale

The setLocale method on the translator.localization service is used to set the language of your TastyIgniter application. The getLocale method on the translator.localization service is used to get the current language. You will typically set the default locale within a middleware.

Here is an example of setting the default locale to fr:

For more information on making your site multilingual, see the Localization section of the TastyIgniter documentation.

Switching locales

Visitors as well as administrators can choose their preferred language, which will change the language of the frontend or admin pages depending on the selection.

Admin area

In the admin area, you can switch the language by selecting the desired language from the dropdown on the staff profile page. Navigate to Manage > Staff members > Edit Staff and select the desired language from the Language dropdown. The admin area will be displayed in the selected language.

The Igniter\Flame\Translation\Middleware\Localization middleware is used to set the language of the admin area. The middleware checks if the staff member has a language set in their profile and sets the language accordingly.

Frontend

To allow visitors to switch the language, you can create a component to show a dropdown with the available languages. The component will change the language of the page depending on the selection. Here is an example creating a language picker livewire component:

The listSupported method on the Language model returns an array of supported languages, where the key is the language code and the value is the language name. The getLocale method on the translator.localization service is used to get the current language. The setLocale method on the translator.localization service is used to change the language of the page.

The component view file localepicker.blade.php:

When a visitor selects a language from the dropdown, the onSwitchLocale method is called, which changes the language of the page and redirects back to the same page.

The Igniter\Flame\Translation\Middleware\Localization middleware is used to set the language of the frontend. The middleware checks does the following checks:

Model translation

Models can have their attributes translated by using the Igniter\Translate\Actions\TranslatableModel action and specifying which attributes to translate using the translatable method. Here's how you can configure a model to have translatable attributes:

You can also translate models on other extensions by adding extending the model class within your extension class boot method. Here is an example of how to translate the Category model from the Igniter.Cart extension:

The addDynamicMethod method is used to add a new method to the model class.

Setting translations

You can store translations for the active locale by setting the model attribute value using the model property. Here is an example of setting the name attribute of a Category model to a french translation, assuming the active locale is set to fr:

You can store translations for multiple locales when creating a model.

To store the translation for a specific locale, you can use the setLocale method on the translator.localization service.

You can store translations for multiple locales when saving a model.

Retrieving translations

You can retrieve translations for the active locale by accessing the model attribute value. Here is an example of retrieving the name attribute of a Category model, assuming the active locale is set to fr:

You can retrieve translations for a specific locale by using the getAttributeTranslatedValue method on the model instance.

Form widgets

Translatable text

The trltext form widget is used to create a text input field that can store translations for multiple locales.

The options for the trltext form widget type are the same as the text form field type.

Translatable textarea

The trltextarea form widget is used to create a textarea input field that can store translations for multiple locales.

The options for the trltextarea form widget type are the same as the textarea form field type](https://tastyigniter.com/docs/extend/forms#textarea).

Translatable rich editor

The trlricheditor form widget is used to create a rich text editor input field that can store translations for multiple locales.

The options for the trlricheditor form widget type are the same as the richeditor form widget type.

Translatable markdown editor

The trlmarkdowneditor form widget is used to create a markdown editor input field that can store translations for multiple locales.

The options for the trlmarkdowneditor form widget type are the same as the markdowneditor form widget type.

Translatable repeater

The trlrepeater form widget is used to create a repeater input field that can store translations for multiple locales.

The options for the trlrepeater form widget type are the same as the repeater form widget type.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Reporting issues

If you encounter a bug in this extension, please report it using the Issue Tracker on GitHub.

Contributing

Contributions are welcome! Please read TastyIgniter's contributing guide.

Security vulnerabilities

For reporting security vulnerabilities, please see our our security policy.

License

TastyIgniter Translate extension is open-source software licensed under the MIT license.


All versions of ti-ext-translate with dependencies

PHP Build Version
Package Version
Requires tastyigniter/core Version ^v4.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 tastyigniter/ti-ext-translate contains the following files

Loading the files please wait ....