MutationDigitale / craft3-translate

Craft CMS plugin for static translations in CP
Other
12 stars 7 forks source link

Add Multisite functionality to cover every type of translation #1

Closed Tim-Wils closed 4 years ago

Tim-Wils commented 4 years ago

Hey! First off all, the plugin is awesome! Just played with it and seems to be the right tool for me on a certain project.

I have two small requests and one larger request:

  1. [CTRL/CMD + S] should be saving the list and it doesn't :)

  2. Instead of an input , you should replace it for a textarea, so that multilines are supported. Textarea could initially be the same height as the inputs now, so it'll keep the looks: Multiline translations in twig: {% filter t %}this is awesome not? {% endfilter %}

initially: afbeelding

with multiline translation: afbeelding

  1. We have 2 websites with the same language, but they cannot have the same translations. This is because one of the websites is written in formal language and the other informal. The question is: can you make a multisite switch? That would be awesome!

For example, both English, but different style: formal site: "Contact us in the form below." informal site: "Send me your thoughts." or formal site: "Welcome" informal site: "Hi there!"

smcyr commented 4 years ago

Hi there! Thanks for the kind words. I’ll fix the first two points on monday and I’ll look into the third one.

smcyr commented 4 years ago

I fixed the first two issues in the 1.5.1 release.

For the 3rd one, I don't think there is really a fix for that as Yii2 translations work for languages only.

But what you could do is to define a category based on the current site in twig:

{% set translateCat = craft.app.sites.currentSite.handle == 'formal-site' ? 'formal' : 'informal' %}

And then, when you use the t filter, you can pass the category:

{{ 'Hello' | t(translateCat) }}

Finally, you can create a file translate.php in your config directory to define the categories used by the plugin:

<?php
return [
    'categories' => [
        'formal',
        'informal'
    ],
];
Tim-Wils commented 4 years ago

Awesome! Seems like it works like a charm, thank you! As for the 3rd one: Your solution seem to can do the job just fine. Thanks again :)