From fc7369835258467bf97eb64f184b93691f9a9fd5 Mon Sep 17 00:00:00 2001 From: Yaco Date: Thu, 4 Jun 2020 11:01:00 -0300 Subject: first commit --- .../extensions/LocalisationUpdate/Autoload.php | 28 ++ .../LocalisationUpdate/CODE_OF_CONDUCT.md | 1 + www/wiki/extensions/LocalisationUpdate/COPYING | 339 +++++++++++++++++++++ .../extensions/LocalisationUpdate/Gruntfile.js | 28 ++ .../LocalisationUpdate.class.php | 65 ++++ .../LocalisationUpdate/LocalisationUpdate.php | 15 + .../LocalisationUpdate/QuickArrayReader.php | 214 +++++++++++++ www/wiki/extensions/LocalisationUpdate/README | 34 +++ www/wiki/extensions/LocalisationUpdate/Updater.php | 195 ++++++++++++ .../extensions/LocalisationUpdate/composer.json | 55 ++++ .../extensions/LocalisationUpdate/extension.json | 55 ++++ .../LocalisationUpdate/fetcher/Fetcher.php | 28 ++ .../LocalisationUpdate/fetcher/FetcherFactory.php | 25 ++ .../fetcher/FileSystemFetcher.php | 37 +++ .../LocalisationUpdate/fetcher/GitHubFetcher.php | 41 +++ .../LocalisationUpdate/fetcher/HttpFetcher.php | 42 +++ .../LocalisationUpdate/finder/Finder.php | 109 +++++++ .../extensions/LocalisationUpdate/i18n/af.json | 8 + .../extensions/LocalisationUpdate/i18n/ar.json | 8 + .../extensions/LocalisationUpdate/i18n/ast.json | 8 + .../extensions/LocalisationUpdate/i18n/ba.json | 8 + .../extensions/LocalisationUpdate/i18n/bar.json | 8 + .../LocalisationUpdate/i18n/be-tarask.json | 9 + .../extensions/LocalisationUpdate/i18n/bg.json | 8 + .../extensions/LocalisationUpdate/i18n/bn.json | 8 + .../extensions/LocalisationUpdate/i18n/br.json | 8 + .../extensions/LocalisationUpdate/i18n/bs.json | 8 + .../extensions/LocalisationUpdate/i18n/ca.json | 9 + .../extensions/LocalisationUpdate/i18n/ce.json | 8 + .../extensions/LocalisationUpdate/i18n/cs.json | 8 + .../extensions/LocalisationUpdate/i18n/cy.json | 8 + .../extensions/LocalisationUpdate/i18n/da.json | 8 + .../extensions/LocalisationUpdate/i18n/de.json | 11 + .../extensions/LocalisationUpdate/i18n/dsb.json | 8 + .../extensions/LocalisationUpdate/i18n/el.json | 8 + .../extensions/LocalisationUpdate/i18n/en.json | 9 + .../extensions/LocalisationUpdate/i18n/eo.json | 8 + .../extensions/LocalisationUpdate/i18n/es.json | 9 + .../extensions/LocalisationUpdate/i18n/et.json | 8 + .../extensions/LocalisationUpdate/i18n/eu.json | 8 + .../extensions/LocalisationUpdate/i18n/fa.json | 8 + .../extensions/LocalisationUpdate/i18n/fi.json | 9 + .../extensions/LocalisationUpdate/i18n/fr.json | 8 + .../extensions/LocalisationUpdate/i18n/gl.json | 8 + .../extensions/LocalisationUpdate/i18n/gsw.json | 8 + .../extensions/LocalisationUpdate/i18n/gu.json | 8 + .../extensions/LocalisationUpdate/i18n/he.json | 8 + .../extensions/LocalisationUpdate/i18n/hil.json | 8 + .../extensions/LocalisationUpdate/i18n/hr.json | 8 + .../extensions/LocalisationUpdate/i18n/hsb.json | 8 + .../extensions/LocalisationUpdate/i18n/hu.json | 8 + .../extensions/LocalisationUpdate/i18n/ia.json | 8 + .../extensions/LocalisationUpdate/i18n/id.json | 8 + .../extensions/LocalisationUpdate/i18n/ilo.json | 8 + .../extensions/LocalisationUpdate/i18n/it.json | 8 + .../extensions/LocalisationUpdate/i18n/ja.json | 9 + .../extensions/LocalisationUpdate/i18n/km.json | 8 + .../extensions/LocalisationUpdate/i18n/ko.json | 9 + .../extensions/LocalisationUpdate/i18n/ksh.json | 8 + .../extensions/LocalisationUpdate/i18n/lb.json | 9 + .../extensions/LocalisationUpdate/i18n/lij.json | 8 + .../extensions/LocalisationUpdate/i18n/mk.json | 9 + .../extensions/LocalisationUpdate/i18n/ml.json | 8 + .../extensions/LocalisationUpdate/i18n/ms.json | 8 + .../extensions/LocalisationUpdate/i18n/nb.json | 10 + .../extensions/LocalisationUpdate/i18n/nl.json | 8 + .../extensions/LocalisationUpdate/i18n/nn.json | 8 + .../extensions/LocalisationUpdate/i18n/oc.json | 8 + .../extensions/LocalisationUpdate/i18n/pl.json | 8 + .../extensions/LocalisationUpdate/i18n/pms.json | 8 + .../extensions/LocalisationUpdate/i18n/pt-br.json | 8 + .../extensions/LocalisationUpdate/i18n/pt.json | 10 + .../extensions/LocalisationUpdate/i18n/qqq.json | 12 + .../extensions/LocalisationUpdate/i18n/ro.json | 8 + .../LocalisationUpdate/i18n/roa-tara.json | 8 + .../extensions/LocalisationUpdate/i18n/ru.json | 8 + .../extensions/LocalisationUpdate/i18n/sk.json | 8 + .../extensions/LocalisationUpdate/i18n/sr-ec.json | 8 + .../extensions/LocalisationUpdate/i18n/sr-el.json | 8 + .../extensions/LocalisationUpdate/i18n/su.json | 8 + .../extensions/LocalisationUpdate/i18n/sv.json | 8 + .../extensions/LocalisationUpdate/i18n/ta.json | 8 + .../extensions/LocalisationUpdate/i18n/te.json | 8 + .../extensions/LocalisationUpdate/i18n/tl.json | 8 + .../extensions/LocalisationUpdate/i18n/tr.json | 8 + .../extensions/LocalisationUpdate/i18n/uk.json | 8 + .../extensions/LocalisationUpdate/i18n/vep.json | 8 + .../extensions/LocalisationUpdate/i18n/vi.json | 8 + .../extensions/LocalisationUpdate/i18n/wa.json | 8 + .../extensions/LocalisationUpdate/i18n/yi.json | 8 + .../extensions/LocalisationUpdate/i18n/yue.json | 8 + .../LocalisationUpdate/i18n/zh-hans.json | 8 + .../LocalisationUpdate/i18n/zh-hant.json | 10 + .../includes/LocalisationUpdate.php | 73 +++++ .../includes/QuickArrayReader.php | 214 +++++++++++++ .../LocalisationUpdate/includes/Updater.php | 204 +++++++++++++ .../includes/fetcher/Fetcher.php | 30 ++ .../includes/fetcher/FetcherFactory.php | 25 ++ .../includes/fetcher/FileSystemFetcher.php | 47 +++ .../includes/fetcher/GitHubFetcher.php | 47 +++ .../includes/fetcher/HttpFetcher.php | 49 +++ .../LocalisationUpdate/includes/finder/Finder.php | 124 ++++++++ .../includes/reader/JSONReader.php | 37 +++ .../includes/reader/PHPReader.php | 61 ++++ .../LocalisationUpdate/includes/reader/Reader.php | 21 ++ .../includes/reader/ReaderFactory.php | 38 +++ www/wiki/extensions/LocalisationUpdate/phpcs.xml | 15 + .../LocalisationUpdate/reader/JSONReader.php | 32 ++ .../LocalisationUpdate/reader/PHPReader.php | 56 ++++ .../LocalisationUpdate/reader/Reader.php | 21 ++ .../LocalisationUpdate/reader/ReaderFactory.php | 38 +++ .../LocalisationUpdate/tests/phan/config.php | 3 + .../LocalisationUpdate/tests/phpunit/Makefile | 12 + .../tests/phpunit/UpdaterTest.php | 89 ++++++ .../tests/phpunit/finder/FinderTest.php | 86 ++++++ .../tests/phpunit/reader/JSONReaderTest.php | 42 +++ .../tests/phpunit/reader/ReaderFactoryTest.php | 43 +++ www/wiki/extensions/LocalisationUpdate/update.php | 93 ++++++ 118 files changed, 3441 insertions(+) create mode 100644 www/wiki/extensions/LocalisationUpdate/Autoload.php create mode 100644 www/wiki/extensions/LocalisationUpdate/CODE_OF_CONDUCT.md create mode 100644 www/wiki/extensions/LocalisationUpdate/COPYING create mode 100644 www/wiki/extensions/LocalisationUpdate/Gruntfile.js create mode 100644 www/wiki/extensions/LocalisationUpdate/LocalisationUpdate.class.php create mode 100644 www/wiki/extensions/LocalisationUpdate/LocalisationUpdate.php create mode 100644 www/wiki/extensions/LocalisationUpdate/QuickArrayReader.php create mode 100644 www/wiki/extensions/LocalisationUpdate/README create mode 100644 www/wiki/extensions/LocalisationUpdate/Updater.php create mode 100644 www/wiki/extensions/LocalisationUpdate/composer.json create mode 100644 www/wiki/extensions/LocalisationUpdate/extension.json create mode 100644 www/wiki/extensions/LocalisationUpdate/fetcher/Fetcher.php create mode 100644 www/wiki/extensions/LocalisationUpdate/fetcher/FetcherFactory.php create mode 100644 www/wiki/extensions/LocalisationUpdate/fetcher/FileSystemFetcher.php create mode 100644 www/wiki/extensions/LocalisationUpdate/fetcher/GitHubFetcher.php create mode 100644 www/wiki/extensions/LocalisationUpdate/fetcher/HttpFetcher.php create mode 100644 www/wiki/extensions/LocalisationUpdate/finder/Finder.php create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/af.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/ar.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/ast.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/ba.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/bar.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/be-tarask.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/bg.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/bn.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/br.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/bs.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/ca.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/ce.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/cs.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/cy.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/da.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/de.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/dsb.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/el.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/en.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/eo.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/es.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/et.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/eu.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/fa.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/fi.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/fr.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/gl.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/gsw.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/gu.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/he.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/hil.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/hr.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/hsb.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/hu.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/ia.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/id.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/ilo.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/it.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/ja.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/km.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/ko.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/ksh.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/lb.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/lij.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/mk.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/ml.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/ms.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/nb.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/nl.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/nn.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/oc.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/pl.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/pms.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/pt-br.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/pt.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/qqq.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/ro.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/roa-tara.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/ru.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/sk.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/sr-ec.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/sr-el.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/su.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/sv.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/ta.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/te.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/tl.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/tr.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/uk.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/vep.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/vi.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/wa.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/yi.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/yue.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/zh-hans.json create mode 100644 www/wiki/extensions/LocalisationUpdate/i18n/zh-hant.json create mode 100644 www/wiki/extensions/LocalisationUpdate/includes/LocalisationUpdate.php create mode 100644 www/wiki/extensions/LocalisationUpdate/includes/QuickArrayReader.php create mode 100644 www/wiki/extensions/LocalisationUpdate/includes/Updater.php create mode 100644 www/wiki/extensions/LocalisationUpdate/includes/fetcher/Fetcher.php create mode 100644 www/wiki/extensions/LocalisationUpdate/includes/fetcher/FetcherFactory.php create mode 100644 www/wiki/extensions/LocalisationUpdate/includes/fetcher/FileSystemFetcher.php create mode 100644 www/wiki/extensions/LocalisationUpdate/includes/fetcher/GitHubFetcher.php create mode 100644 www/wiki/extensions/LocalisationUpdate/includes/fetcher/HttpFetcher.php create mode 100644 www/wiki/extensions/LocalisationUpdate/includes/finder/Finder.php create mode 100644 www/wiki/extensions/LocalisationUpdate/includes/reader/JSONReader.php create mode 100644 www/wiki/extensions/LocalisationUpdate/includes/reader/PHPReader.php create mode 100644 www/wiki/extensions/LocalisationUpdate/includes/reader/Reader.php create mode 100644 www/wiki/extensions/LocalisationUpdate/includes/reader/ReaderFactory.php create mode 100644 www/wiki/extensions/LocalisationUpdate/phpcs.xml create mode 100644 www/wiki/extensions/LocalisationUpdate/reader/JSONReader.php create mode 100644 www/wiki/extensions/LocalisationUpdate/reader/PHPReader.php create mode 100644 www/wiki/extensions/LocalisationUpdate/reader/Reader.php create mode 100644 www/wiki/extensions/LocalisationUpdate/reader/ReaderFactory.php create mode 100644 www/wiki/extensions/LocalisationUpdate/tests/phan/config.php create mode 100644 www/wiki/extensions/LocalisationUpdate/tests/phpunit/Makefile create mode 100644 www/wiki/extensions/LocalisationUpdate/tests/phpunit/UpdaterTest.php create mode 100644 www/wiki/extensions/LocalisationUpdate/tests/phpunit/finder/FinderTest.php create mode 100644 www/wiki/extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php create mode 100644 www/wiki/extensions/LocalisationUpdate/tests/phpunit/reader/ReaderFactoryTest.php create mode 100644 www/wiki/extensions/LocalisationUpdate/update.php (limited to 'www/wiki/extensions/LocalisationUpdate') diff --git a/www/wiki/extensions/LocalisationUpdate/Autoload.php b/www/wiki/extensions/LocalisationUpdate/Autoload.php new file mode 100644 index 00000000..8be7124a --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/Autoload.php @@ -0,0 +1,28 @@ + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/www/wiki/extensions/LocalisationUpdate/Gruntfile.js b/www/wiki/extensions/LocalisationUpdate/Gruntfile.js new file mode 100644 index 00000000..26ca0c16 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/Gruntfile.js @@ -0,0 +1,28 @@ +/*jshint node:true */ +module.exports = function ( grunt ) { + grunt.loadNpmTasks( 'grunt-banana-checker' ); + grunt.loadNpmTasks( 'grunt-jsonlint' ); + grunt.loadNpmTasks( 'grunt-contrib-jshint' ); + + var conf = grunt.file.readJSON( 'extension.json' ); + grunt.initConfig( { + banana: conf.MessagesDirs, + jshint: { + all: [ + '**/*.js', + '!node_modules/**', + '!vendor/**' + ] + }, + jsonlint: { + all: [ + '**/*.json', + '!node_modules/**', + '!vendor/**' + ] + } + } ); + + grunt.registerTask( 'test', [ 'jsonlint', 'banana', 'jshint' ] ); + grunt.registerTask( 'default', 'test' ); +}; diff --git a/www/wiki/extensions/LocalisationUpdate/LocalisationUpdate.class.php b/www/wiki/extensions/LocalisationUpdate/LocalisationUpdate.class.php new file mode 100644 index 00000000..af020db0 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/LocalisationUpdate.class.php @@ -0,0 +1,65 @@ + true, + T_DNUMBER => true, + T_STRING => true, + T_CONSTANT_ENCAPSED_STRING => true, + ]; + $skipTypes = [ + T_WHITESPACE => true, + T_COMMENT => true, + T_DOC_COMMENT => true, + ]; + $tokens = token_get_all( $string ); + $count = count( $tokens ); + for ( $i = 0; $i < $count; ) { + while ( isset( $skipTypes[$tokens[$i][0]] ) ) { + $i++; + } + switch ( $tokens[$i][0] ) { + case T_OPEN_TAG: + $i++; + continue; + case T_VARIABLE: + // '$messages' -> 'messages' + $varname = trim( substr( $tokens[$i][1], 1 ) ); + $varindex = null; + + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + + if ( $tokens[$i] === '[' ) { + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + + if ( isset( $scalarTypes[$tokens[$i][0]] ) ) { + $varindex = $this->parseScalar( $tokens[$i] ); + } else { + throw $this->except( $tokens[$i], 'scalar index' ); + } + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + + if ( $tokens[$i] !== ']' ) { + throw $this->except( $tokens[$i], ']' ); + } + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + } + + if ( $tokens[$i] !== '=' ) { + throw $this->except( $tokens[$i], '=' ); + } + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + + if ( isset( $scalarTypes[$tokens[$i][0]] ) ) { + $buildval = $this->parseScalar( $tokens[$i] ); + } elseif ( $tokens[$i][0] === T_ARRAY ) { + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + if ( $tokens[$i] !== '(' ) { + throw $this->except( $tokens[$i], '(' ); + } + $buildval = []; + do { + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + + if ( $tokens[$i] === ')' ) { + break; + } + if ( isset( $scalarTypes[$tokens[$i][0]] ) ) { + $key = $this->parseScalar( $tokens[$i] ); + } + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + + if ( $tokens[$i][0] !== T_DOUBLE_ARROW ) { + throw $this->except( $tokens[$i], '=>' ); + } + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + + if ( isset( $scalarTypes[$tokens[$i][0]] ) ) { + $val = $this->parseScalar( $tokens[$i] ); + } + wfSuppressWarnings(); + $buildval[$key] = $val; + wfRestoreWarnings(); + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + + if ( $tokens[$i] === ',' ) { + continue; + } elseif ( $tokens[$i] === ')' ) { + break; + } else { + throw $this->except( $tokens[$i], ', or )' ); + } + } while ( true ); + } else { + throw $this->except( $tokens[$i], 'scalar or array' ); + } + if ( is_null( $varindex ) ) { + $this->vars[$varname] = $buildval; + } else { + wfSuppressWarnings(); + $this->vars[$varname][$varindex] = $buildval; + wfRestoreWarnings(); + } + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + if ( $tokens[$i] !== ';' ) { + throw $this->except( $tokens[$i], ';' ); + } + $i++; + break; + default: + throw $this->except( $tokens[$i], 'open tag, whitespace, or variable.' ); + } + } + } + + /** + * @param $got string + * @param $expected string + * @return Exception + */ + private function except( $got, $expected ) { + if ( is_array( $got ) ) { + $got = token_name( $got[0] ) . " ('" . $got[1] . "')"; + } else { + $got = "'" . $got . "'"; + } + + return new Exception( "Expected $expected, got $got" ); + } + + /** + * Parse a scalar value in PHP + * + * @param $token string + * + * @return mixed Parsed value + */ + function parseScalar( $token ) { + if ( is_array( $token ) ) { + $str = $token[1]; + } else { + $str = $token; + } + if ( $str !== '' && $str[0] == '\'' ) { + // Single-quoted string + // @fixme trim() call is due to mystery bug where whitespace gets + // appended to the token; without it we ended up reading in the + // extra quote on the end! + return strtr( substr( trim( $str ), 1, -1 ), + [ '\\\'' => '\'', '\\\\' => '\\' ] ); + } + + wfSuppressWarnings(); + if ( $str !== '' && $str[0] == '"' ) { + // Double-quoted string + // @fixme trim() call is due to mystery bug where whitespace gets + // appended to the token; without it we ended up reading in the + // extra quote on the end! + wfRestoreWarnings(); + return stripcslashes( substr( trim( $str ), 1, -1 ) ); + } + wfRestoreWarnings(); + + if ( substr( $str, 0, 4 ) === 'true' ) { + return true; + } + + if ( substr( $str, 0, 5 ) === 'false' ) { + return false; + } + + if ( substr( $str, 0, 4 ) === 'null' ) { + return null; + } + + // Must be some kind of numeric value, so let PHP's weak typing + // be useful for a change + return $str; + } + + /** + * @param $varname string + * @return null|string + */ + function getVar( $varname ) { + if ( isset( $this->vars[$varname] ) ) { + return $this->vars[$varname]; + } else { + return null; + } + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/README b/www/wiki/extensions/LocalisationUpdate/README new file mode 100644 index 00000000..c5e2f72e --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/README @@ -0,0 +1,34 @@ +== Localisation Update == +Localisation Update extension can update the MediaWiki messages at any time, +without needing to upgrade the MediaWiki software. + +For more information see: + https://www.mediawiki.org/wiki/Extension:LocalisationUpdate + +== Installation == +1. Add the following to LocalSettings.php of your MediaWiki setup: + + wfLoadExtension( 'LocalisationUpdate' ); + $wgLocalisationUpdateDirectory = "$IP/cache"; + +2. Create a cache folder in the installation directory, and be sure the server +has permissions to write on it. + +If localization updates don't seem to come through, you may need to run, + + php maintenance/rebuildLocalisationCache.php --force. + +3. Whenever you want to run an update, run, + + php extensions/LocalisationUpdate/update.php + +For detailed help, see: + + php extensions/LocalisationUpdate/update.php --help + +4. If you are on Unix like system, you should add LocalisationUpdate to +crontab: + + crontab -e + # Add the following line + @daily php /path/to/your/wiki/extensions/LocalisationUpdate/update.php --quiet diff --git a/www/wiki/extensions/LocalisationUpdate/Updater.php b/www/wiki/extensions/LocalisationUpdate/Updater.php new file mode 100644 index 00000000..7f0c21f7 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/Updater.php @@ -0,0 +1,195 @@ + %NAME%. + $keys = []; + foreach ( array_keys( $info ) as $key ) { + $keys[] = '%' . strtoupper( $key ) . '%'; + } + + $values = array_values( $info ); + return str_replace( $keys, $values, $pattern ); + } + + /** + * Parses translations from given list of files. + * + * @param ReaderFactory $readerFactory Factory to construct parsers. + * @param array $files List of files with their contents as array values. + * @return array List of translations indexed by language code. + */ + public function readMessages( ReaderFactory $readerFactory, array $files ) { + $messages = []; + + foreach ( $files as $filename => $contents ) { + $reader = $readerFactory->getReader( $filename ); + try { + $parsed = $reader->parse( $contents ); + } catch ( \Exception $e ) { + trigger_error( __METHOD__ . ": Unable to parse messages from $filename", E_USER_WARNING ); + continue; + } + + foreach ( $parsed as $code => $langMessages ) { + if ( !isset( $messages[$code] ) ) { + $messages[$code] = []; + } + $messages[$code] = array_merge( $messages[$code], $langMessages ); + } + + $c = array_sum( array_map( 'count', $parsed ) ); + // Useful for debugging, maybe create interface to pass this to the script? + # echo "$filename with " . get_class( $reader ) . " and $c\n"; + } + + return $messages; + } + + /** + * Find new and changed translations in $remote and returns them. + * + * @param array $origin + * @param array $remote + * @param array $blacklist Array of message keys to ignore, keys as as array keys. + * @return array + */ + public function findChangedTranslations( $origin, $remote, $blacklist = [] ) { + $changed = []; + foreach ( $remote as $key => $value ) { + if ( isset( $blacklist[$key] ) ) { + continue; + } + + if ( !isset( $origin[$key] ) || $value !== $origin[$key] ) { + $changed[$key] = $value; + } + } + return $changed; + } + + /** + * Fetches files from given Url pattern. + * + * @param FetcherFactory $factory Factory to construct fetchers. + * @param string $path Url to the file or pattern of files. + * @return array List of Urls with file contents as path. + */ + public function fetchFiles( FetcherFactory $factory, $path ) { + $fetcher = $factory->getFetcher( $path ); + + if ( $this->isDirectory( $path ) ) { + $files = $fetcher->fetchDirectory( $path ); + } else { + $files = [ $path => $fetcher->fetchFile( $path ) ]; + } + + // Remove files which were not found + return array_filter( $files ); + } + + public function execute( + Finder $finder, + ReaderFactory $readerFactory, + FetcherFactory $fetcherFactory, + array $repos + ) { + $components = $finder->getComponents(); + + $updatedMessages = []; + + foreach ( $components as $key => $info ) { + $originFiles = $this->fetchFiles( $fetcherFactory, $info['orig'] ); + $remoteFiles = $this->fetchFiles( $fetcherFactory, $this->expandRemotePath( $info, $repos ) ); + + if ( $remoteFiles === [] ) { + // Small optimization: if nothing to compare with, skip + continue; + } + + $originMessages = $this->readMessages( $readerFactory, $originFiles ); + $remoteMessages = $this->readMessages( $readerFactory, $remoteFiles ); + + if ( !isset( $remoteMessages['en'] ) ) { + // Could not find remote messages + continue; + } + + // If remote translation in English is not present or differs, we do not want + // translations for other languages for those messages, as they are either not + // used in this version of code or can be incompatible. + $forbiddenKeys = $this->findChangedTranslations( + $originMessages['en'], + $remoteMessages['en'] + ); + + // We never accept updates for English strings + unset( $originMessages['en'], $remoteMessages['en'] ); + + // message: string in all languages; translation: string in one language. + foreach ( $remoteMessages as $language => $remoteTranslations ) { + // Check for completely new languages + $originTranslations = []; + if ( isset( $originMessages[$language] ) ) { + $originTranslations = $originMessages[$language]; + } + + $updatedTranslations = $this->findChangedTranslations( + $originTranslations, + $remoteTranslations, + $forbiddenKeys + ); + + // Avoid empty arrays + if ( $updatedTranslations === [] ) { + continue; + } + + if ( !isset( $updatedMessages[$language] ) ) { + $updatedMessages[$language] = []; + } + + // In case of conflicts, which should not exist, this prefers the + // first translation seen. + $updatedMessages[$language] += $updatedTranslations; + } + } + + return $updatedMessages; + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/composer.json b/www/wiki/extensions/LocalisationUpdate/composer.json new file mode 100644 index 00000000..e49e334b --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/composer.json @@ -0,0 +1,55 @@ +{ + "name": "mediawiki/localisation-update", + "type": "mediawiki-extension", + "description": "MediaWiki extension to keep the localised messages as up to date as possible.", + "keywords": [ + "MediaWiki", + "l10n", + "localization" + ], + "homepage": "https://www.mediawiki.org/wiki/Extension:LocalisationUpdate", + "license": "GPL-2.0-or-later", + "authors": [ + { + "name": "Roan Kattouw", + "email": "roan.kattouw@gmail.com", + "role": "Developer" + }, + { + "name": "Niklas Laxström", + "email": "niklas.laxstrom@gmail.com", + "role": "Developer" + }, + { + "name": "Tom Maaswinkel", + "role": "Original author" + } + ], + "support": { + "issues": "https://phabricator.wikimedia.org/", + "irc": "irc://irc.freenode.net/mediawiki", + "forum": "https://www.mediawiki.org/wiki/Extension_talk:LocalisationUpdate", + "wiki": "https://www.mediawiki.org/wiki/Extension:LocalisationUpdate" + }, + "require-dev": { + "jakub-onderka/php-parallel-lint": "1.0.0", + "mediawiki/mediawiki-codesniffer": "18.0.0", + "jakub-onderka/php-console-highlighter": "0.3.2", + "mediawiki/minus-x": "0.3.1", + "mediawiki/mediawiki-phan-config": "0.2.0" + }, + "scripts": { + "fix": [ + "phpcbf", + "minus-x fix ." + ], + "test": [ + "parallel-lint . --exclude vendor --exclude node_modules", + "phpcs -p -s", + "minus-x check ." + ] + }, + "extra": { + "phan-taint-check-plugin": "1.2.0" + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/extension.json b/www/wiki/extensions/LocalisationUpdate/extension.json new file mode 100644 index 00000000..901f66fc --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/extension.json @@ -0,0 +1,55 @@ +{ + "@note": "This file must be kept in sync with LocalisationUpdate.php", + "name": "LocalisationUpdate", + "namemsg": "localisationupdate-extensionname", + "version": "1.4.0", + "author": [ + "Tom Maaswinkel", + "Niklas Laxström", + "Roan Kattouw" + ], + "url": "https://www.mediawiki.org/wiki/Extension:LocalisationUpdate", + "descriptionmsg": "localisationupdate-desc", + "license-name": "GPL-2.0-or-later", + "type": "other", + "MessagesDirs": { + "LocalisationUpdate": [ + "i18n" + ] + }, + "AutoloadClasses": { + "LocalisationUpdate": "includes/LocalisationUpdate.php", + "LocalisationUpdate\\Updater": "includes/Updater.php", + "QuickArrayReader": "includes/QuickArrayReader.php", + "LocalisationUpdate\\Fetcher": "includes/fetcher/Fetcher.php", + "LocalisationUpdate\\FetcherFactory": "includes/fetcher/FetcherFactory.php", + "LocalisationUpdate\\FileSystemFetcher": "includes/fetcher/FileSystemFetcher.php", + "LocalisationUpdate\\GitHubFetcher": "includes/fetcher/GitHubFetcher.php", + "LocalisationUpdate\\HttpFetcher": "includes/fetcher/HttpFetcher.php", + "LocalisationUpdate\\Finder": "includes/finder/Finder.php", + "LocalisationUpdate\\JSONReader": "includes/reader/JSONReader.php", + "LocalisationUpdate\\PHPReader": "includes/reader/PHPReader.php", + "LocalisationUpdate\\Reader": "includes/reader/Reader.php", + "LocalisationUpdate\\ReaderFactory": "includes/reader/ReaderFactory.php" + }, + "Hooks": { + "LocalisationCacheRecache": [ + "LocalisationUpdate::onRecache" + ], + "LocalisationCacheRecacheFallback": [ + "LocalisationUpdate::onRecacheFallback" + ] + }, + "config": { + "LocalisationUpdateDirectory": false, + "LocalisationUpdateRepository": "github", + "LocalisationUpdateRepositories": { + "github": { + "mediawiki": "https://raw.github.com/wikimedia/mediawiki/master/%PATH%", + "extension": "https://raw.github.com/wikimedia/mediawiki-extensions-%NAME%/master/%PATH%", + "skin": "https://raw.github.com/wikimedia/mediawiki-skins-%NAME%/master/%PATH%" + } + } + }, + "manifest_version": 1 +} diff --git a/www/wiki/extensions/LocalisationUpdate/fetcher/Fetcher.php b/www/wiki/extensions/LocalisationUpdate/fetcher/Fetcher.php new file mode 100644 index 00000000..9ff79584 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/fetcher/Fetcher.php @@ -0,0 +1,28 @@ +[^/]+)/(?P[^/]+)/(?P[^/]+)/(?P.+)/.+$~"; + preg_match( $p, $pattern, $m ); + + $apiURL = "https://api.github.com/repos/{$m['org']}/{$m['repo']}/contents/{$m['path']}"; + $json = \Http::get( $apiURL ); + if ( !$json ) { + throw new \Exception( "Unable to get directory listing for {$m['org']}/{$m['repo']}" ); + } + + $files = []; + $json = \FormatJson::decode( $json, true ); + foreach ( $json as $fileinfo ) { + $fileurl = dirname( $pattern ) . '/' . $fileinfo['name']; + $file = $this->fetchFile( $fileurl ); + if ( $file ) { + $files[$fileurl] = $file; + } + } + return $files; + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/fetcher/HttpFetcher.php b/www/wiki/extensions/LocalisationUpdate/fetcher/HttpFetcher.php new file mode 100644 index 00000000..42b0f032 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/fetcher/HttpFetcher.php @@ -0,0 +1,42 @@ +fetchFile( $url ); + if ( $file ) { + $files[$url] = $file; + } + } + + return $files; + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/finder/Finder.php b/www/wiki/extensions/LocalisationUpdate/finder/Finder.php new file mode 100644 index 00000000..20ba9377 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/finder/Finder.php @@ -0,0 +1,109 @@ +php = $php; + $this->json = $json; + $this->core = $core; + } + + /** + * @return array + */ + public function getComponents() { + $components = []; + + // For older versions of Mediawiki, pull json updates even though its still using php + if ( !isset( $this->json['core'] ) ) { + $components['core'] = [ + 'repo' => 'mediawiki', + 'orig' => "file://{$this->core}/languages/messages/Messages*.php", + 'path' => 'languages/messages/i18n/*.json', + ]; + } + + foreach ( $this->json as $key => $value ) { + // Json should take priority if both exist + unset( $this->php[$key] ); + + foreach ( (array)$value as $subkey => $subvalue ) { + // Mediawiki core files + $matches = []; + if ( preg_match( '~/(?P(?:includes|languages|resources)/.*)$~', $subvalue, $matches ) ) { + $components["$key-$subkey"] = [ + 'repo' => 'mediawiki', + 'orig' => "file://$value/*.json", + 'path' => "{$matches['path']}/*.json", + ]; + continue; + } + + $item = $this->getItem( 'extensions', $subvalue ); + if ( $item !== null ) { + $item['repo'] = 'extension'; + $components["$key-$subkey"] = $item; + continue; + } + + $item = $this->getItem( 'skins', $subvalue ); + if ( $item !== null ) { + $item['repo'] = 'skin'; + $components["$key-$subkey"] = $item; + continue; + } + } + } + + foreach ( $this->php as $key => $value ) { + $matches = []; + $ok = preg_match( '~/extensions/(?P[^/]+)/(?P.*\.i18n\.php)$~', $value, $matches ); + if ( !$ok ) { + continue; + } + + $components[$key] = [ + 'repo' => 'extension', + 'name' => $matches['name'], + 'orig' => "file://$value", + 'path' => $matches['path'], + ]; + } + + return $components; + } + + /** + * @param string $dir extensions or skins + * @param string $subvalue + * @return array|null + */ + private function getItem( $dir, $subvalue ) { + // This ignores magic, alias etc. non message files + $matches = []; + if ( !preg_match( "~/$dir/(?P[^/]+)/(?P.*)$~", $subvalue, $matches ) ) { + return null; + } + + return [ + 'name' => $matches['name'], + 'orig' => "file://$subvalue/*.json", + 'path' => "{$matches['path']}/*.json", + ]; + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/af.json b/www/wiki/extensions/LocalisationUpdate/i18n/af.json new file mode 100644 index 00000000..3739dc26 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/af.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Naudefj" + ] + }, + "localisationupdate-desc": "Hou die gelokaliseerde boodskappe so op datum as moontlik" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/ar.json b/www/wiki/extensions/LocalisationUpdate/i18n/ar.json new file mode 100644 index 00000000..101e54ee --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/ar.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Meno25" + ] + }, + "localisationupdate-desc": "يبقي الرسائل المترجمة محدثة كأفضل ما يكون" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/ast.json b/www/wiki/extensions/LocalisationUpdate/i18n/ast.json new file mode 100644 index 00000000..13fcd456 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/ast.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Xuacu" + ] + }, + "localisationupdate-desc": "Caltién los mensaxes llocalizaos tan anovaos como se pueda" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/ba.json b/www/wiki/extensions/LocalisationUpdate/i18n/ba.json new file mode 100644 index 00000000..e96ee2b4 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/ba.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Assele" + ] + }, + "localisationupdate-desc": "Локалләштерелгән хәбәрҙәрҙең мөмкин тиклем яңы булыуын тәьмин итә" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/bar.json b/www/wiki/extensions/LocalisationUpdate/i18n/bar.json new file mode 100644 index 00000000..0c4c56f7 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/bar.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Man77" + ] + }, + "localisationupdate-desc": "Lokalisiade Texte und Nåchrichtn so aktuell håidn wia's gråd gehd" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/be-tarask.json b/www/wiki/extensions/LocalisationUpdate/i18n/be-tarask.json new file mode 100644 index 00000000..01f487be --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/be-tarask.json @@ -0,0 +1,9 @@ +{ + "@metadata": { + "authors": [ + "EugeneZelenko", + "Wizardist" + ] + }, + "localisationupdate-desc": "Сочыць за актуальнасьцю лякалізаваных паведамленьняў, наколькі гэта магчыма" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/bg.json b/www/wiki/extensions/LocalisationUpdate/i18n/bg.json new file mode 100644 index 00000000..59a6edbd --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/bg.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "DCLXVI" + ] + }, + "localisationupdate-desc": "Поддържа локализираните съобщения възможно най-актуални" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/bn.json b/www/wiki/extensions/LocalisationUpdate/i18n/bn.json new file mode 100644 index 00000000..6936be62 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/bn.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Bellayet" + ] + }, + "localisationupdate-desc": "স্থানীয়করণকৃত বার্তাসমূহ যথাসম্ভব হালনাগাদ রাখে" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/br.json b/www/wiki/extensions/LocalisationUpdate/i18n/br.json new file mode 100644 index 00000000..89db4778 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/br.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Fulup" + ] + }, + "localisationupdate-desc": "Derc'hel da hizivaat ar c'hemennoù troet ken fonnus ha ma'z eus tu" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/bs.json b/www/wiki/extensions/LocalisationUpdate/i18n/bs.json new file mode 100644 index 00000000..339dae1d --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/bs.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "CERminator" + ] + }, + "localisationupdate-desc": "Zadržavanje lokaliziranih poruka ažurnim koliko je god moguće" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/ca.json b/www/wiki/extensions/LocalisationUpdate/i18n/ca.json new file mode 100644 index 00000000..4b4ac0af --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/ca.json @@ -0,0 +1,9 @@ +{ + "@metadata": { + "authors": [ + "Paucabot", + "Fitoschido" + ] + }, + "localisationupdate-desc": "Manté els missatges traduïts tan actualitzats com sigui possible" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/ce.json b/www/wiki/extensions/LocalisationUpdate/i18n/ce.json new file mode 100644 index 00000000..579d7dbb --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/ce.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Умар" + ] + }, + "localisationupdate-desc": "Таро ма хуьйла хаамашан болх бан гӀо до" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/cs.json b/www/wiki/extensions/LocalisationUpdate/i18n/cs.json new file mode 100644 index 00000000..d72e9110 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/cs.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Mormegil" + ] + }, + "localisationupdate-desc": "Udržuje lokalizovaná hlášení co možná nejaktuálnější" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/cy.json b/www/wiki/extensions/LocalisationUpdate/i18n/cy.json new file mode 100644 index 00000000..9ab89a53 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/cy.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Lloffiwr" + ] + }, + "localisationupdate-desc": "Yn diweddaru'r cyfieithiadau o negeseuon mor aml â phosib" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/da.json b/www/wiki/extensions/LocalisationUpdate/i18n/da.json new file mode 100644 index 00000000..645d0842 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/da.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Peter Alberti" + ] + }, + "localisationupdate-desc": "Holder de lokaliserede meddelelser så opdaterede som muligt" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/de.json b/www/wiki/extensions/LocalisationUpdate/i18n/de.json new file mode 100644 index 00000000..98f9dc14 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/de.json @@ -0,0 +1,11 @@ +{ + "@metadata": { + "authors": [ + "Kghbln", + "Purodha", + "Metalhead64" + ] + }, + "localisationupdate-extensionname": "LocalisationUpdate", + "localisationupdate-desc": "Ermöglicht es lokalisierte Texte und Nachrichten so aktuell wie möglich zu halten" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/dsb.json b/www/wiki/extensions/LocalisationUpdate/i18n/dsb.json new file mode 100644 index 00000000..11cbf5d9 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/dsb.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Michawiki" + ] + }, + "localisationupdate-desc": "Źaržy lokalizěrowane powěźeńki tak aktualne ako móžno" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/el.json b/www/wiki/extensions/LocalisationUpdate/i18n/el.json new file mode 100644 index 00000000..7b4db44c --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/el.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Omnipaedista" + ] + }, + "localisationupdate-desc": "Διατηρεί τις μεταφράσεις μηνυμάτων όσο πιο ενημερωμένες γίνεται" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/en.json b/www/wiki/extensions/LocalisationUpdate/i18n/en.json new file mode 100644 index 00000000..a15cef56 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/en.json @@ -0,0 +1,9 @@ +{ + "@metadata": { + "authors": [ + "Tom Maaswinkel" + ] + }, + "localisationupdate-extensionname": "LocalisationUpdate", + "localisationupdate-desc": "Keeps the localised messages as up to date as possible" +} \ No newline at end of file diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/eo.json b/www/wiki/extensions/LocalisationUpdate/i18n/eo.json new file mode 100644 index 00000000..c1251faa --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/eo.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Yekrats" + ] + }, + "localisationupdate-desc": "Ĝisdatigas la asimilitajn mesaĝojn tiom eble" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/es.json b/www/wiki/extensions/LocalisationUpdate/i18n/es.json new file mode 100644 index 00000000..aea82b47 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/es.json @@ -0,0 +1,9 @@ +{ + "@metadata": { + "authors": [ + "Crazymadlover", + "Fitoschido" + ] + }, + "localisationupdate-desc": "Mantiene los mensajes traducidos tan actualizados como sea posible" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/et.json b/www/wiki/extensions/LocalisationUpdate/i18n/et.json new file mode 100644 index 00000000..9cf22620 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/et.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Pikne" + ] + }, + "localisationupdate-desc": "Hoiab lokaliseeritud sõnumid nii ajakohased kui võimalik." +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/eu.json b/www/wiki/extensions/LocalisationUpdate/i18n/eu.json new file mode 100644 index 00000000..3f55906c --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/eu.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Kobazulo" + ] + }, + "localisationupdate-desc": "Itzulitako mezuak ahalik eta eguneratuen mantentzen ditu" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/fa.json b/www/wiki/extensions/LocalisationUpdate/i18n/fa.json new file mode 100644 index 00000000..ae1a2a27 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/fa.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "ZxxZxxZ" + ] + }, + "localisationupdate-desc": "پیغام‌های محلی‌سازی‌شده را تا جای ممکن به‌روز نگه می‌دارد" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/fi.json b/www/wiki/extensions/LocalisationUpdate/i18n/fi.json new file mode 100644 index 00000000..253c2de7 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/fi.json @@ -0,0 +1,9 @@ +{ + "@metadata": { + "authors": [ + "Crt", + "Nike" + ] + }, + "localisationupdate-desc": "Pitää ohjelmiston käännöksen ajantasaisena." +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/fr.json b/www/wiki/extensions/LocalisationUpdate/i18n/fr.json new file mode 100644 index 00000000..b62e2b6b --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/fr.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Crochet.david" + ] + }, + "localisationupdate-desc": "Maintenir la traduction des messages à jour autant que possible" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/gl.json b/www/wiki/extensions/LocalisationUpdate/i18n/gl.json new file mode 100644 index 00000000..f80215b3 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/gl.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Toliño" + ] + }, + "localisationupdate-desc": "Mantén as mensaxes localizadas tan actualizadas como é posible" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/gsw.json b/www/wiki/extensions/LocalisationUpdate/i18n/gsw.json new file mode 100644 index 00000000..9ce091c0 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/gsw.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Als-Holder" + ] + }, + "localisationupdate-desc": "Halt d Syschtemnochrichte so aktuälle wie megli" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/gu.json b/www/wiki/extensions/LocalisationUpdate/i18n/gu.json new file mode 100644 index 00000000..d0fb3fdb --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/gu.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "KartikMistry" + ] + }, + "localisationupdate-desc": "ભાષાંતરોને શક્ય હોય ત્યાં સુધી છેલ્લામાં છેલ્લાં રાખે છે" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/he.json b/www/wiki/extensions/LocalisationUpdate/i18n/he.json new file mode 100644 index 00000000..9a1b8c64 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/he.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "YaronSh" + ] + }, + "localisationupdate-desc": "שמירת ההודעות המתורגמות מעודכנות ככל הניתן" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/hil.json b/www/wiki/extensions/LocalisationUpdate/i18n/hil.json new file mode 100644 index 00000000..cff1ac40 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/hil.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Tagimata" + ] + }, + "localisationupdate-desc": "Gatugo sang mga mensahe nga lokal para mapahibalo sang madali" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/hr.json b/www/wiki/extensions/LocalisationUpdate/i18n/hr.json new file mode 100644 index 00000000..8d196c34 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/hr.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "SpeedyGonsales" + ] + }, + "localisationupdate-desc": "Dogradnja za osvježavanje lokalizacije poruka MediaWikija" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/hsb.json b/www/wiki/extensions/LocalisationUpdate/i18n/hsb.json new file mode 100644 index 00000000..04adee04 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/hsb.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Michawiki" + ] + }, + "localisationupdate-desc": "Dźerži lokalizowane zdźělenki tak aktualne kaž móžno" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/hu.json b/www/wiki/extensions/LocalisationUpdate/i18n/hu.json new file mode 100644 index 00000000..f8bd039b --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/hu.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Glanthor Reviol" + ] + }, + "localisationupdate-desc": "Frissíti a lefordított üzeneteket" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/ia.json b/www/wiki/extensions/LocalisationUpdate/i18n/ia.json new file mode 100644 index 00000000..7ab58ab9 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/ia.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "McDutchie" + ] + }, + "localisationupdate-desc": "Mantene le messages localisate tanto actual como possibile" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/id.json b/www/wiki/extensions/LocalisationUpdate/i18n/id.json new file mode 100644 index 00000000..6f46173a --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/id.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Bennylin" + ] + }, + "localisationupdate-desc": "Mengusahakan agar pesan-pesan yang telah diterjemahkan tetap semutakhir mungkin" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/ilo.json b/www/wiki/extensions/LocalisationUpdate/i18n/ilo.json new file mode 100644 index 00000000..56428785 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/ilo.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Lam-ang" + ] + }, + "localisationupdate-desc": "Taginayonenna a mapabaro dagiti naipatarus a mensahe" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/it.json b/www/wiki/extensions/LocalisationUpdate/i18n/it.json new file mode 100644 index 00000000..b1ee5aa3 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/it.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Darth Kule" + ] + }, + "localisationupdate-desc": "Mantiene i messaggi localizzati quanto più aggiornati è possibile" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/ja.json b/www/wiki/extensions/LocalisationUpdate/i18n/ja.json new file mode 100644 index 00000000..8eba705e --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/ja.json @@ -0,0 +1,9 @@ +{ + "@metadata": { + "authors": [ + "Fryed-peach", + "Shirayuki" + ] + }, + "localisationupdate-desc": "メッセージの翻訳をできるだけ最新に保つ" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/km.json b/www/wiki/extensions/LocalisationUpdate/i18n/km.json new file mode 100644 index 00000000..c3f78d86 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/km.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "វ័ណថារិទ្ធ" + ] + }, + "localisationupdate-desc": "រក្សា​សារ​ដែលបាន​ប្រែសម្រួល​ទាំងឡាយ អោយនៅ​ទាន់សម័យ​តាមដែលអាចធ្វើទៅបាន​" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/ko.json b/www/wiki/extensions/LocalisationUpdate/i18n/ko.json new file mode 100644 index 00000000..0f906a59 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/ko.json @@ -0,0 +1,9 @@ +{ + "@metadata": { + "authors": [ + "Kwj2772", + "아라" + ] + }, + "localisationupdate-desc": "번역된 메시지를 가능한 한 최신으로 유지합니다" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/ksh.json b/www/wiki/extensions/LocalisationUpdate/i18n/ksh.json new file mode 100644 index 00000000..ecb69cd7 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/ksh.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Purodha" + ] + }, + "localisationupdate-desc": "Texte un Nohreeschte vum Wiki esu joot wi müjjelich om neueste Shtand halde" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/lb.json b/www/wiki/extensions/LocalisationUpdate/i18n/lb.json new file mode 100644 index 00000000..f2eed733 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/lb.json @@ -0,0 +1,9 @@ +{ + "@metadata": { + "authors": [ + "Robby", + "Soued031" + ] + }, + "localisationupdate-desc": "hält déi lokaliséiert Messagen sou aktuell wéi méiglech." +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/lij.json b/www/wiki/extensions/LocalisationUpdate/i18n/lij.json new file mode 100644 index 00000000..8e699bbc --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/lij.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Giromin Cangiaxo" + ] + }, + "localisationupdate-desc": "O manten i messaggi localizæ ciù agiornæ che se poeu" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/mk.json b/www/wiki/extensions/LocalisationUpdate/i18n/mk.json new file mode 100644 index 00000000..3ac7e4df --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/mk.json @@ -0,0 +1,9 @@ +{ + "@metadata": { + "authors": [ + "Bjankuloski06" + ] + }, + "localisationupdate-extensionname": "Поднова на локализацијата", + "localisationupdate-desc": "Ги одржува локализираните пораки колку што е можно пообновени и повеќе во тек со настаните" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/ml.json b/www/wiki/extensions/LocalisationUpdate/i18n/ml.json new file mode 100644 index 00000000..5e7dfd76 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/ml.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Praveenp" + ] + }, + "localisationupdate-desc": "പ്രാദേശികഭാഷയിലാക്കിയ സന്ദേശങ്ങൾ കഴിയുന്നത്ര വേഗം ചേർക്കാൻ ഉപയോഗിക്കുന്നു" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/ms.json b/www/wiki/extensions/LocalisationUpdate/i18n/ms.json new file mode 100644 index 00000000..5081ed8e --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/ms.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Anakmalaysia" + ] + }, + "localisationupdate-desc": "Memastikan kekemaskinian mesej-mesej yang disetempatkan" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/nb.json b/www/wiki/extensions/LocalisationUpdate/i18n/nb.json new file mode 100644 index 00000000..e9db5be1 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/nb.json @@ -0,0 +1,10 @@ +{ + "@metadata": { + "authors": [ + "Nghtwlkr", + "Jon Harald Søby" + ] + }, + "localisationupdate-extensionname": "LocalisationUpdate", + "localisationupdate-desc": "Holder de lokaliserte meldingene så oppdaterte som mulig" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/nl.json b/www/wiki/extensions/LocalisationUpdate/i18n/nl.json new file mode 100644 index 00000000..a05698e6 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/nl.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Siebrand" + ] + }, + "localisationupdate-desc": "Houdt de gelokaliseerde berichten zo actueel mogelijk" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/nn.json b/www/wiki/extensions/LocalisationUpdate/i18n/nn.json new file mode 100644 index 00000000..b9730f27 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/nn.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Gunnernett" + ] + }, + "localisationupdate-desc": "Held dei lokaliserte meldingane så oppdaterte som mogleg" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/oc.json b/www/wiki/extensions/LocalisationUpdate/i18n/oc.json new file mode 100644 index 00000000..541dd0b9 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/oc.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Cedric31" + ] + }, + "localisationupdate-desc": "Manténer la traduccion dels messatges a jorn autant que possible" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/pl.json b/www/wiki/extensions/LocalisationUpdate/i18n/pl.json new file mode 100644 index 00000000..2ed878ea --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/pl.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Sp5uhe" + ] + }, + "localisationupdate-desc": "Uaktualnia lokalne komunikaty w miarę możliwości na bieżąco" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/pms.json b/www/wiki/extensions/LocalisationUpdate/i18n/pms.json new file mode 100644 index 00000000..bebbbd8a --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/pms.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Dragonòt" + ] + }, + "localisationupdate-desc": "A manten i messagi localisà ël pì agiornà possìbil" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/pt-br.json b/www/wiki/extensions/LocalisationUpdate/i18n/pt-br.json new file mode 100644 index 00000000..2684cfa9 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/pt-br.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Eduardo.mps" + ] + }, + "localisationupdate-desc": "Mantém as mensagens localizadas tão atualizadas quanto possível" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/pt.json b/www/wiki/extensions/LocalisationUpdate/i18n/pt.json new file mode 100644 index 00000000..bbda7981 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/pt.json @@ -0,0 +1,10 @@ +{ + "@metadata": { + "authors": [ + "Hamilton Abreu", + "Luckas", + "Malafaya" + ] + }, + "localisationupdate-desc": "Mantém as mensagens traduzidas tão atualizadas quanto possível" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/qqq.json b/www/wiki/extensions/LocalisationUpdate/i18n/qqq.json new file mode 100644 index 00000000..99da1a04 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/qqq.json @@ -0,0 +1,12 @@ +{ + "@metadata": { + "authors": [ + "Fryed-peach", + "Purodha", + "Shirayuki", + "Umherirrender" + ] + }, + "localisationupdate-extensionname": "{{name}}", + "localisationupdate-desc": "{{desc|name=Localisation Update|url=https://www.mediawiki.org/wiki/Extension:LocalisationUpdate}}" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/ro.json b/www/wiki/extensions/LocalisationUpdate/i18n/ro.json new file mode 100644 index 00000000..b609969c --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/ro.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "KlaudiuMihaila" + ] + }, + "localisationupdate-desc": "Menține mesajele localizate cât mai actualizate" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/roa-tara.json b/www/wiki/extensions/LocalisationUpdate/i18n/roa-tara.json new file mode 100644 index 00000000..47d5c72c --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/roa-tara.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Joetaras" + ] + }, + "localisationupdate-desc": "Mandine le messagge localizzate 'u cchiù aggiornate possibbile" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/ru.json b/www/wiki/extensions/LocalisationUpdate/i18n/ru.json new file mode 100644 index 00000000..a0e4739e --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/ru.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Александр Сигачёв" + ] + }, + "localisationupdate-desc": "Поддерживает актуальность локализованных сообщений, насколько это возможно" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/sk.json b/www/wiki/extensions/LocalisationUpdate/i18n/sk.json new file mode 100644 index 00000000..396998ad --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/sk.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Helix84" + ] + }, + "localisationupdate-desc": "Udržiava lokalizované správy čo najaktuálnejšie" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/sr-ec.json b/www/wiki/extensions/LocalisationUpdate/i18n/sr-ec.json new file mode 100644 index 00000000..dfd900a4 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/sr-ec.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Михајло Анђелковић" + ] + }, + "localisationupdate-desc": "Ажурира локализоване поруке колико је то могуће" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/sr-el.json b/www/wiki/extensions/LocalisationUpdate/i18n/sr-el.json new file mode 100644 index 00000000..f303273b --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/sr-el.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Liangent" + ] + }, + "localisationupdate-desc": "Ažurira lokalizovane poruke koliko je to moguće" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/su.json b/www/wiki/extensions/LocalisationUpdate/i18n/su.json new file mode 100644 index 00000000..2c9d2f13 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/su.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Kandar" + ] + }, + "localisationupdate-desc": "Ngajaga sangkan talatah-talatah nu geus dialihbasakeun salawasnya mutahir" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/sv.json b/www/wiki/extensions/LocalisationUpdate/i18n/sv.json new file mode 100644 index 00000000..a68f4521 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/sv.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Boivie" + ] + }, + "localisationupdate-desc": "Håller de lokaliserade meddelandena så uppdaterade som möjligt" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/ta.json b/www/wiki/extensions/LocalisationUpdate/i18n/ta.json new file mode 100644 index 00000000..153519e6 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/ta.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "செல்வா" + ] + }, + "localisationupdate-desc": "உட்சூழலுக்கான செய்திகளை கூடியமட்டிலும் இன்றையநிலையில் வைக்கப்பட்டுள்ளன" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/te.json b/www/wiki/extensions/LocalisationUpdate/i18n/te.json new file mode 100644 index 00000000..4bc8cd36 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/te.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Veeven" + ] + }, + "localisationupdate-desc": "స్ధానికీకరించిన సందేశాలను సాధ్యమైనంత తాజాగా ఉంచుతుంది" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/tl.json b/www/wiki/extensions/LocalisationUpdate/i18n/tl.json new file mode 100644 index 00000000..e493bc7b --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/tl.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "AnakngAraw" + ] + }, + "localisationupdate-desc": "Pinananatili ang mga mensaheng lokalisado bilang pinaka nasasapanahon" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/tr.json b/www/wiki/extensions/LocalisationUpdate/i18n/tr.json new file mode 100644 index 00000000..63191719 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/tr.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Joseph" + ] + }, + "localisationupdate-desc": "Yerelleştirilen mesajları mümkün olabildiğince güncel tutar" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/uk.json b/www/wiki/extensions/LocalisationUpdate/i18n/uk.json new file mode 100644 index 00000000..e2c2446e --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/uk.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Prima klasy4na" + ] + }, + "localisationupdate-desc": "Забезпечує оновлення локалізованих повідомлень у міру можливості" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/vep.json b/www/wiki/extensions/LocalisationUpdate/i18n/vep.json new file mode 100644 index 00000000..8f3916d5 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/vep.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Игорь Бродский" + ] + }, + "localisationupdate-desc": "Pidab lokaliziruidud tedotused veresin, ku voib" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/vi.json b/www/wiki/extensions/LocalisationUpdate/i18n/vi.json new file mode 100644 index 00000000..9c0e7091 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/vi.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Vinhtantran" + ] + }, + "localisationupdate-desc": "Giữ các thông điệp bản địa hóa được cập nhật nhất có thể" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/wa.json b/www/wiki/extensions/LocalisationUpdate/i18n/wa.json new file mode 100644 index 00000000..cba6cba1 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/wa.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Srtxg" + ] + }, + "localisationupdate-desc": "Po wårder les ratournaedjes di l' eterface li pus a djoû possibe" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/yi.json b/www/wiki/extensions/LocalisationUpdate/i18n/yi.json new file mode 100644 index 00000000..eab1afc4 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/yi.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "פוילישער" + ] + }, + "localisationupdate-desc": "האלטן די לאקאליזירטע מעלדונגען אקטועל ווי נאר מעגלעך" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/yue.json b/www/wiki/extensions/LocalisationUpdate/i18n/yue.json new file mode 100644 index 00000000..1376dc0e --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/yue.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Tom Maaswinkel" + ] + }, + "localisationupdate-desc": "將本地化嘅信息保持最新" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/zh-hans.json b/www/wiki/extensions/LocalisationUpdate/i18n/zh-hans.json new file mode 100644 index 00000000..8141f127 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/zh-hans.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Tom Maaswinkel" + ] + }, + "localisationupdate-desc": "将本地化的信息保持最新" +} diff --git a/www/wiki/extensions/LocalisationUpdate/i18n/zh-hant.json b/www/wiki/extensions/LocalisationUpdate/i18n/zh-hant.json new file mode 100644 index 00000000..511b9790 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/i18n/zh-hant.json @@ -0,0 +1,10 @@ +{ + "@metadata": { + "authors": [ + "Mark85296341", + "Tom Maaswinkel", + "LNDDYL" + ] + }, + "localisationupdate-desc": "將在地化的資訊盡可能保持最新" +} diff --git a/www/wiki/extensions/LocalisationUpdate/includes/LocalisationUpdate.php b/www/wiki/extensions/LocalisationUpdate/includes/LocalisationUpdate.php new file mode 100644 index 00000000..a0b5f044 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/includes/LocalisationUpdate.php @@ -0,0 +1,73 @@ + true, + T_DNUMBER => true, + T_STRING => true, + T_CONSTANT_ENCAPSED_STRING => true, + ]; + $skipTypes = [ + T_WHITESPACE => true, + T_COMMENT => true, + T_DOC_COMMENT => true, + ]; + $tokens = token_get_all( $string ); + $count = count( $tokens ); + for ( $i = 0; $i < $count; ) { + while ( isset( $skipTypes[$tokens[$i][0]] ) ) { + $i++; + } + switch ( $tokens[$i][0] ) { + case T_OPEN_TAG: + $i++; + break; + case T_VARIABLE: + // '$messages' -> 'messages' + $varname = trim( substr( $tokens[$i][1], 1 ) ); + $varindex = null; + + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + + if ( $tokens[$i] === '[' ) { + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + + if ( isset( $scalarTypes[$tokens[$i][0]] ) ) { + $varindex = $this->parseScalar( $tokens[$i] ); + } else { + throw $this->except( $tokens[$i], 'scalar index' ); + } + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + + if ( $tokens[$i] !== ']' ) { + throw $this->except( $tokens[$i], ']' ); + } + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + } + + if ( $tokens[$i] !== '=' ) { + throw $this->except( $tokens[$i], '=' ); + } + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + + if ( isset( $scalarTypes[$tokens[$i][0]] ) ) { + $buildval = $this->parseScalar( $tokens[$i] ); + } elseif ( $tokens[$i][0] === T_ARRAY ) { + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + if ( $tokens[$i] !== '(' ) { + throw $this->except( $tokens[$i], '(' ); + } + $buildval = []; + do { + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + + if ( $tokens[$i] === ')' ) { + break; + } + if ( isset( $scalarTypes[$tokens[$i][0]] ) ) { + $key = $this->parseScalar( $tokens[$i] ); + } + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + + if ( $tokens[$i][0] !== T_DOUBLE_ARROW ) { + throw $this->except( $tokens[$i], '=>' ); + } + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + + if ( isset( $scalarTypes[$tokens[$i][0]] ) ) { + $val = $this->parseScalar( $tokens[$i] ); + } + wfSuppressWarnings(); + $buildval[$key] = $val; + wfRestoreWarnings(); + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + + if ( $tokens[$i] === ',' ) { + continue; + } elseif ( $tokens[$i] === ')' ) { + break; + } else { + throw $this->except( $tokens[$i], ', or )' ); + } + } while ( true ); + } else { + throw $this->except( $tokens[$i], 'scalar or array' ); + } + if ( is_null( $varindex ) ) { + $this->vars[$varname] = $buildval; + } else { + wfSuppressWarnings(); + $this->vars[$varname][$varindex] = $buildval; + wfRestoreWarnings(); + } + while ( isset( $skipTypes[$tokens[++$i][0]] ) ) { + } + if ( $tokens[$i] !== ';' ) { + throw $this->except( $tokens[$i], ';' ); + } + $i++; + break; + default: + throw $this->except( $tokens[$i], 'open tag, whitespace, or variable.' ); + } + } + } + + /** + * @param string $got + * @param string $expected + * @return Exception + */ + private function except( $got, $expected ) { + if ( is_array( $got ) ) { + $got = token_name( $got[0] ) . " ('" . $got[1] . "')"; + } else { + $got = "'" . $got . "'"; + } + + return new Exception( "Expected $expected, got $got" ); + } + + /** + * Parse a scalar value in PHP + * + * @param string $token + * + * @return mixed Parsed value + */ + function parseScalar( $token ) { + if ( is_array( $token ) ) { + $str = $token[1]; + } else { + $str = $token; + } + if ( $str !== '' && $str[0] == '\'' ) { + // Single-quoted string + // @fixme trim() call is due to mystery bug where whitespace gets + // appended to the token; without it we ended up reading in the + // extra quote on the end! + return strtr( substr( trim( $str ), 1, -1 ), + [ '\\\'' => '\'', '\\\\' => '\\' ] ); + } + + wfSuppressWarnings(); + if ( $str !== '' && $str[0] == '"' ) { + // Double-quoted string + // @fixme trim() call is due to mystery bug where whitespace gets + // appended to the token; without it we ended up reading in the + // extra quote on the end! + wfRestoreWarnings(); + return stripcslashes( substr( trim( $str ), 1, -1 ) ); + } + wfRestoreWarnings(); + + if ( substr( $str, 0, 4 ) === 'true' ) { + return true; + } + + if ( substr( $str, 0, 5 ) === 'false' ) { + return false; + } + + if ( substr( $str, 0, 4 ) === 'null' ) { + return null; + } + + // Must be some kind of numeric value, so let PHP's weak typing + // be useful for a change + return $str; + } + + /** + * @param string $varname + * @return null|string|array + */ + function getVar( $varname ) { + if ( isset( $this->vars[$varname] ) ) { + return $this->vars[$varname]; + } else { + return null; + } + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/includes/Updater.php b/www/wiki/extensions/LocalisationUpdate/includes/Updater.php new file mode 100644 index 00000000..863dc04a --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/includes/Updater.php @@ -0,0 +1,204 @@ + %NAME%. + $keys = []; + foreach ( array_keys( $info ) as $key ) { + $keys[] = '%' . strtoupper( $key ) . '%'; + } + + $values = array_values( $info ); + return str_replace( $keys, $values, $pattern ); + } + + /** + * Parses translations from given list of files. + * + * @param ReaderFactory $readerFactory Factory to construct parsers. + * @param array $files List of files with their contents as array values. + * @return array List of translations indexed by language code. + */ + public function readMessages( ReaderFactory $readerFactory, array $files ) { + $messages = []; + + foreach ( $files as $filename => $contents ) { + $reader = $readerFactory->getReader( $filename ); + try { + $parsed = $reader->parse( $contents ); + } catch ( \Exception $e ) { + trigger_error( __METHOD__ . ": Unable to parse messages from $filename", E_USER_WARNING ); + continue; + } + + foreach ( $parsed as $code => $langMessages ) { + if ( !isset( $messages[$code] ) ) { + $messages[$code] = []; + } + $messages[$code] = array_merge( $messages[$code], $langMessages ); + } + + $c = array_sum( array_map( 'count', $parsed ) ); + // Useful for debugging, maybe create interface to pass this to the script? + # echo "$filename with " . get_class( $reader ) . " and $c\n"; + } + + return $messages; + } + + /** + * Find new and changed translations in $remote and returns them. + * + * @param array $origin + * @param array $remote + * @param array $blacklist Array of message keys to ignore, keys as as array keys. + * @return array + */ + public function findChangedTranslations( $origin, $remote, $blacklist = [] ) { + $changed = []; + foreach ( $remote as $key => $value ) { + if ( isset( $blacklist[$key] ) ) { + continue; + } + + if ( !isset( $origin[$key] ) || $value !== $origin[$key] ) { + $changed[$key] = $value; + } + } + return $changed; + } + + /** + * Fetches files from given Url pattern. + * + * @param FetcherFactory $factory Factory to construct fetchers. + * @param string $path Url to the file or pattern of files. + * @return array List of Urls with file contents as path. + */ + public function fetchFiles( FetcherFactory $factory, $path ) { + $fetcher = $factory->getFetcher( $path ); + + if ( $this->isDirectory( $path ) ) { + $files = $fetcher->fetchDirectory( $path ); + } else { + $files = [ $path => $fetcher->fetchFile( $path ) ]; + } + + // Remove files which were not found + return array_filter( $files ); + } + + public function execute( + Finder $finder, + ReaderFactory $readerFactory, + FetcherFactory $fetcherFactory, + array $repos, + $logger + ) { + $components = $finder->getComponents(); + + $updatedMessages = []; + + foreach ( $components as $key => $info ) { + $logger->logInfo( "Updating component $key" ); + + $originFiles = $this->fetchFiles( $fetcherFactory, $info['orig'] ); + $remotePath = $this->expandRemotePath( $info, $repos ); + try { + $remoteFiles = $this->fetchFiles( $fetcherFactory, $remotePath ); + } catch ( \Exception $e ) { + $logger->logError( __METHOD__ . ": Unable to fetch messages from $remotePath" ); + continue; + } + + if ( $remoteFiles === [] ) { + // Small optimization: if nothing to compare with, skip + continue; + } + + $originMessages = $this->readMessages( $readerFactory, $originFiles ); + $remoteMessages = $this->readMessages( $readerFactory, $remoteFiles ); + + if ( !isset( $remoteMessages['en'] ) ) { + // Could not find remote messages + continue; + } + + // If remote translation in English is not present or differs, we do not want + // translations for other languages for those messages, as they are either not + // used in this version of code or can be incompatible. + $forbiddenKeys = $this->findChangedTranslations( + $originMessages['en'], + $remoteMessages['en'] + ); + + // We never accept updates for English strings + unset( $originMessages['en'], $remoteMessages['en'] ); + + // message: string in all languages; translation: string in one language. + foreach ( $remoteMessages as $language => $remoteTranslations ) { + // Check for completely new languages + $originTranslations = []; + if ( isset( $originMessages[$language] ) ) { + $originTranslations = $originMessages[$language]; + } + + $updatedTranslations = $this->findChangedTranslations( + $originTranslations, + $remoteTranslations, + $forbiddenKeys + ); + + // Avoid empty arrays + if ( $updatedTranslations === [] ) { + continue; + } + + if ( !isset( $updatedMessages[$language] ) ) { + $updatedMessages[$language] = []; + } + + // In case of conflicts, which should not exist, this prefers the + // first translation seen. + $updatedMessages[$language] += $updatedTranslations; + } + } + + return $updatedMessages; + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/includes/fetcher/Fetcher.php b/www/wiki/extensions/LocalisationUpdate/includes/fetcher/Fetcher.php new file mode 100644 index 00000000..62febac8 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/includes/fetcher/Fetcher.php @@ -0,0 +1,30 @@ +[^/]+)/(?P[^/]+)/(?P[^/]+)/(?P.+)/.+$~"; + preg_match( $p, $pattern, $m ); + + $apiURL = "https://api.github.com/repos/{$m['org']}/{$m['repo']}/contents/{$m['path']}"; + $json = \Http::get( $apiURL ); + if ( !$json ) { + throw new \Exception( "Unable to get directory listing for {$m['org']}/{$m['repo']}" ); + } + + $files = []; + $json = \FormatJson::decode( $json, true ); + foreach ( $json as $fileinfo ) { + $fileurl = dirname( $pattern ) . '/' . $fileinfo['name']; + $file = $this->fetchFile( $fileurl ); + if ( $file ) { + $files[$fileurl] = $file; + } + } + return $files; + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/includes/fetcher/HttpFetcher.php b/www/wiki/extensions/LocalisationUpdate/includes/fetcher/HttpFetcher.php new file mode 100644 index 00000000..72988e98 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/includes/fetcher/HttpFetcher.php @@ -0,0 +1,49 @@ +fetchFile( $url ); + if ( $file ) { + $files[$url] = $file; + } + } + + return $files; + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/includes/finder/Finder.php b/www/wiki/extensions/LocalisationUpdate/includes/finder/Finder.php new file mode 100644 index 00000000..acebc42a --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/includes/finder/Finder.php @@ -0,0 +1,124 @@ +php = $php; + $this->json = $json; + $this->core = $core; + } + + /** + * @return array + */ + public function getComponents() { + $components = []; + + // For older versions of Mediawiki, pull json updates even though its still using php + if ( !isset( $this->json['core'] ) ) { + $components['core'] = [ + 'repo' => 'mediawiki', + 'orig' => "file://{$this->core}/languages/messages/Messages*.php", + 'path' => 'languages/messages/i18n/*.json', + ]; + } + + foreach ( $this->json as $key => $value ) { + // Json should take priority if both exist + unset( $this->php[$key] ); + + foreach ( (array)$value as $subkey => $subvalue ) { + // Mediawiki core files + $matches = []; + if ( preg_match( '~/(?P(?:includes|languages|resources)/.*)$~', $subvalue, $matches ) ) { + $components["$key-$subkey"] = [ + 'repo' => 'mediawiki', + 'orig' => "file://$value/*.json", + 'path' => "{$matches['path']}/*.json", + ]; + continue; + } + + $item = $this->getItem( 'extensions', $subvalue ); + if ( $item !== null ) { + $item['repo'] = 'extension'; + $components["$key-$subkey"] = $item; + continue; + } + + $item = $this->getItem( 'skins', $subvalue ); + if ( $item !== null ) { + $item['repo'] = 'skin'; + $components["$key-$subkey"] = $item; + continue; + } + } + } + + foreach ( $this->php as $key => $value ) { + $matches = []; + $ok = preg_match( '~/extensions/(?P[^/]+)/(?P.*\.i18n\.php)$~', $value, $matches ); + if ( !$ok ) { + continue; + } + + $components[$key] = [ + 'repo' => 'extension', + 'name' => $matches['name'], + 'orig' => "file://$value", + 'path' => $matches['path'], + ]; + } + + return $components; + } + + /** + * @param string $dir extensions or skins + * @param string $subvalue + * @return array|null + */ + private function getItem( $dir, $subvalue ) { + // This ignores magic, alias etc. non message files + $matches = []; + if ( !preg_match( "~/$dir/(?P[^/]+)/(?P.*)$~", $subvalue, $matches ) ) { + return null; + } + + return [ + 'name' => $matches['name'], + 'orig' => "file://$subvalue/*.json", + 'path' => "{$matches['path']}/*.json", + ]; + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/includes/reader/JSONReader.php b/www/wiki/extensions/LocalisationUpdate/includes/reader/JSONReader.php new file mode 100644 index 00000000..e8613660 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/includes/reader/JSONReader.php @@ -0,0 +1,37 @@ +code = $code; + } + + /** + * @param string $contents + * + * @return array + */ + public function parse( $contents ) { + $messages = \FormatJson::decode( $contents, true ); + unset( $messages['@metadata'] ); + + if ( $this->code ) { + return [ $this->code => $messages ]; + } + + // Assuming that the array is keyed by language codes + return $messages; + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/includes/reader/PHPReader.php b/www/wiki/extensions/LocalisationUpdate/includes/reader/PHPReader.php new file mode 100644 index 00000000..43e4db25 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/includes/reader/PHPReader.php @@ -0,0 +1,61 @@ +code = $code; + } + + /** + * @param string $contents + * + * @return array + */ + public function parse( $contents ) { + if ( strpos( $contents, '$messages' ) === false ) { + // This happens for some core languages that only have a fallback. + return []; + } + + $php = $this->cleanupFile( $contents ); + $reader = new \QuickArrayReader( "getVar( 'messages' ); + + if ( $this->code ) { + return [ $this->code => $messages ]; + } + + // Assuming that the array is keyed by language codes + return $messages; + } + + /** + * Removes all unneeded content from a file and returns it. + * + * @param string $contents String + * @return string PHP code without PHP tags + */ + protected function cleanupFile( $contents ) { + // We hate the windows vs linux linebreaks. + $contents = preg_replace( '/\r\n?/', "\n", $contents ); + + // We only want message arrays. + $results = []; + preg_match_all( '/\$messages(?:.*\s)*?\);/', $contents, $results ); + + // But we want them all in one string. + return implode( "\n\n", $results[0] ); + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/includes/reader/Reader.php b/www/wiki/extensions/LocalisationUpdate/includes/reader/Reader.php new file mode 100644 index 00000000..fd37322e --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/includes/reader/Reader.php @@ -0,0 +1,21 @@ + array( 'key' => 'value' ) ); + * @param string $contents File contents as a string. + * @return array + */ + public function parse( $contents ); +} diff --git a/www/wiki/extensions/LocalisationUpdate/includes/reader/ReaderFactory.php b/www/wiki/extensions/LocalisationUpdate/includes/reader/ReaderFactory.php new file mode 100644 index 00000000..44bc5e40 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/includes/reader/ReaderFactory.php @@ -0,0 +1,38 @@ + + + + + + + + + + + + . + + + diff --git a/www/wiki/extensions/LocalisationUpdate/reader/JSONReader.php b/www/wiki/extensions/LocalisationUpdate/reader/JSONReader.php new file mode 100644 index 00000000..fdc4e1d6 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/reader/JSONReader.php @@ -0,0 +1,32 @@ +code = $code; + } + + public function parse( $contents ) { + $messages = \FormatJson::decode( $contents, true ); + unset( $messages['@metadata'] ); + + if ( $this->code ) { + return [ $this->code => $messages ]; + } + + // Assuming that the array is keyed by language codes + return $messages; + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/reader/PHPReader.php b/www/wiki/extensions/LocalisationUpdate/reader/PHPReader.php new file mode 100644 index 00000000..f314744b --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/reader/PHPReader.php @@ -0,0 +1,56 @@ +code = $code; + } + + public function parse( $contents ) { + if ( strpos( $contents, '$messages' ) === false ) { + // This happens for some core languages that only have a fallback. + return []; + } + + $php = $this->cleanupFile( $contents ); + $reader = new \QuickArrayReader( "getVar( 'messages' ); + + if ( $this->code ) { + return [ $this->code => $messages ]; + } + + // Assuming that the array is keyed by language codes + return $messages; + } + + /** + * Removes all unneeded content from a file and returns it. + * + * @param string $contents String + * @return string PHP code without PHP tags + */ + protected function cleanupFile( $contents ) { + // We hate the windows vs linux linebreaks. + $contents = preg_replace( '/\r\n?/', "\n", $contents ); + + // We only want message arrays. + $results = []; + preg_match_all( '/\$messages(?:.*\s)*?\);/', $contents, $results ); + + // But we want them all in one string. + return implode( "\n\n", $results[0] ); + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/reader/Reader.php b/www/wiki/extensions/LocalisationUpdate/reader/Reader.php new file mode 100644 index 00000000..8c263ff0 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/reader/Reader.php @@ -0,0 +1,21 @@ + array( 'key' => 'value' ) ); + * @param string $contents File contents as a string. + * @return array + */ + public function parse( $contents ); +} diff --git a/www/wiki/extensions/LocalisationUpdate/reader/ReaderFactory.php b/www/wiki/extensions/LocalisationUpdate/reader/ReaderFactory.php new file mode 100644 index 00000000..ab5cdf1b --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/reader/ReaderFactory.php @@ -0,0 +1,38 @@ +assertTrue( + $updater->isDirectory( '/IP/extensions/Translate/i18n/*.json' ), + 'Extension json files are a file pattern' + ); + + $this->assertFalse( + $updater->isDirectory( '/IP/extensions/Translate/Translate.i18n.php' ), + 'Extension php file is not a pattern' + ); + } + + public function testExpandRemotePath() { + $updater = new Updater(); + $repos = [ 'main' => 'file:///repos/%NAME%/%SOME-VAR%' ]; + + $info = [ + 'repo' => 'main', + 'name' => 'product', + 'some-var' => 'file', + ]; + $this->assertEquals( + 'file:///repos/product/file', + $updater->expandRemotePath( $info, $repos ), + 'Variables are expanded correctly' + ); + } + + public function testReadMessages() { + $updater = $updater = new Updater(); + + $input = [ 'file' => 'Hello World!' ]; + $output = [ 'en' => [ 'key' => $input['file'] ] ]; + + $reader = $this->getMock( 'LocalisationUpdate\Reader' ); + $reader + ->expects( $this->once() ) + ->method( 'parse' ) + ->will( $this->returnValue( $output ) ); + + $factory = $this->getMock( 'LocalisationUpdate\ReaderFactory' ); + $factory + ->expects( $this->once() ) + ->method( 'getReader' ) + ->will( $this->returnValue( $reader ) ); + + $observed = $updater->readMessages( $factory, $input ); + $this->assertEquals( $output, $observed, 'Tries to parse given file' ); + } + + public function testFindChangedTranslations() { + $updater = $updater = new Updater(); + + $origin = [ + 'A' => '1', + 'C' => '3', + 'D' => '4', + ]; + $remote = [ + 'A' => '1', // No change key + 'B' => '2', // New key + 'C' => '33', // Changed key + 'D' => '44', // Blacklisted key + ]; + $blacklist = [ 'D' => 0 ]; + $expected = [ 'B' => '2', 'C' => '33' ]; + $observed = $updater->findChangedTranslations( $origin, $remote, $blacklist ); + $this->assertEquals( $expected, $observed, 'Changed and new keys returned' ); + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/tests/phpunit/finder/FinderTest.php b/www/wiki/extensions/LocalisationUpdate/tests/phpunit/finder/FinderTest.php new file mode 100644 index 00000000..1b4db0f4 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/tests/phpunit/finder/FinderTest.php @@ -0,0 +1,86 @@ + '/IP/extensions/Translate/TranslateSearch.i18n.php', + 'Babel' => '/IP/extensions/Babel/Babel.i18n.php', + ], + [ + 'Babel' => '/IP/extensions/Babel/i18n', + 'Door' => [ + 'core' => '/IP/extensions/Door/i18n/core', + 'extra' => '/IP/extensions/Door/i18n/extra', + ], + 'Vector' => '/IP/skins/Vector/i18n', + ], + '/IP' + ); + $observed = $finder->getComponents(); + + $expected = [ + 'repo' => 'mediawiki', + 'orig' => "file:///IP/languages/messages/Messages*.php", + 'path' => 'languages/messages/i18n/*.json', + ]; + + $this->assertArrayHasKey( 'core', $observed ); + $this->assertEquals( $expected, $observed['core'], 'Core php file' ); + + $expected = [ + 'repo' => 'extension', + 'name' => 'Translate', + 'orig' => 'file:///IP/extensions/Translate/TranslateSearch.i18n.php', + 'path' => 'TranslateSearch.i18n.php' + ]; + $this->assertArrayHasKey( 'TranslateSearch', $observed ); + $this->assertEquals( $expected, $observed['TranslateSearch'], 'PHP only extension' ); + + $expected = [ + 'repo' => 'extension', + 'name' => 'Babel', + 'orig' => 'file:///IP/extensions/Babel/i18n/*.json', + 'path' => 'i18n/*.json' + ]; + $this->assertArrayHasKey( 'Babel-0', $observed ); + $this->assertEquals( $expected, $observed['Babel-0'], 'PHP&JSON extension' ); + + $expected = [ + 'repo' => 'extension', + 'name' => 'Door', + 'orig' => 'file:///IP/extensions/Door/i18n/core/*.json', + 'path' => 'i18n/core/*.json' + ]; + $this->assertArrayHasKey( 'Door-core', $observed ); + $this->assertEquals( $expected, $observed['Door-core'], 'Multidir json extension' ); + + $expected = [ + 'repo' => 'extension', + 'name' => 'Door', + 'orig' => 'file:///IP/extensions/Door/i18n/extra/*.json', + 'path' => 'i18n/extra/*.json' + ]; + $this->assertArrayHasKey( 'Door-extra', $observed ); + $this->assertEquals( $expected, $observed['Door-extra'], 'Multidir json extension' ); + + $expected = [ + 'repo' => 'skin', + 'name' => 'Vector', + 'orig' => 'file:///IP/skins/Vector/i18n/*.json', + 'path' => 'i18n/*.json' + ]; + $this->assertArrayHasKey( 'Vector-0', $observed ); + $this->assertEquals( $expected, $observed['Vector-0'], 'Json skin' ); + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php b/www/wiki/extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php new file mode 100644 index 00000000..11f0a03b --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/tests/phpunit/reader/JSONReaderTest.php @@ -0,0 +1,42 @@ +parse( $input ); + $this->assertEquals( $expected, $observed['xx'], $comment ); + } + + public function parseProvider() { + return [ + [ + '{}', + [], + 'empty file', + ], + [ + '{"key":"value"}', + [ 'key' => 'value' ], + 'file with one string', + ], + [ + '{"@metadata":{"authors":["Nike"]},"key":"value2"}', + [ 'key' => 'value2' ], + '@metadata is ignored', + ] + ]; + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/tests/phpunit/reader/ReaderFactoryTest.php b/www/wiki/extensions/LocalisationUpdate/tests/phpunit/reader/ReaderFactoryTest.php new file mode 100644 index 00000000..86776395 --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/tests/phpunit/reader/ReaderFactoryTest.php @@ -0,0 +1,43 @@ +getReader( $input ); + $observed = get_class( $reader ); + $this->assertEquals( $expected, $observed, $comment ); + } + + public function getReaderProvider() { + return [ + [ + 'languages/messages/MessagesFi.php', + 'LocalisationUpdate\PHPReader', + 'core php file', + ], + [ + 'extensions/Translate/Translate.i18n.php', + 'LocalisationUpdate\PHPReader', + 'extension php file', + ], + [ + 'extension/Translate/i18n/core/de.json', + 'LocalisationUpdate\JSONReader', + 'extension json file', + ], + ]; + } +} diff --git a/www/wiki/extensions/LocalisationUpdate/update.php b/www/wiki/extensions/LocalisationUpdate/update.php new file mode 100644 index 00000000..a8ed7ead --- /dev/null +++ b/www/wiki/extensions/LocalisationUpdate/update.php @@ -0,0 +1,93 @@ +mDescription = 'Fetches translation updates to MediaWiki core, skins and extensions.'; + $this->addOption( + 'repoid', + 'Fetch translations from repositories identified by this', + false, /*required*/ + true /*has arg*/ + ); + + $this->requireExtension( 'LocalisationUpdate' ); + } + + public function execute() { + // Prevent the script from timing out + set_time_limit( 0 ); + ini_set( "max_execution_time", 0 ); + ini_set( 'memory_limit', -1 ); + + global $IP; + global $wgExtensionMessagesFiles; + global $wgLocalisationUpdateRepositories; + global $wgLocalisationUpdateRepository; + + $dir = LocalisationUpdate::getDirectory(); + if ( !$dir ) { + $this->error( "No cache directory configured", true ); + return; + } + + $lc = Language::getLocalisationCache(); + $messagesDirs = $lc->getMessagesDirs(); + + $finder = new LocalisationUpdate\Finder( $wgExtensionMessagesFiles, $messagesDirs, $IP ); + $readerFactory = new LocalisationUpdate\ReaderFactory(); + $fetcherFactory = new LocalisationUpdate\FetcherFactory(); + + $repoid = $this->getOption( 'repoid', $wgLocalisationUpdateRepository ); + if ( !isset( $wgLocalisationUpdateRepositories[$repoid] ) ) { + $known = implode( ', ', array_keys( $wgLocalisationUpdateRepositories ) ); + $this->error( "Unknown repoid $repoid; known: $known", true ); + return; + } + $repos = $wgLocalisationUpdateRepositories[$repoid]; + + // output and error methods are protected, hence we add logInfo and logError + // public methods, that hopefully won't conflict in the future with the base class. + $logger = $this; + + // Do it ;) + $updater = new LocalisationUpdate\Updater(); + $updatedMessages = $updater->execute( + $finder, + $readerFactory, + $fetcherFactory, + $repos, + $logger + ); + + // Store it ;) + $count = array_sum( array_map( 'count', $updatedMessages ) ); + if ( !$count ) { + $this->output( "Found no new translations\n" ); + return; + } + + foreach ( $updatedMessages as $language => $messages ) { + $filename = "$dir/" . LocalisationUpdate::getFilename( $language ); + file_put_contents( $filename, FormatJson::encode( $messages, true ) ); + } + $this->output( "Saved $count new translations\n" ); + } + + public function logInfo( $msg ) { + $this->output( $msg . "\n" ); + } + + public function logError( $msg ) { + $this->error( $msg ); + } +} + +$maintClass = Update::class; +require_once RUN_MAINTENANCE_IF_MAIN; -- cgit v1.2.1