I’m developing a theme especially for BÄnglÄ blog posting, and it’d be under GNU license. I questioned about a Calendar Widget translation with some problems today, and got a comment saying:
I’m just wondering, is this not covered in the Bangla translation?
And after the s_ha_dum’s answer I thought I can make a translation-ready theme. Then I can translate all the necessary Texts for my theme. I followed:
- Internationalizing And Localizing Your WordPress Theme
– by Konstantinos Kouratoras — WP.SmashingMagazine.com - Translating Your Theme
– by Robert Treacy — WP.TutsPlus.com
And now I made a complete translation-ready theme and it’s working when I change the WPLANG
to my language in wp-config.php
. But except this step the whole thing is automatic. So if this step can be automatic, it’d be nice for me.
I want to place a filter that can hook the WPLANG and overwrite with bn_BD
like:
define('WPLANG', 'bn_BD');
when the theme is activated.
So that I can simply say: “Install the theme, and it’ll do everything for you. You don’t need to have access into your cPanel to make change into the wp-config.php
.” I’ve read the WPSE thread Trigger language change in WordPress, but if you now get me, I’m on a different track.
So, is that possible?
It is not possible to do it exactly as you ask as once you
define()
a constant in php you can not redefine/override the value. But what you are trying to do is not necessary, this constant is defined as part of the installation of a localized wordress, therefor it is already there, and set correctly, for users that are running localized wordppress.There is an edge case of people that want different languages for their admin and front end, and need the ability to override the lang settings, but there are plugins/code snippets for them, and you as a theme author should not worry about that.
what you are trying to do will prevent your theme from being used in anything but english and Bangladesh sites. why would you want do limit it in that way.
Yap, got the answer from toscho’s Answer from a WPSE thread. Simply quoting him. Using the Filter:Locale, hook your function:
Place the code into your
functions.php
.