We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Detect language in PHP | Forum

Thomas
Thomas Jun 20 '13

Hello,


I'm working on getting different content in custom HTML widget, depending on the language the user has set. I feel like I'm on the right track (I hope) but I need some help.


PHP can not run from the widget, I know. But I can include a php file using ajax. My thought is that the php file will have a script that is based on the "OW :: getLanguage ()" and detect the current language settings.


If language is "en" -> do this - echo something in english

else -> do something else - echo other text


Am I on the right track and can someone PLEASE write a few lines of code and help me? ;-)


Any help will be greatly appreciated.

Daisy Team
Daisy Jun 27 '13
Thomas, the method you've chosen to change the content of the box depending on the language ID is quite tangled. We can suggest two ways on how to make it easier:

First is using java-script code that will detect the language ID and show the part of the block text depending on the language ID. This is the easiest way.

Second is a new plugin development. This plugin will simply add a custom text block (you can designe it as the standard widget). you will be able to modify the text of this widget via standard language system.

All you will need is to take the standard Custom HTML widget functionality for the base functionality of your plugin.

P.S. please take a look at this topic, you might find it useful: http://www.oxwall.org/forum/topic/8737