r73286 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73285‎ | r73286 | r73287 >
Date:13:47, 18 September 2010
Author:siebrand
Status:deferred
Tags:
Comment:
Rename script file
Modified paths:
  • /trunk/extensions/Translate/scripts/genStatusNet-plugins.php (added) (history)
  • /trunk/extensions/Translate/scripts/genStatusNetPluginsConfig.php (deleted) (history)

Diff [purge]

Index: trunk/extensions/Translate/scripts/genStatusNetPluginsConfig.php
@@ -1,101 +0,0 @@
2 -<?php
3 -/**
4 - * Quick script to generate YAML configuration for StatusNet plugins.
5 - *
6 - * @todo Use Maitenance class and add target option for writing output file.
7 - */
8 -
9 -$plugins = array();
10 -
11 -function getPotFiles( $path, $pattern ) {
12 - global $plugins;
13 -
14 - $path = rtrim( str_replace( "\\", "/", $path ), '/' ) . '/';
15 - $matches = Array();
16 - $entries = Array();
17 - $dir = dir( $path );
18 - while ( false !== ( $entry = $dir->read() ) ) {
19 - $entries[] = $entry;
20 - }
21 - $dir->close();
22 - foreach ( $entries as $entry ) {
23 - $fullname = $path . $entry;
24 - if ( $entry != '.' && $entry != '..' && is_dir( $fullname ) ) {
25 - $subFolderResults = getPotFiles( $fullname, $pattern );
26 - } else if ( is_file( $fullname ) && preg_match( $pattern, $entry ) ) {
27 - $pathParts = explode( '/', $fullname );
28 - $plugins[] = substr( array_pop( $pathParts ), 0, -4 );
29 - }
30 - }
31 -}
32 -
33 -$baseFolder = '/home/betawiki/projects/statusnet/plugins/';
34 -$filePattern = '/[.]pot$/';
35 -
36 -getPotFiles( $baseFolder, $filePattern );
37 -
38 -$header = <<<PHP
39 -TEMPLATE:
40 - BASIC:
41 - description: "{{int:translate-group-desc-statusnet-plugin}}"
42 - namespace: NS_STATUSNET
43 - display: out/statusnet/
44 - class: FileBasedMessageGroup
45 -
46 - FILES:
47 - class: GettextFFS
48 - codeMap:
49 - en-gb: en_GB
50 - en-us: en_US
51 - nl-be: nl_BE
52 - no: nb
53 - pt-br: pt_BR
54 - zh-hans: zh_CN
55 - zh-hant: zh_TW
56 -
57 - header: |
58 - # This file is distributed under the same license as the StatusNet package.
59 - #
60 -
61 - MANGLER:
62 - class: StringMatcher
63 - patterns:
64 - - "*"
65 -
66 - CHECKER:
67 - class: MessageChecker
68 - checks:
69 - - printfCheck
70 -PHP;
71 -
72 -echo $header . "\n";
73 -
74 -$basePluginFolder = "statusnet/plugins/";
75 -$localeFolder = "/locale/%CODE%/LC_MESSAGES/";
76 -
77 -asort( $plugins );
78 -$numberPlugins = count( $plugins );
79 -$count = 0;
80 -
81 -foreach ( $plugins as $plugin ) {
82 - $pluginL = strtolower( $plugin );
83 -
84 - echo "BASIC:\n";
85 - echo " id: out-statusnet-plugin-" . $pluginL . "\n";
86 - echo " label: StatusNet - " . $plugin . "\n";
87 - echo " display: out/statusnet/plugin/" . $pluginL . "\n";
88 - echo " codeBrowser: http://gitorious.org/statusnet/mainline/blobs/0.9.x/plugins/" . $plugin . "/%FILE%#line%LINE%\n\n";
89 - echo "FILES:\n";
90 - echo " sourcePattern: %GROUPROOT%/" . $basePluginFolder . $plugin . $localeFolder . $plugin . ".po\n";
91 - echo " definitionFile: %GROUPROOT%/" . $basePluginFolder . $plugin . "/locale/" . $plugin . ".pot\n";
92 - echo " targetPattern: " . $basePluginFolder . $plugin . $localeFolder . $plugin . ".po\n\n";
93 - echo "MANGLER:\n";
94 - echo " prefix: " . $pluginL . "-\n";
95 -
96 - $count++;
97 -
98 - if ( $count < $numberPlugins ) {
99 - echo "---\n";
100 - }
101 -}
Index: trunk/extensions/Translate/scripts/genStatusNet-plugins.php
@@ -0,0 +1,101 @@
 2+<?php
 3+/**
 4+ * Quick script to generate YAML configuration for StatusNet plugins.
 5+ *
 6+ * @todo Use Maitenance class and add target option for writing output file.
 7+ */
 8+
 9+$plugins = array();
 10+
 11+function getPotFiles( $path, $pattern ) {
 12+ global $plugins;
 13+
 14+ $path = rtrim( str_replace( "\\", "/", $path ), '/' ) . '/';
 15+ $matches = Array();
 16+ $entries = Array();
 17+ $dir = dir( $path );
 18+ while ( false !== ( $entry = $dir->read() ) ) {
 19+ $entries[] = $entry;
 20+ }
 21+ $dir->close();
 22+ foreach ( $entries as $entry ) {
 23+ $fullname = $path . $entry;
 24+ if ( $entry != '.' && $entry != '..' && is_dir( $fullname ) ) {
 25+ $subFolderResults = getPotFiles( $fullname, $pattern );
 26+ } else if ( is_file( $fullname ) && preg_match( $pattern, $entry ) ) {
 27+ $pathParts = explode( '/', $fullname );
 28+ $plugins[] = substr( array_pop( $pathParts ), 0, -4 );
 29+ }
 30+ }
 31+}
 32+
 33+$baseFolder = '/home/betawiki/projects/statusnet/plugins/';
 34+$filePattern = '/[.]pot$/';
 35+
 36+getPotFiles( $baseFolder, $filePattern );
 37+
 38+$header = <<<PHP
 39+TEMPLATE:
 40+ BASIC:
 41+ description: "{{int:translate-group-desc-statusnet-plugin}}"
 42+ namespace: NS_STATUSNET
 43+ display: out/statusnet/
 44+ class: FileBasedMessageGroup
 45+
 46+ FILES:
 47+ class: GettextFFS
 48+ codeMap:
 49+ en-gb: en_GB
 50+ en-us: en_US
 51+ nl-be: nl_BE
 52+ no: nb
 53+ pt-br: pt_BR
 54+ zh-hans: zh_CN
 55+ zh-hant: zh_TW
 56+
 57+ header: |
 58+ # This file is distributed under the same license as the StatusNet package.
 59+ #
 60+
 61+ MANGLER:
 62+ class: StringMatcher
 63+ patterns:
 64+ - "*"
 65+
 66+ CHECKER:
 67+ class: MessageChecker
 68+ checks:
 69+ - printfCheck
 70+---
 71+PHP;
 72+
 73+echo $header . "\n";
 74+
 75+$basePluginFolder = "statusnet/plugins/";
 76+$localeFolder = "/locale/%CODE%/LC_MESSAGES/";
 77+
 78+asort( $plugins );
 79+$numberPlugins = count( $plugins );
 80+$count = 0;
 81+
 82+foreach ( $plugins as $plugin ) {
 83+ $pluginL = strtolower( $plugin );
 84+
 85+ echo "BASIC:\n";
 86+ echo " id: out-statusnet-plugin-" . $pluginL . "\n";
 87+ echo " label: StatusNet - " . $plugin . "\n";
 88+ echo " display: out/statusnet/plugin/" . $pluginL . "\n";
 89+ echo " codeBrowser: http://gitorious.org/statusnet/mainline/blobs/0.9.x/plugins/" . $plugin . "/%FILE%#line%LINE%\n\n";
 90+ echo "FILES:\n";
 91+ echo " sourcePattern: %GROUPROOT%/" . $basePluginFolder . $plugin . $localeFolder . $plugin . ".po\n";
 92+ echo " definitionFile: %GROUPROOT%/" . $basePluginFolder . $plugin . "/locale/" . $plugin . ".pot\n";
 93+ echo " targetPattern: " . $basePluginFolder . $plugin . $localeFolder . $plugin . ".po\n\n";
 94+ echo "MANGLER:\n";
 95+ echo " prefix: " . $pluginL . "-\n";
 96+
 97+ $count++;
 98+
 99+ if ( $count < $numberPlugins ) {
 100+ echo "---\n";
 101+ }
 102+}
Property changes on: trunk/extensions/Translate/scripts/genStatusNet-plugins.php
___________________________________________________________________
Added: svn:eol-style
1103 + native
Added: svn:keywords
2104 + Id

Follow-up revisions

RevisionCommit summaryAuthorDate
r73287Move script to where the file is it can create....siebrand13:48, 18 September 2010

Status & tagging log