Page MenuHomePhabricator

[8 hours] Investigate: Evaluate how a new IPA parser tag would be implemented in wikis
Closed, ResolvedPublicSpike

Description

Adopting a new parser tag across different wikis can be challenging. We need to understand how a new parser function would be incorporated in different templates, specially in English wikipedia, the biggest wiki.

Event Timeline

JMcLeod_WMF renamed this task from Investigate: Evaluate how a new IPA parser tag would be implemented in wikis to [8 hours] Investigate: Evaluate how a new IPA parser tag would be implemented in wikis.May 18 2022, 2:40 PM
JMcLeod_WMF added a project: Spike.
Restricted Application changed the subtype of this task from "Task" to "Spike". · View Herald TranscriptMay 18 2022, 2:40 PM
This comment was removed by HMonroy.

My work so far on this has found that if we implement a parser function which uses named parameters, e.g. something like

{{ #phonos: word=Shibboleth | ipa=ˈʃɪbəlɛθ | lang=en-US }}

it could fairly easily be added onto a pre-existing IPA template (or integrated into one of the many Lua modules)

hey @MusikAnimal and/or @Samwilson — any thoughts on the above? I think this makes sense, and its basically what I mocked at rEPHN includes/Phonos.php:29

/**
* Convert phonos magic word to HTML
* {{#phonos: word=hello | ipa=/həˈləʊ/ | type=ipa | lang=en}}
* @todo Error handling for missing required parameters
* @param Parser $parser
* @return string
*/
public static function renderPhonos( Parser $parser ) {
	// Add the CSS and JS
	$parser->getOutput()->addModules( [ 'ext.phonos' ] );

	// Get the named parameters
	$options = self::extractOptions( array_slice( func_get_args(), 1 ) );

	// Explicitly set a default type if none is given
	if ( !isset( $options['type'] ) ) {
		$options['type'] = 'ipa';
	}
	
	// Using a switch() so that future types can be added
	switch ( $options['type'] ) {
		case 'ipa':
			// Fall through
		default:
			// For now, default to IPA
			$html = "<span class='mw-phonos' data-phonos-lang='{$options['lang']}'
	                        data-ssml-sub-alias='{$options['word']}' data-ssml-phoneme-alphabet='ipa'
	                        data-ssml-phoneme-ph='{$options['ipa']}'>{$options['ipa']}</span>";
	}
	
	return $html;
}

but y'all know a bit more about this 😅

It sounds sensible to me!

With some additional config vars for setting default values maybe, and lang defaulting to the page content language? Although those details can be figured out later definitely.

Is word enough, or should it be text or phrase or something to account for multiple words?

It sounds sensible to me!

With some additional config vars for setting default values maybe, and lang defaulting to the page content language? Although those details can be figured out later definitely.

Is word enough, or should it be text or phrase or something to account for multiple words?

text makes much more sense :-)

It sounds sensible to me!

With some additional config vars for setting default values maybe, and lang defaulting to the page content language? Although those details can be figured out later definitely.

lang seems important for multi lingual sites like Commons and esp. wiktionaries that cross reference to translations in other languages. See for instance: https://fr.wiktionary.org/wiki/portemonnaie