Siebrand has uploaded a new change for review. https://gerrit.wikimedia.org/r/123083
Change subject: Migrate to JSON i18n ...................................................................... Migrate to JSON i18n Procedure per https://www.mediawiki.org/wiki/Manual:GenerateJsonI18n.php with shim. Change-Id: I71a2a5b026710627c654079cd0ec144b4af07ffd --- M SimpleSurvey.i18n.php M SimpleSurvey.php A i18n/en.json 3 files changed, 80 insertions(+), 60 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SimpleSurvey refs/changes/83/123083/1 diff --git a/SimpleSurvey.i18n.php b/SimpleSurvey.i18n.php index c4c073f..eeb2776 100644 --- a/SimpleSurvey.i18n.php +++ b/SimpleSurvey.i18n.php @@ -1,62 +1,31 @@ <?php - -$messages = array(); - -/** English - * @author Nimish Gautam +/** + * This is a backwards-compatibility shim, generated by: + * https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php + * + * Beginning with MediaWiki 1.23, translation strings are stored in json files, + * and the EXTENSION.i18n.php file only exists to provide compatibility with + * older releases of MediaWiki. For more information about this migration, see: + * https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format + * + * This shim maintains compatibility back to MediaWiki 1.17. */ -$messages['en'] = array( - 'simplesurvey' => 'Take a quick survey', - 'simple-survey-invalid' => 'That is not a valid survey at this time', - 'simple-survey-back' => 'Go back', - 'simple-survey-title' => 'Simple Survey', - 'simple-survey-confirm' => 'Thanks! Your data has been submitted.', +$messages = array(); +$GLOBALS['wgHooks']['LocalisationCacheRecache'][] = function ( $cache, $code, &$cachedData ) { + $codeSequence = array_merge( array( $code ), $cachedData['fallbackSequence'] ); + foreach ( $codeSequence as $csCode ) { + $fileName = __DIR__ . "/i18n/$csCode.json"; + if ( is_readable( $fileName ) ) { + $data = FormatJson::decode( file_get_contents( $fileName ), true ); + foreach ( array_keys( $data ) as $key ) { + if ( $key === '' || $key[0] === '@' ) { + unset( $data[$key] ); + } + } + $cachedData['messages'] = array_merge( $data, $cachedData['messages'] ); + } - /*vitals 07 2010 */ - 'simple-survey-intro-vitals-07-2010' => 'This is a quick survey to give us a better idea of who you are', - 'vitals-07-2010-submit' => 'Submit', - - 'vitals-07-2010-question-use' => 'How often do you use Wikipedia?', - 'vitals-07-2010-question-edit' => 'Do you edit Wikipedia?', - 'vitals-07-2010-question-nonprofit' => 'Did you know Wikipedia is a non-profit project?', - 'vitals-07-2010-question-wikimedia' => 'Which of these describes your knowledge of the Wikimedia Foundation, the organization that hosts Wikipedia and its sister projects such as Wiktionary and Wikiquote:', - 'vitals-07-2010-question-age' => 'Please tell us your age', - 'vitals-07-2010-question-programming' => 'Please tell us which one of these describes you:', - 'vitals-07-2010-question-gender' => 'Please tell us your gender', - 'vitals-07-2010-question-story' => 'We love hearing about ways Wikipedia has impacted your life! Please feel free to share any stories, explain any of your answers, or leave a comment for the Wikimedia Foundation here:', - 'vitals-07-2010-question-computerexp' => "Which one of the following describes your computer experience?", - - 'vitals-07-2010-blank' => '', - 'vitals-07-2010-answer-daily' => 'Daily', - 'vitals-07-2010-answer-weekly' => 'Weekly', - 'vitals-07-2010-answer-monthly' => 'Monthly', - 'vitals-07-2010-answer-rarely' => 'less than monthly', - 'vitals-07-2010-answer-firsttime' => 'This was my first time', - 'vitals-07-2010-answer-never' => 'Never', - - 'vitals-07-2010-answer-y-daily' => 'Yes, daily', - 'vitals-07-2010-answer-y-weekly' => 'Yes, weekly', - 'vitals-07-2010-answer-y-monthly' => 'Yes, monthly', - 'vitals-07-2010-answer-y-rarely' => 'Yes, but less than monthly', - 'vitals-07-2010-answer-n-never' => 'No, never', - 'vitals-07-2010-answer-dunno-edit' => "I didn't know you could edit", - - 'vitals-07-2010-answer-nonprof-knew' => "I knew it was a non-profit", - 'vitals-07-2010-answer-nonprof-business' => "I assumed it was a for-profit business", - 'vitals-07-2010-answer-nonprof-think' => "I've never thought about it", - - 'vitals-07-2010-answer-never-heard' => "I've never heard of it", - 'vitals-07-2010-answer-heard-nothing' => "I guess I've heard of it, but don't know anything about it", - 'vitals-07-2010-answer-hosted' => "I know that Wikipedia is hosted by the Wikimedia Foundation, but that's about it", - 'vitals-07-2010-answer-know' => "I'm familiar with the Wikimedia Foundation", - - 'vitals-07-2010-answer-beginner' => "I am a beginner with at least one programming language (eg HTML, PHP, Java, C)", - 'vitals-07-2010-answer-one-lang' => "I am comfortable with at least one programming language", - 'vitals-07-2010-answer-many-lang' => "I am comfortable with many programming languages", - 'vitals-07-2010-answer-no-lang' => "Programming? Not me!", - - 'vitals-07-2010-answer-male' => 'Male', - 'vitals-07-2010-answer-female' => 'Female', - 'vitals-07-2010-answer-other' => 'Other', - ); - + $cachedData['deps'][] = new FileDependency( $fileName ); + } + return true; +}; diff --git a/SimpleSurvey.php b/SimpleSurvey.php index 5bc1ede..a6c11eb 100644 --- a/SimpleSurvey.php +++ b/SimpleSurvey.php @@ -18,6 +18,7 @@ // add special pages $wgSpecialPages['SimpleSurvey'] = 'SpecialSimpleSurvey'; $wgSpecialPageGroups['SimpleSurvey'] = 'wiki'; +$wgMessagesDirs['SimpleSurvey'] = __DIR__ . '/i18n'; $wgExtensionMessagesFiles['SimpleSurvey'] = $dir . 'SimpleSurvey.i18n.php'; @@ -25,7 +26,7 @@ 'path' => __FILE__, 'name' => 'SimpleSurvey', 'author' => array( 'Nimish Gautam' ), - 'version' => '0.1', + 'version' => '0.2.0', 'url' => 'https://www.mediawiki.org/wiki/Extension:UsabilityInitiative', ); diff --git a/i18n/en.json b/i18n/en.json new file mode 100644 index 0000000..c451be0 --- /dev/null +++ b/i18n/en.json @@ -0,0 +1,50 @@ +{ + "@metadata": { + "authors": [ + "Nimish Gautam" + ] + }, + "simplesurvey": "Take a quick survey", + "simple-survey-invalid": "That is not a valid survey at this time", + "simple-survey-back": "Go back", + "simple-survey-title": "Simple Survey", + "simple-survey-confirm": "Thanks! Your data has been submitted.", + "simple-survey-intro-vitals-07-2010": "This is a quick survey to give us a better idea of who you are", + "vitals-07-2010-submit": "Submit", + "vitals-07-2010-question-use": "How often do you use Wikipedia?", + "vitals-07-2010-question-edit": "Do you edit Wikipedia?", + "vitals-07-2010-question-nonprofit": "Did you know Wikipedia is a non-profit project?", + "vitals-07-2010-question-wikimedia": "Which of these describes your knowledge of the Wikimedia Foundation, the organization that hosts Wikipedia and its sister projects such as Wiktionary and Wikiquote:", + "vitals-07-2010-question-age": "Please tell us your age", + "vitals-07-2010-question-programming": "Please tell us which one of these describes you:", + "vitals-07-2010-question-gender": "Please tell us your gender", + "vitals-07-2010-question-story": "We love hearing about ways Wikipedia has impacted your life! Please feel free to share any stories, explain any of your answers, or leave a comment for the Wikimedia Foundation here:", + "vitals-07-2010-question-computerexp": "Which one of the following describes your computer experience?", + "vitals-07-2010-blank": "", + "vitals-07-2010-answer-daily": "Daily", + "vitals-07-2010-answer-weekly": "Weekly", + "vitals-07-2010-answer-monthly": "Monthly", + "vitals-07-2010-answer-rarely": "less than monthly", + "vitals-07-2010-answer-firsttime": "This was my first time", + "vitals-07-2010-answer-never": "Never", + "vitals-07-2010-answer-y-daily": "Yes, daily", + "vitals-07-2010-answer-y-weekly": "Yes, weekly", + "vitals-07-2010-answer-y-monthly": "Yes, monthly", + "vitals-07-2010-answer-y-rarely": "Yes, but less than monthly", + "vitals-07-2010-answer-n-never": "No, never", + "vitals-07-2010-answer-dunno-edit": "I didn't know you could edit", + "vitals-07-2010-answer-nonprof-knew": "I knew it was a non-profit", + "vitals-07-2010-answer-nonprof-business": "I assumed it was a for-profit business", + "vitals-07-2010-answer-nonprof-think": "I've never thought about it", + "vitals-07-2010-answer-never-heard": "I've never heard of it", + "vitals-07-2010-answer-heard-nothing": "I guess I've heard of it, but don't know anything about it", + "vitals-07-2010-answer-hosted": "I know that Wikipedia is hosted by the Wikimedia Foundation, but that's about it", + "vitals-07-2010-answer-know": "I'm familiar with the Wikimedia Foundation", + "vitals-07-2010-answer-beginner": "I am a beginner with at least one programming language (eg HTML, PHP, Java, C)", + "vitals-07-2010-answer-one-lang": "I am comfortable with at least one programming language", + "vitals-07-2010-answer-many-lang": "I am comfortable with many programming languages", + "vitals-07-2010-answer-no-lang": "Programming? Not me!", + "vitals-07-2010-answer-male": "Male", + "vitals-07-2010-answer-female": "Female", + "vitals-07-2010-answer-other": "Other" +} -- To view, visit https://gerrit.wikimedia.org/r/123083 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I71a2a5b026710627c654079cd0ec144b4af07ffd Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SimpleSurvey Gerrit-Branch: master Gerrit-Owner: Siebrand <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
