Skip to main content
WP- WPML 을 위한 다국어 위젯제작!

WPML은 대표적인 다국어 플러그인입니다.

유료지만 안정적이고 강력해서 항상 다국어 사이트 제작시 사용하고 있습니다.

그런데 일반 글쓰기와 페이지등과 쇼핑몰은 오히려 다국어제작시 큰 문제 없었지만

오히려 사소한(?) 위젯이 다국어제작시 문제시 문제가 되었습니다.

보통 위젯은 사이드메뉴로 대부분 사용하기 때문에 WPML에서도 크게 문제가 눈에 띄지 않았지만

사이드메뉴 아닌 텍스트를 이용해서 사이트의 안내문구등을 표기할때 WPML의 자체기능으로

다국어설정을 지원하지 않습니다.

Widget Logic

WPML페이지의 Tutorials에서 내용을 보면

widget Logic을 이용해서 위젯에 컨디션을 ?부여해서 해당 언어에 표기할 수 있다고 되어 있네요.

그리고 특히

ICL_LANGUAGE_CODE == 'en' 언어설정에 대한 코드는 이렇습니다.
이제 위젯도 마음것 활용할 수 있겠네요.

Howto Display Different Widgets Per Language!

 

WPML lets you translate widget titles and the body of text widgets. Sometimes, it’s not enough and you want to have completely different widgets for each language. I’ll show you how to do this using Widget Logic.

Widget Logic?is a plugin that allows controlling where widgets display using PHP code. You can use it to specify where widgets are allowed, including which languages they will display in.

For example, supposing that I want to have different feeds in the widget area. There are different ways to do this, but I’ll show how it can be done using Widget Logic and language conditions.

Before we begin, download and activate Widget Logic:
http://wordpress.org/extend/plugins/widget-logic/

Add multiple copies of the widget to the Widget Area

Each of these widgets will be active in only one language, so we need as many copies as the number of languages we have.

The order of these copies doesn’t matter, as only one will be active at any time.

Two RSS widgets, one per language

Add language conditions per widgets

Click to edit each of these widgets and add the language conditions to the Widget Logic field.

blank

WPML’s language code

The logic that we add uses WPML’s language code constant ? ICL_LANGUAGE_CODE (reference). For example, for English we add:

ICL_LANGUAGE_CODE == 'en'

This condition tells Widget Code to display this widget only on English pages.

We repeat this for all the copies that we created.

The result ? different widgets per language

You should expect to see the different widgets per language now.

English page German page
blank blank