Created
August 28, 2015 04:04
-
-
Save maruware/a8edb2cb7e66848ff9c8 to your computer and use it in GitHub Desktop.
og locales
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$locale_tags = [ | |
'en_US'=>[ | |
'title'=>'hello', | |
'description'=>'hello world' | |
], | |
'fr_FR'=>[ | |
'title'=>'Bonjour', | |
'description'=>'Bonjour tout le monde' | |
], | |
'ja_JP'=>[ | |
'title'=>'こんにちは', | |
'description'=>'こんにちは世界' | |
] | |
]; | |
$curr_locale = 'en_US';//default | |
if( isset($_REQUEST['locale']) ){ | |
$curr_locale = $_REQUEST['locale']; | |
} | |
if( !isset($locale_tags[$curr_locale]) ){ | |
throw new Exception('Bad locale'); | |
} | |
?> | |
<html> | |
<head> | |
<meta property="og:locale" content="<?=$curr_locale?>" /> | |
<?php foreach($locale_tags as $locale=>$tags): ?> | |
<?php if( $locale === $curr_locale ) continue; ?> | |
<meta property="og:locale:alternate" content="<?=$locale?>" /> | |
<?php endforeach; ?> | |
<meta property="og:title" content="<?=$locale_tags[$curr_locale]['title']?>" /> | |
<meta property="og:description" content="<?=$locale_tags[$curr_locale]['description']?>" /> | |
</head> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment