Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to share the page to facebook / twitter with different language?

I am using codeigniter and the language is determine by the session.

I wrrite the meta data, facebook / twitter grab the data and share the page:

        echo "<meta name='twitter:card' content='summary' />";
        echo "<meta property='og:title' content='" . $video->{set_lang("title")} . "' />";
        echo "<meta property='og:description' content='" . $video->{set_lang("description")} . "' />";
        echo "<meta property='og:image' content='" . (isset($video->image_url) ? site_url("thumbnail/" . $video->image_url) : $video->thumbnail) . "' />";

The set_lang function is to check the session like this:

function set_lang($var) {
    $CI = & get_instance();
    $lang = $CI->session->userdata('site_lang');
    if ($lang == "english") {
        return $var;
    } else if ($lang == "zh_tw") {
        return $var . "_tw";
    } else if ($lang == "zh_cn") {
        return $var . "_cn";
    }
}

The share function work fine in the browser, however, I would like to share the link by mobile app too. Since the app contain no session it can not check language. Also, if I put the parameter in the link, eg.

http://example.com/video/view/1/english

Then my share link will also fix the language.

Any ideas ? Thanks a lot for helping.

like image 316
user3538235 Avatar asked Aug 20 '15 02:08

user3538235


1 Answers

Have you explored the internationalization documentation?

Using og:locale:alternate meta tags (one pointing to each language) should show the link in the Facebook users native language across Facebook.com.

Try it out :D

like image 177
Tom Waddington Avatar answered Sep 23 '22 13:09

Tom Waddington