1

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:

  1. Internationalizing And Localizing Your WordPress Theme
    - by Konstantinos Kouratoras — WP.SmashingMagazine.com
  2. 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?

0

2 Answers 2

1

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.

1
  • That well-said, why would I? To be or not to be that is the question! Commented Nov 4, 2013 at 10:08
1

Yap, got the answer from toscho's Answer from a WPSE thread. Simply quoting him. Using the Filter:Locale, hook your function:

add_filter( 'locale', 'wpse_52419_toscho_change_language' );

function wpse_52419_toscho_change_language( $locale ) {
    return 'bn_BD';
}

Place the code into your functions.php.

2
  • 1
    So your question is a duplicate?
    – fuxia
    Commented Nov 4, 2013 at 14:50
  • Yap, it's duplicate. Should mark this one. :) Commented Nov 4, 2013 at 15:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.