Help:Extension:Translate/Translation aids/pl

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page Help:Extension:Translate/Translation aids and the translation is 44% complete.
Other languages:
Deutsch • ‎English • ‎Lëtzebuergesch • ‎dansk • ‎español • ‎français • ‎lietuvių • ‎polski • ‎português • ‎português do Brasil • ‎čeština • ‎български • ‎русский • ‎українська • ‎中文 • ‎日本語

Translation aids (or translation helpers) are modules that provide helpful and necessary information for the translator when translating. Different aids can provide suggestions from translation memory and machine translation, documentation about the message or even such a basic thing as the message definition – the text that needs to be translated.

There is some overlap between the data provided by message collection and the aids, but the rule of thumb is that message collection only provides information that is absolutely needed to present the list of messages: definition, translation, status of translation, last translator (because one can only review translations made by someone else) etc.

Translate comes with many aid classes. Each class that extends the TranslationAid class only needs to implement one method called getData. It should return the information in structured format (nested arrays). These modules can be called either directly from PHP or via the WebAPI.

Jak korzystać z pomocników tłumaczeń wewnątrz MediaWiki

Prosty przykład, jak pobrać dokumentację komunikatu, jeśli jest dostępna.

$title = Title::newFromText( 'MediaWiki:Jan/de' );
$handle = new MessageHandle( $title );
$group = $handle->getGroup();
$context = RequestContext::newExtraneousContext( $title );

$aid = new DocumentationAid( $group, $handle, $context );

try {
	$data = $aid->getData();
	$docHtml = $aid['html'];
} catch ( TranslationHelperException $e ) {
	return;
}

echo $docHtml . "\n";

Jak korzystać z API pomocników tłumaczeń

As already seen above, translation aids are available via a WebAPI, which is using the MediaWiki WebAPI framework. Getting translation aids is as simple as doing HTTP GET for the URL http://translatewiki.net/w/api.php?action=translationaids&title=MediaWiki%3AJan%2Fde . It provides various different formats, but JSON and XML are the most popular ones. This API does not need authentication, but some translation aids like "inotherlanguages" uses user preferences to determine which languages to use. To use that aid you should log in first, as described in the MediaWiki WebAPI documentation.

Zwracane dane powinny wyglądać następująco (pokazane w ładnym formacie JSON):

{
	"helpers": {
		"definition": {
			"value": "Jan",
			"language": "en"
		},
		"translation": {
			"language": "de",
			"fuzzy": false,
			"value": "Jan."
		},
		"inotherlanguages": [
			
		],
		"documentation": {
			"language": "en",
			"value": "Abbreviation of January, the first month of the Gregorian calendar",
			"html": "<p>Abbreviation of January, the first month of the Gregorian calendar\n<\/p>"
		},
		"mt": [
			{
				"target": "Jan",
				"service": "Microsoft",
				"source_language": "en",
				"source": "Jan"
			},
			{
				"target": "Jan",
				"service": "Yandex",
				"source_language": "en",
				"source": "Jan"
			}
		],
		"definitiondiff": {
			"error": "No changes"
		},
		"ttmserver": [
			{
				"source": "Jan",
				"target": "Jan.",
				"context": "MediaWiki:Jan",
				"location": "MediaWiki:Jan\/de",
				"quality": 1,
				"wiki": "mediawiki-bw_",
				"service": "TTMServer",
				"source_language": "en",
				"local": true,
				"uri": "https:\/\/translatewiki.net\/wiki\/MediaWiki:Jan\/de"
			}
		],
		"support": {
			"url": "\/\/translatewiki.net\/w\/i.php?title=Support&lqt_method=talkpage_new_thread&lqt_subject_field=About+%5B%5BMediaWiki%3AJan%2Fde%5D%5D"
	}
}

Every requested aid is guaranteed to have a key here (until the request fails miserably), but while we use exceptions in the PHP side, in the JavaScript side each aid may have the key "error" set with the error message set as value. You can see an example of this above with definitiondiff. It signals that it cannot display a diff, because there have been no changes to the definition since last translation.

Przykładowy JavaScript

Here is the same thing for JavaScript. By default the API returns all aids, but you can request specific ones with the prop param. In the example we are using jsonp to work around cross site request limitations. Be aware that you cannot execute any write actions with jsonp, so if you are using this API from JavaScript you will need: to have a proxy; to run the script on the same host; or to load a little helper (not yet implemented) from the target site.

apiURL = 'https://translatewiki.net/w/api.php?callback=?';

queryParams = {
	action: 'translationaids',
	title: 'MediaWiki:Jan/de',
	format: 'json'
};

$.getJSON( apiURL, queryParams )
	.complete( function( data ) {
		console.log( data );
	} )
	.fail( function () {
		console.log( "Failed" );
	} );

Konwencje nazewnictwa i zwracane wartości

Each translation aid has a unique string identifier. Identifiers should avoid special characters, especially those which are not valid in JavaScript identifiers, like - and *.

The array that is returned by each translation aid is up to the developer, but should follow some general recommendations.

If only one text value is returned, it should use value as the key of the field. Language should be provided in field language. Users of this data should ensure that in HTML and elsewhere the text is tagged properly with the provided language and directionality (not provided here). If there is HTML output, it should be available with key html. Examples of this are message documentation and diffs.

Various kinds of translation suggestions like machine translation and translation memories should use these keys when they make sense:

  • source, source_language and target (target language is implicitly the same as the language of the translation)
  • server: identifier of the service used
  • quality: value in range [0,1], higher value means that the quality of the suggestions is very good.

Note: When returning arrays, you must set the ** field to contain an element name. For machine translation and translation memory this is suggestion. This is mandated by the MediaWiki WebAPI framework. It is visible in the XML format, but in JSON format the output is just a list.

Lista standardowych pomocników

[field] Oznacza, że wartością zwracaną jest lista. W PHP oznacza to tablicę z indeksami numerycznymi + jeden z kluczy **; zobacz powyżej, dlaczego jest to potrzebne.

Klasa Identyfikator Pola Uwagi
MessageDefinitionAid definition
  • language
  • value
CurrentTranslationAid translation
  • language
  • value
  • fuzzy - (boolean) Jeśli tłumaczenie istnieje, ale wymaga przejrzenia lub aktualizacji.
InOtherLanguagesAid inotherlanguages
  • [suggestion]
    • language
    • value
W zależności od preferencji użytkownika
DocumentationAid documentation
  • language
  • value - Unparsed wiki markup
  • html
MachineTranslationAid mt
  • [suggestion]
    • source
    • source_language
    • target
    • service
Dostępność zależy od wsparcia pary językowej i dostępności usług zewnętrznych.
UpdatedDefinitionAid definitiondiff
  • value_old
  • value_new
  • revisionid_old
  • revisionid_new
  • language
  • html
Display depends on mediawiki.action.history.diff Resource Loader Module of MediaWiki.
TTMServerAid ttmserver
  • [suggestion]
    • source
    • source_language
    • target
    • service
    • quality
    • local - (boolean) Whether the suggestion is a message in the wiki queried.
    • uri - URL or other resource location indicator.
SupportAid support
  • url
To jest strona internetowa, na którą użytkownik może zostać skierowany, aby odpowiedzieć na pytania dotyczące tego komunikatu.
InsertablesAid insertables
  • [insertable]
    • display
    • pre
    • post
Strings of untranslatable text that can be inserted into the translation. Fields tell what to display to the user and what is inserted before and after selection.