PluginProbe ʕ •ᴥ•ʔ
Real Cookie Banner: GDPR & ePrivacy Cookie Consent / 3.9.4
Real Cookie Banner: GDPR & ePrivacy Cookie Consent v3.9.4
5.2.25 5.2.23 4.5.1 4.5.2 4.5.3 4.6.0 4.6.1 4.7.0 4.7.1 4.7.10 4.7.11 4.7.12 4.7.13 4.7.14 4.7.15 4.7.2 4.7.3 4.7.4 4.7.5 4.7.6 4.7.8 4.7.9 4.8.0 4.8.3 4.8.4 5.0.0 5.0.1 5.0.10 5.0.11 5.0.13 5.0.15 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.12 5.1.13 5.1.16 5.1.17 5.1.19 5.1.2 5.1.4 5.1.6 5.1.9 5.2.0 5.2.1 5.2.10 5.2.12 5.2.14 5.2.19 5.2.22 5.2.4 5.2.5 5.2.7 5.2.9 trunk 2.10.1 2.11.0 2.11.1 2.11.2 2.12.0 2.13.0 2.14.0 2.14.1 2.14.2 2.14.3 2.15.0 2.16.0 2.16.1 2.16.2 2.17.0 2.17.1 2.17.2 2.17.3 2.18.1 2.18.2 3.0.0 3.0.1 3.0.2 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.10.0 3.11.0 3.11.1 3.11.2 3.11.4 3.11.5 3.12.0 3.13.0 3.13.1 3.13.2 3.13.3 3.2.0 3.3.0 3.4.0 3.4.1 3.4.10 3.4.11 3.4.12 3.4.13 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.10 3.6.11 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9 3.7.0 3.7.1 3.7.2 3.8.0 3.9.0 3.9.2 3.9.4 3.9.5 4.0.0 4.0.1 4.1.0 4.1.1 4.1.2 4.2.0 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.3.5 4.3.7 4.4.0 4.4.1 4.5.0
real-cookie-banner / inc / Localization.php
real-cookie-banner / inc Last commit date
api 3 years ago base 2 years ago comp 2 years ago import 2 years ago overrides 2 years ago rest 2 years ago scanner 2 years ago settings 2 years ago templates 2 years ago view 2 years ago Activator.php 3 years ago AdInitiator.php 3 years ago Assets.php 2 years ago Cache.php 3 years ago Clear.php 3 years ago Core.php 2 years ago DemoEnvironment.php 3 years ago IpHandler.php 3 years ago Localization.php 3 years ago MyConsent.php 3 years ago RpmInitiator.php 2 years ago Stats.php 3 years ago UserConsent.php 3 years ago Utils.php 2 years ago index.php 5 years ago
Localization.php
69 lines
1 <?php
2
3 namespace DevOwl\RealCookieBanner;
4
5 use DevOwl\RealCookieBanner\Vendor\DevOwl\Multilingual\AbstractSyncPlugin;
6 use DevOwl\RealCookieBanner\Vendor\DevOwl\Multilingual\Sync;
7 use DevOwl\RealCookieBanner\Vendor\MatthiasWeb\Utils\Constants;
8 use DevOwl\RealCookieBanner\Vendor\MatthiasWeb\Utils\Localization as UtilsLocalization;
9 use DevOwl\RealCookieBanner\base\UtilsProvider;
10 use DevOwl\RealCookieBanner\lite\settings\TcfVendorConfiguration;
11 use DevOwl\RealCookieBanner\settings\Blocker;
12 use DevOwl\RealCookieBanner\settings\Cookie;
13 use DevOwl\RealCookieBanner\settings\CookieGroup;
14 use DevOwl\RealCookieBanner\templates\TemplateConsumers;
15 use DevOwl\RealCookieBanner\view\customize\banner\Legal;
16 // @codeCoverageIgnoreStart
17 \defined('ABSPATH') or die('No script kiddies please!');
18 // Avoid direct file request
19 // @codeCoverageIgnoreEnd
20 /**
21 * i18n management for backend and frontend.
22 */
23 class Localization
24 {
25 use UtilsProvider;
26 use UtilsLocalization;
27 /**
28 * Keys of array which should be not translated with `translateArray`.
29 */
30 const COMMON_SKIP_KEYS = ['slug'];
31 /**
32 * Get the directory where the languages folder exists.
33 *
34 * @param string $type
35 * @return string[]
36 */
37 protected function getPackageInfo($type)
38 {
39 if ($type === Constants::LOCALIZATION_BACKEND) {
40 return [RCB_PATH . '/languages', RCB_TD];
41 } else {
42 return [RCB_PATH . '/' . Constants::LOCALIZATION_PUBLIC_JSON_I18N, RCB_TD];
43 }
44 }
45 /**
46 * Make our plugin multilingual with the help of `AbstractSyncPlugin` and `Sync`!
47 * Also have a look at `BannerCustomize`, there are `LanguageDependingOption`'s.
48 */
49 public static function multilingual()
50 {
51 $compLanguage = \DevOwl\RealCookieBanner\Core::getInstance()->getCompLanguage();
52 $sync = new Sync(\array_merge([Cookie::CPT_NAME => Cookie::SYNC_OPTIONS, Blocker::CPT_NAME => Blocker::SYNC_OPTIONS], \DevOwl\RealCookieBanner\Core::getInstance()->isPro() ? [TcfVendorConfiguration::CPT_NAME => TcfVendorConfiguration::SYNC_OPTIONS] : []), [CookieGroup::TAXONOMY_NAME => CookieGroup::SYNC_OPTIONS], $compLanguage);
53 $compLanguage->setSync($sync);
54 \add_filter('DevOwl/Multilingual/TranslateInput', [TemplateConsumers::getInstance(), 'translateInputFromTemplates'], 10, 5);
55 $idsToCurrent = [Legal::SETTING_PRIVACY_POLICY, Legal::SETTING_IMPRINT];
56 foreach ($idsToCurrent as $id) {
57 \add_filter('DevOwl/Customize/LocalizedValue/' . $id, function ($value) use($compLanguage) {
58 return $compLanguage->getCurrentPostId($value, Cookie::CPT_NAME);
59 });
60 }
61 // Translate some meta fields when they get copied to the other language
62 if ($compLanguage instanceof AbstractSyncPlugin) {
63 foreach (Cookie::SYNC_META_COPY_ONCE as $translateMetaKey) {
64 \add_filter('DevOwl/Multilingual/Copy/Meta/post/' . $translateMetaKey, [$compLanguage, 'translateInputAndReturnValue']);
65 }
66 }
67 }
68 }
69