ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

User Language Preference.

September 25, 2008 3:06pm

Subscribe [1]
  • #1 / Sep 25, 2008 3:06pm

    Lavi Yatziv

    28 posts

    I’m unsure of how to proceed with the following problem. It seems simple enough but i get the feeling this is a user profile setting.

    I’ve got a piece of code that seems to be causing me a lot of grief and anguish on this but I need to clarify the problem first no?

    {paginate}
        {if simple_language == "English"}
            Part {current_page} of {total_pages}  {pagination_links}
        {if:else} {!-- in This case it's french --}
            Partie {current_page} de {total_pages}  {pagination_links} 
        {/if}
    {/paginate}

    To allow a user to “toggle” between the english and french content I use the following method.

    <?php
    $myurl = $_SERVER["QUERY_STRING"];
    if (substr($myurl,-1) != "/")    {
        $myurl = $myurl . "/";
        }
    ?>
    {if simple_language == "French"}
        <a href="http://&lt?php">English</a>
    {if:else}
        <a href="http://&lt?php">Français</a>
    {/if}

    What ends up happening is the rest of the page changes to french except for the {pagination_links}.
    Is there a function that will change / update the user language in their profile?

  • #2 / Sep 25, 2008 8:30pm

    Greg Aker

    6022 posts

    Lavi Yatziv:

    Have you added French language files?

    There’s a nice utility located in your control panel at:  CP Home ›  Admin ›  Utilities ›  Translation Utility that will help you to set them up.

    You can read more about the utility here

    But, to answer your question, you need to change the words in the lang.core.php file to get the paginating links working.

    Does that help?

    -greg

  • #3 / Sep 26, 2008 9:59am

    Lavi Yatziv

    28 posts

    As for the french language files. Those are installed and working just fine.

    Thanks for the quick reply. The site has separate content for each weblog already set up, so I have thousands of if statements all over the site templates like this.

    {if simple_language = "English"}
    {weblog_content}
    {if:else}
    {weblog_content_fr}
    {/if}

    The problem I’m having is that the pagination links seem to be controlled by an entry in the DB. under their localization preferences.

    Is there a quick way to “toggle” this value?

  • #4 / Sep 26, 2008 3:44pm

    Greg Aker

    6022 posts

    Lavi Yatziv:

    To use your method & update the db to reflect the new language in the users profile is going to need some custom work.  I think it’s probably better suited in the “How To” forums, as you can get some feedback from the community.

    However, I’d start by looking at the dev docs

    Specifically the Session and database

    I think your best solution would be to write an addon to securely make the database update.

    I hope that gets you heading in the right direction.

    for a potentially easier solution, have you looked at the Languages category in the wiki?

    Regards,

    -greg

  • #5 / Mar 09, 2009 4:15pm

    Lavi Yatziv

    28 posts

    ::UPDATE::

    I think this is risky but it works enough to get pagination going…

    global $DB, $SESS, $IN;
    $this_user_id = $SESS->userdata['member_id'];
    $data = array('language' => $IN->global_vars['simple_language']);
    $sql = $DB->update_string('exp_members', $data, "member_id = $this_user_id"); // update lang
    $DB->query($sql);
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases