Index: trunk/extensions/Translate/groups/Mifos/Mifos.yaml |
— | — | @@ -2,8 +2,7 @@ |
3 | 3 | BASIC: |
4 | 4 | namespace: NS_MIFOS |
5 | 5 | class: FileBasedMessageGroup |
6 | | - description: > |
7 | | - {{int:translate-group-desc-mifos}} |
| 6 | + description: "{{int:translate-group-desc-mifos}}" |
8 | 7 | |
9 | 8 | FILES: |
10 | 9 | class: JavaFFS |
Index: trunk/extensions/Translate/utils/TranslateYaml.php |
— | — | @@ -60,14 +60,41 @@ |
61 | 61 | switch ( $wgTranslateYamlLibrary ) { |
62 | 62 | case 'spyc': |
63 | 63 | require_once( dirname( __FILE__ ) . '/../spyc/spyc.php' ); |
64 | | - return spyc_load( $text ); |
| 64 | + $yaml = spyc_load( $text ); |
| 65 | + return self::fixSpycSpaces( $yaml ); |
65 | 66 | case 'syck': |
66 | | - return self::syckLoad( $text ); |
| 67 | + $yaml = self::syckLoad( $text ); |
| 68 | + return self::fixSyckBooleans( $yaml ); |
| 69 | + case 'syck-pecl': |
| 70 | + $text = preg_replace( '~^(\s*)no(\s*:\s*[a-zA-Z-_]+\s*)$~m', '\1"no"\2', $text ); |
| 71 | + return syck_load( $text ); |
67 | 72 | default: |
68 | 73 | throw new MWException( "Unknown Yaml library" ); |
69 | 74 | } |
70 | 75 | } |
71 | 76 | |
| 77 | + public static function fixSyckBooleans( &$yaml ) { |
| 78 | + foreach ( $yaml as $key => &$value ) { |
| 79 | + if ( is_array( $value ) ) { |
| 80 | + self::fixSyckBooleans( $value ); |
| 81 | + } elseif ( $value === 'yes' ) { |
| 82 | + $value = true; |
| 83 | + } |
| 84 | + } |
| 85 | + return $yaml; |
| 86 | + } |
| 87 | + |
| 88 | + public static function fixSpycSpaces( &$yaml ) { |
| 89 | + foreach ( $yaml as $key => &$value ) { |
| 90 | + if ( is_array( $value ) ) { |
| 91 | + self::fixSpycSpaces( $value ); |
| 92 | + } elseif ( is_string( $value ) && $key === 'header' ) { |
| 93 | + $value = preg_replace( '~^\*~m', ' *', $value ). "\n"; |
| 94 | + } |
| 95 | + } |
| 96 | + return $yaml; |
| 97 | + } |
| 98 | + |
72 | 99 | public static function load( $file ) { |
73 | 100 | $text = file_get_contents( $file ); |
74 | 101 | |
— | — | @@ -83,6 +110,8 @@ |
84 | 111 | return Spyc::YAMLDump( $text ); |
85 | 112 | case 'syck': |
86 | 113 | return self::syckDump( $text ); |
| 114 | + case 'syck-pecl': |
| 115 | + return syck_dump( $text ); |
87 | 116 | default: |
88 | 117 | throw new MWException( "Unknown Yaml library" ); |
89 | 118 | } |