https://www.mediawiki.org/wiki/Special:Code/MediaWiki/115451
Revision: 115451
Author: amire80
Date: 2012-05-28 19:04:31 +0000 (Mon, 28 May 2012)
Log Message:
-----------
Cleaned up and updated. Made it possible to add more products and not just the
browser, although new products will probably require more tweaks.
Modified Paths:
--------------
trunk/translatewiki/Mozilla/genMozilla.php
Modified: trunk/translatewiki/Mozilla/genMozilla.php
===================================================================
--- trunk/translatewiki/Mozilla/genMozilla.php 2012-05-28 06:12:41 UTC (rev
115450)
+++ trunk/translatewiki/Mozilla/genMozilla.php 2012-05-28 19:04:31 UTC (rev
115451)
@@ -15,6 +15,10 @@
// Array of supported products. Any of browser, calendar, chat, dom, editor,
// embedding, extensions, mail, mobile, netwerk, other-licenses, security,
// services, suite, toolkit.
+// Currently only browser.
+$products = array(
+ 'browser'
+);
// Folder below $projectFolder in which source files are.
$sourceFolder = 'en';
// File pattern for gettext template files.
@@ -26,25 +30,29 @@
// excluded files.
$excludedFiles = array(
'chrome/browser/browser.properties',
+ 'chrome/browser/feeds/subscribe.dtd',
+ 'chrome/browser/preferences/selectBookmark.dtd',
);
-$baseFolder = "$projectsFolder/$projectFolder/${sourceFolder}/";
+foreach ( $products as $product ) {
+ $baseFolder =
"$projectsFolder/$projectFolder/${sourceFolder}/$product/";
-foreach ( $fileTypes as $fileType ) {
- $output = '';
+ foreach ( $fileTypes as $fileType ) {
+ $output = '';
- $fileExtension = $fileType[0];
- $FFS = $fileType[1];
- $files = shell_exec( "find ${baseFolder} -name '*.${fileExtension}'" );
- $files = explode( "\n", $files );
- $files = array_filter( $files );
+ $fileExtension = $fileType[0];
+ $FFS = $fileType[1];
+ $findCmd = "find ${baseFolder} -name '*.${fileExtension}'";
+ $files = shell_exec( $findCmd );
+ $files = explode( "\n", $files );
+ $files = array_filter( $files );
- foreach ( $files as $index => $file ) {
- $files[$index] = str_replace( $baseFolder, '', $file );
- }
+ foreach ( $files as $index => $file ) {
+ $files[$index] = str_replace( $baseFolder, '', $file );
+ }
- // Template header for YAML config file.
- $header = <<<PHP
+ // Template header for YAML config file.
+ $header = <<<PHP
TEMPLATE:
BASIC:
description: "{{int:translate-group-desc-mozilla-browser}}"
@@ -68,62 +76,64 @@
PHP;
- $output .= $header . "\n";
+ $output .= $header . "\n";
- $localeFolder = "${projectFolder}/%CODE%/";
+ $localeFolder = "${projectFolder}/%CODE%/$product";
- asort( $files );
+ asort( $files );
- // Add config for each file.
- foreach ( $files as $file ) {
- // Exclude some files.
- if( in_array( $file, $excludedFiles ) ) {
- echo "$file\n";
- continue;
- }
+ // Add config for each file.
+ foreach ( $files as $file ) {
+ // Exclude some files.
+ if( in_array( $file, $excludedFiles ) ) {
+ echo "excluding $file\n";
+ continue;
+ }
+ echo "reading $file\n";
- // Strip extension from file name and break into parts for
plugin name.
- // Later on, used to create a group name.
- $groupName = explode( "/", str_replace( '.' . $fileExtension,
'', $file ) );
+ // Strip extension from file name and break into parts
for plugin name.
+ // Later on, used to create a group name.
+ $groupName = explode( "/", str_replace( '.' .
$fileExtension, '', $file ) );
- // File name in lower case.
- $fileL = strtolower( $file );
+ // File name in lower case.
+ $fileL = strtolower( $file );
- // Create group ID by replacing directory separators by dashes
after
- // file extension was stripped.
- $groupId = str_replace( "/", '-', $fileL );
- $groupId = str_replace( '.' . $fileExtension, '', $groupId );
- $groupId .= '-' . strtolower( $FFS );
+ // Create group ID by replacing directory separators by
dashes after
+ // file extension was stripped.
+ $groupId = str_replace( "/", '-', $fileL );
+ $groupId = str_replace( '.' . $fileExtension, '',
$groupId );
+ $groupId .= '-' . strtolower( $FFS );
- // Create a group name by concatenating the directory and file
name parts
- // after capitalising them.
- foreach ( $groupName as $index => $groupNamePart ) {
- $groupName[$index] = ucfirst( $groupNamePart );
+ // Create a group name by concatenating the directory
and file name parts
+ // after capitalising them.
+ foreach ( $groupName as $index => $groupNamePart ) {
+ $groupName[$index] = ucfirst( $groupNamePart );
+ }
+ $groupName = implode( ' - ', $groupName );
+ $groupName .= " - ${FFS}";
+
+ // Actual configuration.
+ $output .= "---\n";
+ $output .= "BASIC:\n";
+ $output .= " id: mozilla-${groupId}\n";
+ $output .= " label: Mozilla - ${groupName}\n";
+ $output .= "\n";
+ $output .= "FILES:\n";
+ $output .= " sourcePattern:
%GROUPROOT%/${localeFolder}/${file}\n";
+ $output .= " targetPattern: ${localeFolder}/${file}\n";
+ $output .= "\n";
+ // Mangler prefix based on group ID.
+ $output .= "MANGLER:\n";
+ $output .= " prefix: ${groupId}-\n";
+ $output .= "\n";
}
- $groupName = implode( ' - ', $groupName );
- $groupName .= " - ${FFS}";
- // Actual configuration.
- $output .= "---\n";
- $output .= "BASIC:\n";
- $output .= " id: mozilla-${groupId}\n";
- $output .= " label: Mozilla - ${groupName}\n";
- $output .= "\n";
- $output .= "FILES:\n";
- $output .= " sourcePattern:
%GROUPROOT%/${localeFolder}${file}\n";
- $output .= " targetPattern: ${localeFolder}${file}\n";
- $output .= "\n";
- // Mangler prefix based on group ID.
- $output .= "MANGLER:\n";
- $output .= " prefix: ${groupId}-\n";
- $output .= "\n";
+ // Write a file for each file type to Mozilla<FFSName>.yaml in
current
+ // directory.
+ $fp = fopen( "Mozilla${FFS}.yaml", 'w' );
+ fwrite( $fp, $output );
+ fclose( $fp );
}
-
- // Write a file for each file type to Mozilla<FFSName>.yaml in current
- // directory.
- $fp = fopen( "Mozilla${FFS}.yaml", 'w' );
- fwrite( $fp, $output );
- fclose( $fp );
}
echo "Done.\n";
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs