Sharing a multi-language website in Google+ - internationalization

I have a multi-language website which correctly detects the user language (the site's language changes accordingly), but can't be correctly shared in Google+.
The site exists in two languages, therefore I have set up two different sets of meta properties, one for each language:
English:
<link rel="canonical" href="http://en.perehana.com/"/>
<meta property="og:title" content="Perehana, the best way to find perfect gifts!"/>
<meta property="og:type" content="website"/>
<meta property="og:url" content="http://www.perehana.com"/>
<meta property="og:image" content="http://www.perehana.com/img/large-icon.jpg"/>
<meta property="og:site_name" content="Perehana"/>
<meta property="og:description" content="No gift ideas for Christmas, birthdays, weddings, births or any other event? Perehana allows you to enter gift ideas and to reserve your family and friends' ideas before buying them."/>
<meta property="og:locale" content="en_GB"/>
<meta property="fb:app_id" content="242045389185230"/>
<meta property="og:locale:alternate" content="fr_FR"/>
<meta itemprop="name" content="Perehana, the best way to find perfect gifts!"/>
<meta itemprop="description" content="No gift ideas for Christmas, birthdays, weddings, births or any other event? Perehana allows you to enter gift ideas and to reserve your family and friends' ideas before buying them."/>
<meta itemprop="image" content="http://www.perehana.com/img/square_logo.png"/>
French:
<link rel="canonical" href="http://fr.perehana.com/"/>
<meta property="og:title" content="Perehana, le meilleur moyen de faire plaisir à coup sûr !"/>
<meta property="og:type" content="website"/>
<meta property="og:url" content="http://www.perehana.com"/>
<meta property="og:image" content="http://www.perehana.com/img/large-icon.jpg"/>
<meta property="og:site_name" content="Perehana"/>
<meta property="og:description" content="En manque d'idées de cadeaux à l'approche de Noël, des anniversaires, des mariages ou des naissances ? Perehana est un site qui vous permet de saisir des idées-cadeaux et de réserver celles de votre famille et de vos amis. Vous pouvez ensuite aller les acheter sans qu'ils le sachent."/>
<meta property="og:locale" content="fr_FR"/>
<meta property="fb:app_id" content="242045389185230"/>
<meta property="og:locale:alternate" content="en_GB"/>
<meta itemprop="name" content="Perehana, le meilleur moyen de faire plaisir à coup sûr !"/>
<meta itemprop="description" content="En manque d'idées de cadeaux à l'approche de Noël, des anniversaires, des mariages ou des naissances ? Perehana vous permet de saisir des idées-cadeaux et de réserver celles de votre famille et de vos amis. Vous pouvez ensuite aller les acheter sans qu'ils le sachent."/>
<meta itemprop="image" content="http://www.perehana.com/img/square_logo.png"/>
As you can see, the locales and alternates are correctly set.
This is how I call the G+ API (this is an example for a French user):
<div class="g-plusone" data-size="medium" data-href="http://www.perehana.com"></div>
<script type="text/javascript">
window.___gcfg = {
lang: 'fr'
};
(function() {
var po = document.createElement('script'); po.type = 'text/javascript';
po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
According to the user's language, the correct properties are displayed.
The problem occurs when I want to share it via Google+, the title and description that Google automatically chooses for the site are in English, even if my G+ user account is in French... :-(
Thanks to anyone who can help!

I assume you're using the Accept-Language HTTP header to do this on your website.
The page fetcher used for sharing on to Google+ does not propagate any of the HTTP headers from the user who initiated the action, so your website will fall back to whatever the default language is.
You can work around this by using GET parameters to set the language. If you are sharing from the +1 button, share button or share link you can then set the current language into the target url parameter, data-href, for that plugin.
It looks like you've already filed a feature request for this in the Google+ issue tracker. If it wasn't you, star the issue to receive update notifications.

Related

Write a sentence In blade laravel 5.6

I want send description to page and if I don't send description use default from config file
in normal php I just write
<meta name="description" content="<?= if($replaceDescrption)?$replaceDescrption:$defaultDescrption">
how can I write this in laravel blade
<meta name="description" content="#if(yield('descrption'))?#yield('descrption'):{{config('app.description')}}">
I know I can send description with
#section('description',)
<meta name="description" content="replace des">
#endsection
put I need change in tow place
<meta property="og:description" content="#if(yield('descrption'))?#yield('descrption'):{{config('app.description')}}"/>
<meta name="description" content="#if(yield('descrption'))?#yield('descrption'):config('app.description')">
#yield takes default value for 2nd argument:
<meta property="og:description" content="#yield('description', config('app.description'))"/>

SplFileObject::SKIP_EMPTY does not work

I'm facing a huge difficulty right now. I did not succeed in finding how to fix it.
I'm trying to display csv datas without empty lines. I thought the SPL library could permit it. But whatever i do i can't find why it's not working.
Could you?
Here's my code (quite simple):
<?php
// Lecture du fichier csv
$csv = new SplFileObject('fichiers/tempo/test.csv', 'r');
// Flags pour ignorer les lignes vides
$csv->setFlags(SplFileObject::READ_CSV | SplFileObject::READ_AHEAD | SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE);
$csv->setCsvControl(';');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="style.css" />
<link rel="icon" type="image/png" href="images/favicon.png" />
<title>Nas - Insertion de données</title>
</head>
<body>
<table>
<?php
$tableau = array();
// On parcours les lignes du fichier csv en lecture ==> $csv
foreach($csv as $line){
echo '<tr>';
foreach($line as $var){
echo '<td>-'.$var.'</td>';
}
echo '</tr>';
}
?>
</table>
</body>
</html>
My flags do nothing, and i don't know what i'm doing wrong.....
Thank you.
You should use these flags to ignore empty lines:
$file->setFlags(
SplFileObject::READ_CSV |
SplFileObject::SKIP_EMPTY |
SplFileObject::READ_AHEAD |
SplFileObject::DROP_NEW_LINE
);
Thank you for your time. I tried with php 5.4, 5.5, 5.6 and 7.0 but it did nothing. Then i choose to put the following test to every loop:
foreach($csv as $line){
// Ignoring empty lines
if(implode($line) == null)continue;
...
At least it works!
My Csv is something like:
Wine List;;;;;;;;;;
;;;;;;;;;;
;This wine is stored at the chƒteau or at our supplier's warehouse and will be available for collection later on.;;;;;;;;;
;;;;;;;;;;
Product Type;Vintage;Wine;Appellation;Classement;Qty;Size;Price;W-A;W-S;Comments
Red wine;2013;Aiguilhe (d');Castillon - c“tes de bordeaux;;216;750 mL;11,80 ?;87-89s;86-89;
Red wine;2012;Aiguilhe (d');Castillon - c“tes de bordeaux;;168;750 mL;12,50 ?;89-91;89;
Red wine;2011;Aiguilhe (d');Castillon - c“tes de bordeaux;;395;750 mL;12,60 ?;88;89;

How do I repeat the form POST request programmatically

When I visit the site http://www.jetstar.com/au/en/home
And fill the form then submit.
It will send a POST request then redirect me to new page show the ticket price page(HTML).
I can get the expected result in the second GET response
However, When I try to repeat the POST request with Ruby or Charles
I will get 302 Found error.
I don't get it.
Ruby
q_prams = {
"ControlGroupSearchView$AvailabilitySearchInputSearchView$DropDownListFareTypes" =>"I",
"ControlGroupSearchView$AvailabilitySearchInputSearchView$DropDownListMarketDay1" =>"9",
~~~
"pageToken" =>"sLkmnwXwAsY=",
"ControlGroupSearchView$AvailabilitySearchInputSearchView$fromCS" =>"yes"
}
res = RestClient.post 'https://booknow.jetstar.com/Search.aspx', q_prams
POST request params
ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListCurrency=&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListFareTypes=I&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketDay1=18&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketDay2=1&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketDay3=&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketMonth1=2015-6&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketMonth2=1968-1&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketMonth3=&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListPassengerType_ADT=1&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListPassengerType_CHD=0&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListPassengerType_INFANT=0&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24RadioButtonMarketStructure=OneWay&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24TextBoxMarketDestination1=MEL&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24TextBoxMarketDestination2=&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24TextBoxMarketDestination3=&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24TextBoxMarketOrigin1=NAN&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24TextBoxMarketOrigin2=&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24TextBoxMarketOrigin3=&ControlGroupSearchView%24ButtonSubmit=&__VIEWSTATE=&culture=en-AU&date_picker=&go-booking=&pageToken=sLkmnwXwAsY%3D&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24fromCS=yes&_pe_39b5379c652b_9df496572198=null&locale=en-AU
The first time response (SUCCESS) but cat not repeat it programmatically
<!doctype html><!--paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/--><!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]--><!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]--><!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]--><!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]--><!--[if (gt IE 9)|!(IE)]><!--><html lang="en" class="no-js"><!--<![endif]--><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head class="SB">
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Jetstar Airways Cheap Flights, Low Fares all day everyday from the world's best Cheap Fare airline</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/ico">
<link rel="SHORTCUT ICON" href="favicon.ico">
...
This is most probably because of the CSRF verification, Sites users CSRF to validate the request to make sure the form submission came from the same site.
In your case, you try to submit a form from a different source and hence the verification fails.
If you want to do the above, I recon to do a screen scraping by using a library like capybara
read more about CSRF here

Twitter Card Validation

Can anybody see whats wrong with this code, to say why this isnt validating using
https://dev.twitter.com/docs/cards/validation/validator
<meta name="twitter:card" content="product">
<meta name="twitter:site" content="#Agora_snapbacks">
<meta name="twitter:creator" content="#Agora_snapbacks">
<meta name="twitter:title" content="Agora Black Beanie">
<meta name="twitter:description" content="View our varied collection of beanies by Agora">
<meta name="twitter:image:src" content="http://agoraclothing.com/images/detailed/1/LOGOB_BLACK.JPG">
<meta name="twitter:data1" content="29.99">
<meta name="twitter:label1" content="Price">
<meta name="twitter:data2" content="United Kingdom">
<meta name="twitter:label2" content="Locaion">
http://agoraclothing.com/shop/hats/beanies/agora-black-beanie.html
Your issue may be in the price/data1 field. You may have to add the pound symbol before 29.99. I can't be positive but it's worth a try. --David

Mettre des accents français dans des fichiers - Put the french accents in HTML files (RoR)

I have a problem with encoding. I want to add french accents in HTML files.
I'm on Ubuntu and my editor is SciTE.
This is a Ruby on Rails program.
ActionView::WrongEncodingError in Look#input
Your template was not saved as valid UTF-8. Please either specify UTF-8 as the
encoding for your template in your text editor, or mark the template with its
encoding by inserting the following as the first line of the template:
encoding: .
The source of your template was:
<!DOCTYPE html>
<meta charset="UFT-8"/>
<head>
<meta http-equiv="content-type" content="text/html"; charset="utf8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<!-- ... autres mentions de l'entête de fichier ... -->
</head>
<html>
<head>
<title>Projet 3textfields, fichier input.rhtml</title>
</head>
<body>
<h1>Les champs de saisie (champs de texte) version 3</h1>
<br>
Cette application Ruby on Rails lit du texte saisi.
<br>
<br>
Elle transmet la variable au mod�le.
<br>
<%= start_form_tag :action => 'at', :method => get %>
Veuillez saisir votre nom.
<br>
<%= text_field "cruncher", "crunch", :size => 30%>
<br>
<br>
<input type="submit"/>
<%= end_form_tag %>
</body>
</html>
It should be <meta charset="UTF-8" />. Note that you have UFT-8.
I am not familiar with SciTE. Is it UTF-8 compatible?
May be it's related to utf-8 encoding not being recognised in ruby file (and by ActionView in that case). You may have to put this line at the top of each file containing non-ascii characters :
# encoding: utf-8

Resources