Skip to content

Instantly share code, notes, and snippets.

@PechenkiUA
Last active December 30, 2023 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PechenkiUA/43a4db5cb6fe9500aed122f45c43f62a to your computer and use it in GitHub Desktop.
Save PechenkiUA/43a4db5cb6fe9500aed122f45c43f62a to your computer and use it in GitHub Desktop.
підключення спільної папки з перекладами шаблону opencart
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Share lang </name>
<version>0.1</version>
<author>CoderUA</author>
<link>https://example.com</link>
<code>name_code</code>
<description></description>
<!--
додати в config.php та admin/config.php
define('DIR_LANGUAGE_SHARE', 'шлях до файлу від root'); // add share folder
Щоб працювали картинки додати в .htaccess
RewriteRule ^admin/language/(.*)/(.*).png$ index.php?route=tool/upload/flag&lang=$0&imgname=$1 [L]
RewriteRule ^catalog/language/(.*)/(.*).png$ index.php?route=tool/upload/flag&lang=$0&imgname=$1 [L]
-->
<file path="system/library/language.php">
<operation>
<search><![CDATA[$this->data = array_merge($this->data, $_);]]></search>
<add position="before"><![CDATA[
if (defined('DIR_LANGUAGE_SHARE')){
$file = DIR_LANGUAGE_SHARE . $this->directory . '/' . $filename . '.php';
if (is_file($file)) {
require($file);
}
}
]]></add>
</operation>
</file>
<file path="admin/controller/localisation/language.php">
<operation>
<search><![CDATA[if (isset($this->request->post['locale'])) {]]></search>
<add position="before"><![CDATA[
if (defined('DIR_LANGUAGE_SHARE')){
$folders_share = glob(DIR_LANGUAGE_SHARE . '*', GLOB_ONLYDIR);
foreach ($folders_share as $folder) {
$data['languages'][] = basename($folder);
}
$data['languages'] = array_unique($data['languages']);
}
]]></add>
</operation>
</file>
<file path="catalog/controller/tool/upload.php">
<operation>
<search><![CDATA[public function index() {]]></search>
<add position="before"><![CDATA[
public function flag(){
$path = $_GET['lang'];
$imgname = $_GET['imgname'];
if (defined('DIR_LANGUAGE_SHARE')){
$file = DIR_LANGUAGE_SHARE .$imgname.'/' . $imgname . '.png';
if (is_file($file)) {
header('Content-type: image/png');
readfile($file);
return;
}
}
if (defined('DIR_LANGUAGE')){
$file = DIR_LANGUAGE .$imgname.'/' . $imgname . '.png';
if (is_file($file)) {
header('Content-type: image/png');
readfile($file);
return;
}
}
}
]]></add>
</operation>
</file>
</modification>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment