WMDE Technical Wishes/Suggested values for template parameters/ja

From Meta, a Wikimedia project coordination wiki
This page is a translated version of the page WMDE Technical Wishes/Suggested values for template parameters and the translation is 74% complete.
テンプレートのパラメータ推奨値
Status展開先は全てのウィキ
Focus areaテンプレート類
PhabricatorT273857
Responsible技術要望チーム

このページではテンプレートのパラメータの推奨値に関して「テンプレートの操作を簡略化する」という視点から、開発の進捗状態とプロジェクトに関する協議内容を 述べます。この視点について一般情報と、実施するプロジェクトを選んだ背景はこちらのページをご参照ください。

皆さんからのコメントや質問は、ぜひ協議のページにお寄せください。

説明

When filling in parameter values in templates in Visual Editor it is often not obvious at first glance which values are expected for a certain parameter. In some cases only certain values are even accepted by the template, but the user cannot necessarily see what those values are. For example, if a user edits an article about a novel and wants to specify the genre in the parameter "genre" in the infobox, they might ask themselves whether to enter crime, thriller or perhaps mystery?

With the new parameter property suggestedvalues, anyone who creates or maintains templates can now define a list of suggested values for a parameter. These values will then be displayed to VisualEditor users in a dropdown menu. If you use the template and want to enter a value for this parameter, you can then quickly select the appropriate value from the list. If you want to type in a value that is not in the list, e.g. Sci-Fi Crime in the example above, this option is still available. Because there are sometimes situations where an article needs a more customized value, it will be possible to fill in values other than the suggested ones.

This way, the user does not need to know the expected values and their required format in advance. It is no longer necessary to figure out what values go in each field by visiting the template documentation page or to even try to guess the expected values. This new feature is particularly helpful for those who are not yet familiar with a template.

This prevents potential errors, reduces the effort needed to fill the template with values and makes the formatting of the values more consistent. Together with the planned improvements in the template dialog, the suggested values feature makes the usage of templates in the VisualEditor easier.

新しい機能の使い方

新しいパラメータの属性として、 suggestedvalues を指定するとビジュアルエディターの利用者にドロップダウンとしてどのパラメータ値の一覧を表示すことで簡単に選べるようにできます。この機能を使うには、まずそれぞれのテンプレートデータに推奨値類を先に追加しておく必要があります。それには直接、JSON に書き込むか、テンプレートデータ用エディターを使うかできます (後者ならコードが分からなくても大丈夫。) それぞれの詳細は以下に説明します。

テンプレートデータ

パラメータのうち、以下のオプション類を設定すると、ビジュアルエディターで表示する推奨値を追加できます。

  • content (コンテンツ)
  • line (行)
  • string (文字列)
  • number (数値)
  • unknown (不明)
  • unbalanced wikitext (ウィキ文だが不均衡)

Other types (file, page, template, user, date, boolean, URL) are not currently supported because they have special functionalities in the VisualEditor already, such as autocomplete, which would interfere with the drop-down menu for suggested values in the VisualEditor.

TemplateData の編集は JSON でウィキテキスト形式で実行

パラメータの種別を問わず推奨値を加えるには、JSON に新しいプロパティ 「suggestedvalues�」 を記入します。また 「suggestedvalues」 属性は必ず文字列の一覧にします。

例を示すならこんな感じです。

"media_type": {
    "label": "媒体の種別",
    "example": "新聞",
    "type": "string",
    "description": "その記事を掲載した媒体は?",
    "suggestedvalues": [
        "定期刊行物・論文集",
        "書籍",
        "新聞",
        "雑誌"
    ]
}
テンプレートデータ用エディターを使い推奨値を追加する例

専用エディターを使い テンプレートデータを編集するには

上記に示したパラメータ値に関しては、推奨値を追加するにはテンプレートデータのエディターを使います。

Step 1. Click on "Manage TemplateData".

Step 2. Click on the name of the parameter you want to add suggested values to.

Step 3. If it’s not already, set the type of the parameter to one of the following: content, line, string, number, unknown or unbalanced wikitext. A new input field "Suggested values" will appear. If the parameter is already set to one of these types, the input field should already be visible.

Step 4. Type in the suggested value(s), including any spaces and special characters, and press enter to add it to the list.

ビジュアルエディターで推奨された値から選んでテンプレートに記入する例

ビジュアルエディターへの影響

テンプレートデータ (TemplateData ) に値を指定すると、ビジュアルエディター (VisualEditor) で上述のパラメータのタイプの場合、コンボ・ボックスに表示します (ドロップダウンの一種で利用者が好みの文字列を入力できるもの)。利用者は表示された値の一覧から好きなものを選んでクリックします。その一覧が長い場合 -- 例えば特定の国の州の名前全部など -- 入力欄に目的の値を入力すると、文字入力と連動して一覧にフィルタがかかり、入力文字に適合する値にしぼり込みます。入力した文字を変更するには、まず入力値を消去します。すると、いったん消えたドロップダウンメニューが再表示されます。もし利用者が求めている値が一覧に掲載されていない場合は、手入力します (例えば「message in a bottle」。)

現状と次の段階

  • Deployed to all wikis on April 29, 2021.