| |
| | |

CodersClub

 Forgot password?
 Register
Search
View: 4300|Reply: 3
Collapse the left

How to create MultiLingual Plugins

[Copy link]

 Russia

Post time: 2013-07-18 15:45
| Show all posts |Read mode
THE FIRST PROBLEM IS WHERE TO PLACE LANGUAGES

Some original Discuz plugins give us an idea how to organize the ML plugins.

Look inside any plugin, i.e. source/plugin/qqconnect/
We can see the plugin have onboard FIVE identical xml files but with different translations/encodings:
discuz_plugin_qqconnect.xml
discuz_plugin_qqconnect_SC_GBK.xml
discuz_plugin_qqconnect_SC_UTF8.xml
discuz_plugin_qqconnect_TC_BIG5.xml
discuz_plugin_qqconnect_TC_UTF8.xml

The first file is DEFAULT, but others have a suffix like LANGUAGE_ENCODING.

No need to reinvent the wheel again.
My idea is just use the same structure for add other languages, i.e.
discuz_plugin_qqconnect_AR_UTF8.xml
discuz_plugin_qqconnect_EN_UTF8.xml
discuz_plugin_qqconnect_PL_UTF8.xml
discuz_plugin_qqconnect_RU_UTF8.xml
etc.

As you can see, I have realized partially this idea...


THE SECOND PROBLEM IS HOW TO GET THE CURRENT PLUGIN LANGUAGES IN RUNTIME

For now Discuz can use ONLY ONE LANGUAGE (selected on installation).

All the language variables from all the plugins are combined into a single cache file:
/data/cache/cache_pluginlanguage_script.php = lang used in all the plugins code
/data/cache/cache_pluginlanguage_template.php = lang used in all the plugins templates

How to cache different languages for the same plugin?
There are 2 methods:

1) Do not cache languages, but read it dynamically.
It is very hard to realize, and is very slow...

2) Just save a separated cache file for every used language. (like for main templates now)
i.e.
/data/cache/cache_ar_pluginlanguage_script.php = AR lang used in all the plugins code
/data/cache/cache_ar_pluginlanguage_template.php = AR lang used in all the plugins templates
/data/cache/cache_en_pluginlanguage_script.php = EN lang used in all the plugins code
/data/cache/cache_en_pluginlanguage_template.php = EN lang used in all the plugins templates
etc.
It's much easier to realize.

I think we will go by the second road...




 Palestine

Post time: 2013-07-22 11:45
| Show all posts
thx vot

 Malaysia

Post time: 2013-07-25 09:58
| Show all posts
/data/cache/cache_pluginlanguage_script.php
/data/cache/cache_pluginlanguage_template.php

where to get this code?

 Russia

 Author| Post time: 2013-07-25 15:36
| Show all posts
jlloke82 2013-7-25 10:58
/data/cache/cache_pluginlanguage_script.php
/data/cache/cache_pluginlanguage_template.php

That files created automatically (cached) at your site.

You have to log in before you can reply Login | Register

Points Rules

Archive|Mobile|Dark room|CodersClub

Top.Mail.Ru
Top.Mail.Ru

2024-11-23 13:59 GMT+3 , Processed in 0.041543 sec., 11 queries .

Powered by Discuz! X3.4 Release 20230520

© 2001-2024 Discuz! Team.

MultiLingual version, Rev. 4301, © codersclub.org

Quick Reply To Top Return to the list