PluginProbe ʕ •ᴥ•ʔ
Real Cookie Banner: GDPR & ePrivacy Cookie Consent / 3.1.2
Real Cookie Banner: GDPR & ePrivacy Cookie Consent v3.1.2
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 4 years ago base 3 years ago comp 3 years ago import 3 years ago overrides 3 years ago presets 3 years ago rest 3 years ago scanner 3 years ago settings 3 years ago view 3 years ago Activator.php 3 years ago AdInitiator.php 4 years ago Assets.php 3 years ago Cache.php 5 years ago Clear.php 4 years ago Core.php 3 years ago DemoEnvironment.php 5 years ago IpHandler.php 4 years ago Localization.php 3 years ago MyConsent.php 4 years ago RpmInitiator.php 5 years ago Stats.php 5 years ago UserConsent.php 4 years ago Utils.php 4 years ago index.php 5 years ago
Localization.php
95 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\Localization as UtilsLocalization;
8 use DevOwl\RealCookieBanner\base\UtilsProvider;
9 use DevOwl\RealCookieBanner\lite\settings\TcfVendorConfiguration;
10 use DevOwl\RealCookieBanner\settings\Blocker;
11 use DevOwl\RealCookieBanner\settings\Cookie;
12 use DevOwl\RealCookieBanner\settings\CookieGroup;
13 use DevOwl\RealCookieBanner\view\customize\banner\Legal;
14 // @codeCoverageIgnoreStart
15 \defined('ABSPATH') or die('No script kiddies please!');
16 // Avoid direct file request
17 // @codeCoverageIgnoreEnd
18 /**
19 * i18n management for backend and frontend.
20 */
21 class Localization {
22 use UtilsProvider;
23 use UtilsLocalization;
24 /**
25 * Keys of array which should be not translated with `translateArray`.
26 */
27 const COMMON_SKIP_KEYS = ['slug'];
28 /**
29 * Get the directory where the languages folder exists.
30 *
31 * @param string $type
32 * @return string[]
33 */
34 protected function getPackageInfo($type) {
35 if ($type === \DevOwl\RealCookieBanner\Vendor\MatthiasWeb\Utils\Localization::$PACKAGE_INFO_BACKEND) {
36 return [path_join(RCB_PATH, 'languages'), RCB_TD];
37 } else {
38 return [path_join(RCB_PATH, \DevOwl\RealCookieBanner\Assets::$PUBLIC_JSON_I18N), RCB_TD];
39 }
40 }
41 /**
42 * Make our plugin multilingual with the help of `AbstractSyncPlugin` and `Sync`!
43 * Also have a look at `BannerCustomize`, there are `LanguageDependingOption`'s.
44 */
45 public static function multilingual() {
46 $compLanguage = \DevOwl\RealCookieBanner\Core::getInstance()->getCompLanguage();
47 $sync = new \DevOwl\RealCookieBanner\Vendor\DevOwl\Multilingual\Sync(
48 \array_merge(
49 [
50 \DevOwl\RealCookieBanner\settings\Cookie::CPT_NAME =>
51 \DevOwl\RealCookieBanner\settings\Cookie::SYNC_OPTIONS,
52 \DevOwl\RealCookieBanner\settings\Blocker::CPT_NAME =>
53 \DevOwl\RealCookieBanner\settings\Blocker::SYNC_OPTIONS
54 ],
55 \DevOwl\RealCookieBanner\Core::getInstance()->isPro()
56 ? [
57 \DevOwl\RealCookieBanner\lite\settings\TcfVendorConfiguration::CPT_NAME =>
58 \DevOwl\RealCookieBanner\lite\settings\TcfVendorConfiguration::SYNC_OPTIONS
59 ]
60 : []
61 ),
62 [
63 \DevOwl\RealCookieBanner\settings\CookieGroup::TAXONOMY_NAME =>
64 \DevOwl\RealCookieBanner\settings\CookieGroup::SYNC_OPTIONS
65 ],
66 $compLanguage
67 );
68 $compLanguage->setSync($sync);
69 $idsToCurrent = [
70 \DevOwl\RealCookieBanner\view\customize\banner\Legal::SETTING_PRIVACY_POLICY,
71 \DevOwl\RealCookieBanner\view\customize\banner\Legal::SETTING_IMPRINT
72 ];
73 foreach ($idsToCurrent as $id) {
74 add_filter('DevOwl/Customize/LocalizedValue/' . $id, function ($value) use ($compLanguage) {
75 return $compLanguage->getCurrentPostId($value, \DevOwl\RealCookieBanner\settings\Cookie::CPT_NAME);
76 });
77 }
78 // Translate some meta fields when they get copied to the other language
79 if ($compLanguage instanceof \DevOwl\RealCookieBanner\Vendor\DevOwl\Multilingual\AbstractSyncPlugin) {
80 foreach (
81 [
82 \DevOwl\RealCookieBanner\settings\Cookie::META_NAME_PROVIDER,
83 \DevOwl\RealCookieBanner\settings\Cookie::META_NAME_PROVIDER_PRIVACY_POLICY_URL
84 ]
85 as $translateMetaKey
86 ) {
87 add_filter('DevOwl/Multilingual/Copy/Meta/post/' . $translateMetaKey, [
88 $compLanguage,
89 'translateInputAndReturnValue'
90 ]);
91 }
92 }
93 }
94 }
95