<p><a href="https://github.com/craftcms/cms/issues/2028" rel="nofollow noreferrer">There is no native support for this</a>, you can follow my approach and create a custom table for it to store the settings for each site</p>

<p>Another way is to return a different array depending on the current site in your config file</p>

<pre><code>if(Craft::$app-&gt;getSites()-&gt;getCurrentSite()-&gt;handle === X){
    return ['flagName' =&gt; 'Tricolore'];
} else {
    return ['flagName' =&gt; 'Bundesflagge'];
}
</code></pre>

<p>or</p>

<pre><code>$array = [
    'de' =&gt; [
        'flagName' =&gt; 'Bundesflagge'
    ],
    'fr' =&gt; [
        'flagName' =&gt; 'Tricolore'
    ]
];

return $array[Craft::$app-&gt;getSites()-&gt;getCurrentSite()-&gt;handle];
</code></pre>

CC BY-SA 4.0
2018-07-11T15:14:05.517Z
2018-07-11T15:31:05.187Z
2018-07-11T15:31:05.187Z
Robin Schambach
<p>if you need site-specific config for the plugin in the control-panel, you have to check for the site-param</p>

<pre><code>&lt;?php
$handle = Craft::$app-&gt;request-&gt;isCpRequest ?  Craft::$app-&gt;request-&gt;getParam('site') : Craft::$app-&gt;getSites()-&gt;getCurrentSite()-&gt;handle;
$array = [
  'de' =&gt; [
    ...
   ],
  'en' =&gt; [
    ...
  ]
];
return $array[$handle];
?&gt;
</code></pre>

<p>getCurrentSite() always returns the primary site for cp.</p>

CC BY-SA 4.0
2019-08-28T14:22:20.683Z
2019-08-28T14:22:20.683Z
toy
<p>These solutions work great, but I found an alternative, which suited my use-case a bit better. </p>

<p>If you create a Global (e.g. handle <code>cookieNotice</code>) in CMS with <strong>translatable</strong> fields (e.g. text fields with handles <code>cookieMessage</code>, <code>cookieLearnMoreText</code>, ..), you can add them to your custom plugin config as follows;</p>

<pre><code>&lt;?php
    $global = Craft::$app-&gt;globals-&gt;getSetByHandle('cookieNotice');
    return [
        'message' =&gt; $global-&gt;cookieMessage,
        'learn' =&gt; $global-&gt;cookieLearnMoreText,
        'learn_more_link' =&gt; $global-&gt;cookieLearnMoreLink,
        'dismiss' =&gt; $global-&gt;cookieButtonText
    ];
</code></pre>

<p>This automatically returns the <strong>translated</strong> value for your site, and let you change the values from CMS.</p>

<p><em>Note: in my case, the fields were basic text fields, you may have to customise <code>$global-&gt;cookieMessage</code> for different field types.</em></p>

CC BY-SA 4.0
2019-12-09T12:46:05.967Z
2019-12-09T12:46:05.967Z
Ludo
<p>This is a followup question to <a href="https://craftcms.stackexchange.com/questions/20381/plugin-settings-per-site-locale/20382">this question</a> which asked about the possibility of per-site plugin config for Craft 3.</p>

<p>I'm a plugin author and have had a feature request for allowing my plugin to have different settings based on the current site. Looking at the above question, it sounds like this used to be possible in Craft 2:</p>

<pre><code>&lt;?php

return [
    'flagName' =&gt; [
        'de' =&gt; 'Bundesflagge',
        'fr' =&gt; 'Tricolore',
    ],
];
</code></pre>

<p>This doesn't work in Craft 3, alas (throws an error). I could write something into my plugin's admin area to loop through known sites and output config per-site but this seems like something Craft should be able to do out-of-the-box (especially given the above method used to be valid). Does anyone know if there's a good way to do this in Craft 3?</p>

CC BY-SA 4.0
2018-07-12T04:45:22.517Z
I'm pretty sure that the above only ever applied to the `siteUrl` and wasn't generalized to work for any setting for Craft 2.x
andrew.welch
<plugin-development><craft3>
Plugin settings per site / locale (Craft 3)
# Plugin settings per site / locale (Craft 3)

(Asked by: username_0 on 2018-07-11)

This is a followup question to this question which asked about the possibility of per-site plugin config for Craft 3.
I'm a plugin author and have had a feature request for allowing my plugin to have different settings based on the current site. Looking at the above question, it sounds like this used to be possible in Craft 2:
 [
        'de' => 'Bundesflagge',
        'fr' => 'Tricolore',
    ],
];

This doesn't work in Craft 3, alas (throws an error). I could write something into my plugin's admin area to loop through known sites and output config per-site but this seems like something Craft should be able to do out-of-the-box (especially given the above method used to be valid). Does anyone know if there's a good way to do this in Craft 3?

**Tags:** plugin-development, craft3

> **Comments:**
> **username_1**: I'm pretty sure that the above only ever applied to the `siteUrl` and wasn't generalized to work for any setting for Craft 2.x  

---

## 3 answers

### Answer by username_2 on 2018-07-11. Score: 3 | Accepted answer

There is no native support for this, you can follow my approach and create a custom table for it to store the settings for each site
Another way is to return a different array depending on the current site in your config file
if(Craft::$app->getSites()->getCurrentSite()->handle === X){
    return ['flagName' => 'Tricolore'];
} else {
    return ['flagName' => 'Bundesflagge'];
}

or
$array = [
    'de' => [
        'flagName' => 'Bundesflagge'
    ],
    'fr' => [
        'flagName' => 'Tricolore'
    ]
];

return $array[Craft::$app->getSites()->getCurrentSite()->handle];


---

### Answer by username_3 on 2019-08-28. Score: 1

if you need site-specific config for the plugin in the control-panel, you have to check for the site-param
request->isCpRequest ?  Craft::$app->request->getParam('site') : Craft::$app->getSites()->getCurrentSite()->handle;
$array = [
  'de' => [
    ...
   ],
  'en' => [
    ...
  ]
];
return $array[$handle];
?>

getCurrentSite() always returns the primary site for cp.


---

### Answer by username_4 on 2019-12-09. Score: 1

These solutions work great, but I found an alternative, which suited my use-case a bit better. 
If you create a Global (e.g. handle cookieNotice) in CMS with translatable fields (e.g. text fields with handles cookieMessage, cookieLearnMoreText, ..), you can add them to your custom plugin config as follows;
globals->getSetByHandle('cookieNotice');
    return [
        'message' => $global->cookieMessage,
        'learn' => $global->cookieLearnMoreText,
        'learn_more_link' => $global->cookieLearnMoreLink,
        'dismiss' => $global->cookieButtonText
    ];

This automatically returns the translated value for your site, and let you change the values from CMS.
Note: in my case, the fields were basic text fields, you may have to customise $global->cookieMessage for different field types.


---

