tastyigniter/ti-ext-translate

Allows multilingual websites with TastyIgniter, making it easy to translate menu items.

Fund package maintenance!
tastyigniter
Open Collective

Installs: 26

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 2

Open Issues: 1

Type:tastyigniter-extension

dev-master 2022-12-11 08:50 UTC

This package is auto-updated.

Last update: 2024-04-24 15:15:19 UTC


README

Language Picker Component

Using the LocalePicker component a visitor can choose their preferred language. This component shows a simple dropdown, which will change the language of the page depending on the selection.

Add the Language Picker component to your layout or page

---
title: 'Home'
permalink: /

'[localePicker]':
---

@component('localePicker')

If the text on the page is translated, it will appear as whatever language the user selects. The dropdown is very simple and customisable:

[...]
---

<p>
    Switch language to:
    <a href="#" data-request="localePicker::onSwitchLocale" data-request-data="locale: 'en'">English</a>,
    <a href="#" data-request="localePicker::onSwitchLocale" data-request-data="locale: 'es'">Spanish</a>
</p>

Model translation

Models can have their attributes translated by using the Igniter\Translate\Actions\TranslatableModel action and specifying which attributes to translate in the class.

class Category
{
    public $implement = [\Igniter\Translate\Actions\TranslatableModel::class];

    public function translatable() {
        return ['name'];
    }
}