opencart / opencart

A free shopping cart system. OpenCart is an open source PHP-based online e-commerce solution.
https://www.opencart.com/
Other
7.48k stars 4.84k forks source link

Multi-language issue #13833

Closed lemonadvert closed 5 months ago

lemonadvert commented 7 months ago

OpenCart 4.0.2.4 and 4.1

Hello, We have translated OpenCart into Bulgarian. We have 100% translated all language files. But when we started testing and noticed that language files in extensions are loaded from "extension/opencart/module/account" but they have to be loading from "ocbg_bglang/extension/opencart/module/account".

When you load the store, the Bulgarian translation of the module on the right does not appear.

You can check here: https://shipping.opencartsupports.com/bg?route=account/register

Thanks!

ppalashturov commented 7 months ago

@danielkerr I have this problem too!

Thanks!

opencartbot commented 7 months ago

You're right! I solved this problem by custom fix - copying the language files to the 'extension/opencart' folder when installing the language. But in the new version 4.1.0.0 I see new issue - the language in the admin does not switch, although in version 4.0.2.3 it was finally solved. But now again. "OpenCart Language Example" not working also. This must be decided before the release 4.1.0.0.

ppalashturov commented 7 months ago

@opencartbot @danielkerr Hello, We also have a problem with the namespace of the libraries uploading to extensions ('library'), I still can't load the library with use from there, and I have to use include to start the library. thanks!

opencartbot commented 7 months ago

We also have a problem with the namespace of the libraries uploading to extensions ('library'), I still can't load the library with use from there, and I have to use include to start the library.

This is not relevant to this topic (issue), i.e. multi-language . Let's be consistent in the topic.

opencartbot commented 7 months ago

And another problem is related to multi-language when I install a third-party module - the system looks for its translation in the language extension folder, but not in the module folder. Therefore, third-party modules do not have a translation in the admin, they are always in English. For example: I installed second language - Ukrainian, and switch to this language in the admin. Then installed the new extension - MyModule with Ukrainian localization in the file extension/mymodule/admin/language/uk-ua/module/mymodule.php But OpenCart connect the module localization with path extension/ukrainian/extension/mymodule/module/mymodule What do you advise?

danielkerr commented 7 months ago

i think u have not copied how i setup the language extension included to show developers how to add languages.

sounds like u have just copied language files into the system without setting up a start up controller to add the additional loading paths or even overrides to alter the route to match a extension directory.

ppalashturov commented 7 months ago

Hello, Thank you very much @danielkerr , everything is working perfectly now with the languages. Can you show an example how to work with the libraries in the modules for example: "ocbg_module/system/library/ocbg_module.php" how to load the corresponding class in some controller. It doesn't work with namespaces, it only works with 'include'. Thank you very much!

ppalashturov commented 7 months ago

@opencartbot Hello, oops, you need to transfer "extension" from module "my_module" folder to "catalog/language/de-de/extension/opencart/module/module.php" and for admin "admin/language/de-de/extension/ opencart/module/module.php"! unnamed

opencartbot commented 7 months ago

@danielkerr We need an example of a full additional localization, not what we have now, where there is only one localization file each. Moreover, this example does not work correctly, just look at the file admin\language\de-de\language\common\header.php in 'oc_language_example' folder

ppalashturov commented 7 months ago

@opencartbot "admin\language\de-de\language\common\header.php" remove "language" => "admin\language\de-de\common\header.php"!

opencartbot commented 7 months ago

@ppalashturov You didn't understand me. Please open the file extension\oc_language_example\admin\language\de-de\language\common\header.php What do you see there? Is it a front-end localization file? So. Therefore, it must be corrected. And it is necessary to make a example of full localization to show how the localization of extensions in the admin and in the catalog should look like.

opencartbot commented 7 months ago

you need to transfer "extension" from module "my_module" folder to "catalog/language/de-de/extension/opencart/module/module.php" and for admin "admin/language/de-de/extension/ opencart/module/module.php"!

This works for the default opencart extensions. But it doesn't work for other extensions.

ppalashturov commented 7 months ago

@opencartbot For the other modules, you create language files with a language in your module. For example: "extension/my_module/catalog/language/bg/module/my_module.php"

opencartbot commented 7 months ago

Thank you all. The issue with switching the language in the admin has been fixed c2b6fb5 With loading the admin localization of third-party modules - it was my fault, I did it like this: $data = $this->load->language(..); But it doesn't work anymore, no need to load the localization into the $data array.

BuslikDrev commented 1 month ago

Спасибо всем. Проблема с переключением языка в админке исправлена ​​c2b6fb5 С загрузкой локализации админки сторонних модулей - это моя ошибка, я сделал так: $data = $this->load->language(..); Но это больше не работает, не нужно загружать локализацию в массив $data.

Мне пришлось сделать так:

        foreach ($this->load->language($this->paths['language']['bus_cache']) as $key => $lang) {
            $data[$key] = $this->language->get($key);
        }

обработка через $this->language->get();