Skip to content

Instantly share code, notes, and snippets.

@pascalchevrel
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pascalchevrel/9623606 to your computer and use it in GitHub Desktop.
Save pascalchevrel/9623606 to your computer and use it in GitHub Desktop.
String Distribution for Firefox Aurora, based on data from Transvision
<?php
function cleanEntity($entity)
{
$component = explode('/', $entity);
array_pop($component); // suppress entity
$component = array_filter(
$component,
function($val) { return $val != 'chrome'; }
);
return implode('/', $component);
}
function excludeProducts($entity)
{
$component = explode('/', $entity);
if (in_array($component[0], ['chat', 'calendar', 'suite',
'mail', 'editor', 'extensions'] ))
{
return false;
}
return true;
}
include __DIR__ . '/TMX/aurora/en-US/cache_en-US.php';
$tmx = array_keys($tmx);
$tmx = array_map('cleanEntity', $tmx);
$tmx = array_filter($tmx, 'excludeProducts');
$results = [];
$devtools = 0;
foreach ($tmx as $val) {
$component = explode('/', $val);
$main_component = $component[0];
if (in_array('devtools', $component)) {
$devtools++;
}
if (! isset($results[$main_component])) {
$results[$main_component] = 1;
} else {
$results[$main_component] += 1;
}
}
foreach ($results as $component => $number) {
print $component . ' : ' . $number . '<br>';
}
print "(of which devtools: $devtools )<br>";
print 'Total: ' . count($tmx) . '<br>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment