[wp-hackers] What do you name the localization .mo when the locale is not set?

Frank Bueltge frank at bueltge.de
Thu Jun 17 15:12:03 UTC 2010


A small example, works fine.
i have this in a function and hook this on init (WordPress smaller
3.0) and greater
than or equal WP 3.0 via hook after_setup_theme.

    define( 'FB_GREYFOTO_TEXTDOMAIN', 'photoblog' );

    if ( defined( 'WPLANG') )
        $locale = WPLANG;
    if ( empty($locale) )
        $locale = 'en_US';
    load_theme_textdomain( FB_GREYFOTO_TEXTDOMAIN );
    $locale = get_locale();
    $locale_file = TEMPLATEPATH . '/languages/' . $locale . '.php';
    if ( is_readable( $locale_file ) )
        require_once( $locale_file );


On Thu, Jun 17, 2010 at 5:02 PM, Wordpress Developer <
wordpress.development at gmail.com> wrote:

> I'm working on a localized template and have my .mo working fine for
> default
> installs of WP. Love it: Just use _e('whatever', 'textdomain') and it echos
> out the value based on the "whatever" key.
>
> Unfortunately, my code fails after taking it from my personal dev
> environment into a professional one. I've troubleshooted what I can and
> think it's because the locale is not set on the new dev environment. I ran
> this code to check:
>
> <?php
> $locale = get_locale();
> if($locale == "en_US") {
>   echo "english: $locale";
> } else { echo "not english: $locale"; } ?>
>
> In the working dev environment, it echos out "english: en_US"
>
> In the non-working dev environment, it echos out "not english: "
>
> In both installs the WP_Lang constant is not set (wp-config: "define
> ('WPLANG', '');"). It's a bit confusing to me as to why one install
> defaults
> to en_US (as I might expect) but the other doesn't seem to have the locale
> set at all. In any case, I suspect my .mo is failing because it's named
> en_US.mo in the theme folder and since the locale on the second setup is
> not
> en_US it's not finding it.
>
> In any case, I figure my .mo has a chance if I name it the right thing for
> a
> WP install with no language set. Is there such a namespace? What do you
> name
> the localization .mo when the locale doesn't seem to be set?
>
> Thank you!
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list