Nikerabbit has uploaded a new change for review. https://gerrit.wikimedia.org/r/152285
Change subject: Add support for phpyaml driver ...................................................................... Add support for phpyaml driver Thanks to Joel Sahleen for mentioning this. Change-Id: Ic6ecf925c94be9ec9ac960d3bc385258b6f81948 --- M Translate.php M scripts/yaml-tests.php M utils/TranslateYaml.php 3 files changed, 15 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate refs/changes/85/152285/1 diff --git a/Translate.php b/Translate.php index fd3f6d3..1b88f36 100644 --- a/Translate.php +++ b/Translate.php @@ -552,7 +552,9 @@ # ==== YAML driver ==== # <source lang=php> /** - * Currently supported YAML drivers are spyc and syck. + * Currently supported YAML drivers are phpyaml, spyc and syck. + * + * For phpyaml see http://php.net/manual/en/book.yaml.php. * * For syck we're shelling out to perl. So you need: * @@ -568,6 +570,10 @@ * For the shell to work, you also need an en.UTF-8 locale installed on your system. * add a line "en.UTF-8" to your /etc/locale.gen or uncomment an existing one and run locale-gen * if you do not have it already. + * + * phpyaml is the fastest and based on libyaml so the output should be most + * compatible. spyc output format is least compatible. syck is slowest but + * almost as good as phpyaml. */ $GLOBALS['wgTranslateYamlLibrary'] = 'spyc'; diff --git a/scripts/yaml-tests.php b/scripts/yaml-tests.php index a1a44bc..905b8a7 100644 --- a/scripts/yaml-tests.php +++ b/scripts/yaml-tests.php @@ -31,7 +31,7 @@ $mems = array(); $mempeaks = array(); - foreach ( array( 'syck', 'spyc' ) as $driver ) { + foreach ( array( 'syck', 'spyc', 'phpyaml' ) as $driver ) { $mempeaks[$driver] = -memory_get_peak_usage( true ); $mems[$driver] = -memory_get_usage( true ); $times[$driver] = -microtime( true ); @@ -49,6 +49,7 @@ self::sortNestedArrayAssoc( $documents[$driver] ); file_put_contents( "yaml-test-$driver.txt", var_export( $documents[$driver], true ) ); + file_put_contents( "yaml-output-$driver.txt", TranslateYaml::dump( $documents[$driver] ) ); } var_dump( $times ); var_dump( $mems ); diff --git a/utils/TranslateYaml.php b/utils/TranslateYaml.php index a6dd1c5..d3ae363 100644 --- a/utils/TranslateYaml.php +++ b/utils/TranslateYaml.php @@ -73,6 +73,9 @@ global $wgTranslateYamlLibrary; switch ( $wgTranslateYamlLibrary ) { + case 'phpyaml': + return yaml_parse( $text ); + case 'spyc': // Load the bundled version if not otherwise available if ( !class_exists( 'Spyc' ) ) { @@ -132,6 +135,9 @@ global $wgTranslateYamlLibrary; switch ( $wgTranslateYamlLibrary ) { + case 'phpyaml': + return yaml_emit( $text, YAML_UTF8_ENCODING ); + case 'spyc': require_once __DIR__ . '/../libs/spyc/spyc.php'; -- To view, visit https://gerrit.wikimedia.org/r/152285 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic6ecf925c94be9ec9ac960d3bc385258b6f81948 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: Nikerabbit <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
