Page MenuHomePhabricator

Port Romanian diacritics replacement script from JS to PHP
Closed, InvalidPublic

Description

Porting the input scripts from [1] to PHP should allow us to maintain a single instance of the scripts, instead of a different one for each editor that might exist out there.

[1] https://ro.wikipedia.org/wiki/MediaWiki:Diacritice.js

Event Timeline

Great start.

Coding conventions

This pull request allows your code to respect MediaWiki coding convention.

Architecture and testable part of the code

I'd suggest to isolate the part of the RomanianDiacriticsReplacements::attemptSave method which perfoms the actual replacement, the same way the JS doesw ith the allCommas function.

This way, you can write unit test with the transformation you want to achieve, then run your function against them.

A popular pattern in modern MediaWiki extensions is to have a class only for the hooks. The goal is separation of concerns: one class for logic code, one class for wiring with the MediaWiki relevant events.

L10n

You can copy en.json to qqq.json, then document the goal of each string. That will be used on TranslateWiki to help translators.

JSON

JSON files weren't parsable. This pull request fixes that.

You can validate JSON with this tool. A CLI version exists: npm install jsonlint.

Goal

What's the goal of the extension, do you want this to be deployed on ro. Wikimedia projects?

If so, you can request here a Git repository and here a component in Phabricator for your extension.

@Dereckson , thanks for the pull requests and advice. Yes, the final idea is to have this used on Romanian projects. However, I would still prefer to work on Github until I reach feature parity with JS. This shouldn't take too long; I hope to have a usable version by the hackathon @ Wikimania. At that point I hope I will also have the approval of the Romanian community so I can ask for a security review and all the other steps needed for deployment.

I would appreciate some advice on how to allow the community to edit the regular expressions for the elements that are skipped. Is the MediaWiki namespace still the preferred way to do this?

Okay, happy coding for the next steps :)

On wiki configuration is still done per messages in the MediaWiki: namespace, yes. Here the syntax could be tricky as I imagine you want these messages to respect a certain format you can read as an array.

Some extensions rely on Extension:JsonConfig to achieve this goal. If you're interested to store as a JSON configuration the list of these regular expressions you could ask @Yurik to worth with you on this topic at the Wikimania hackathon, it's the author of JsonConfig.

No reply; closing per last comment.