Skip to content

Instantly share code, notes, and snippets.

@andizer
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andizer/0d6422a91ebfcf0f193a to your computer and use it in GitHub Desktop.
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.
<?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 "&nbsp;&nbsp;&nbsp;&nbsp;'{$locale}',<br />";
}
echo ');';
echo "</code>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment