• Resolved SpiritOfTheWinds

    (@spiritofthewinds)


    Hi,

    I’ve got a problems while trying to use gettext inside iframes. I’m linking to PHP pages (which has included the WordPress header) and using the gettext function to get those pages to translate. Unfortunately, it keeps using the default language even if I specify the locale.

    I’d like any help which could help me fix the localization of those pages. I want to use the same .MO/.PO that my theme use.

    So, I have my language files as theme_name\en_US.po and my iframe files in theme_name\forms\form_name.php.

    Those forms have <?php include("../../../../wp-blog-header.php"); ?> and $locale = ($_GET['lang'] == 'fr') ? 'fr_CA' : 'en_US'; define('WPLANG', $locale); setlocale(LC_ALL, $locale);. I tried forcing the locale however the setlocale and define does nothing and it keeps showing me the default language text. I know it’s loading cause the text is not the same, even in the default language. I just can’t seem to figure out how to force a language in a file outside the WordPress theme files.

    Bit more code:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <?php include("../../../../wp-blog-header.php"); ?>
    <?php $locale = ($_GET['lang'] == 'fr') ? 'fr_CA' : 'en_US';
    load_theme_textdomain('theme', get_template_directory());
    define('WPLANG', $locale);
    setlocale(LC_ALL, $locale); ?>
    <title><?php bloginfo('name'); ?> - <?php _e('theme', 'Test Form') ?></title>
    [...]

    The default language is fr_CA. Any help on this issue would be greatly appreciated!

    Thanks!

    P.S. Couldn’t post to the WP-Advanced forum so I posted here instead.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter SpiritOfTheWinds

    (@spiritofthewinds)

    Well, a colleague got an idea that worked. I created a new page that used a new template (which contained the form) and linked it in my iframe. It is working fine though I would have preferred if it wasn’t listed in the Pages list. But it works and it’s the important.

    Thread Starter SpiritOfTheWinds

    (@spiritofthewinds)

    Sorry, forgot to mark as resolved! Now done.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using localization in iframes’ is closed to new replies.