Last active
August 29, 2015 14:16
-
-
Save andizer/0d6422a91ebfcf0f193a to your computer and use it in GitHub Desktop.
Compare a list of locales with the actual xml file on facebook to check for new additions.
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 | |
// This list is not actual, because it's shortened | |
$fb_valid_fb_locales = array( | |
'ca_ES', | |
'cs_CZ', | |
'cy_GB', | |
'da_DK', | |
'de_DE', | |
'eu_ES', | |
'en_PI', | |
'en_UD', | |
'ck_US', | |
); | |
function facebook_locale_compare($fb_valid_fb_locales) { | |
$xml = simplexml_load_file( 'https://www.facebook.com/translations/FacebookLocales.xml' ); | |
foreach ( $xml->locale AS $locale ) { | |
if ( ! in_array( $locale->codes->code->standard->representation, $fb_valid_fb_locales ) ) { | |
$new_fb_locales[] = (string) $locale->codes->code->standard->representation; | |
} | |
} | |
if ( ! empty( $new_fb_locales ) ) { | |
$fb_valid_fb_locales = array_merge( $fb_valid_fb_locales, $new_fb_locales ); | |
echo "<h1>There are some differences!</h1>"; | |
echo "<p>Number of additions: ".count($new_fb_locales)."</p>"; | |
echo "<h2>New array to copy:</h2>"; | |
echo "<code>"; | |
echo '$fb_valid_fb_locales = array(<br />'; | |
foreach ( $fb_valid_fb_locales as $locale ) { | |
echo " '{$locale}',<br />"; | |
} | |
echo ');'; | |
echo "</code>"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment