Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Multisite functionality to cover every type of translation #1

Closed
Tim-Wils opened this issue Dec 6, 2019 · 3 comments
Closed

Add Multisite functionality to cover every type of translation #1

Tim-Wils opened this issue Dec 6, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@Tim-Wils
Copy link

Tim-Wils commented Dec 6, 2019

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
Copy link
Contributor

smcyr commented Dec 6, 2019

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 smcyr added the enhancement New feature or request label Dec 6, 2019
@smcyr
Copy link
Contributor

smcyr commented Dec 8, 2019

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
Copy link
Author

Tim-Wils commented Dec 9, 2019

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants