Extension:UniversalLanguageSelector/ja

ユニバーサル言語選択 (ULS: Universal Language Selector) はユーザーが簡単に言語を選びサポートを設定できるツールです. 使用するとウェブフォント及びNarayam拡張機能が同梱されます（両方ともこの拡張機能を優先するため使われていません）. 背景とその他の情報はUniversal Language Selectorを参照してください.

使用法
主目的は、利用者が言語やその設定の変更を簡単に行えるようにすることです.

この拡張機能は以下の機能を提供します.


 * 1) 幅広い言語から柔軟に簡単にひとつ選べる.
 * 2) 地理的位置に基づくウェブ閲覧や検索により選択できる.
 * 3) Search can be based on ISO 言語コード、現在のUIやスクリプトの言語（自称）
 * 4) 言語間検索 - 使用スクリプトに関わらず言語名を検索
 * 5) 言語名のオートコンプリート（自動補完）
 * 6) 検索文字列のつづりの誤りを自動で補正
 * 7) GeoIP から言語をお奨め
 * 8) ユーザーのブラウザやOSによる言語の選択
 * 9) 複数の入力方式
 * 使い方の完全マニュアルはHelp:Extension:UniversalLanguageSelector/Input_methods/jaを参照
 * 1) 使える複数の入力方式から選び、編集ができる欄すべてで使用
 * 2) 幅広い言語群に対応する多様な入力方式
 * 3) * 旧来の入力方式一覧はExtension:Narayam#Supported schemesを参照
 * 4) 言語ごとに入力方式を設定
 * 5) ウェブフォント
 * 6) 言語ごとに多彩なウェブフォントから選び、ページで埋め込みフォントとして用いる
 * 7) * 旧来のウェブフォント一覧は Extension:WebFonts#Supported languagesを参照
 * 8) * 同梱されたフォントの一覧
 * 9) 言語ごとに割り当てるフォントの設定



フォントの追加
言語に適したフォントをコードに追加すると、サポートする言語を増やすことができます. そうは言うものの、追加できるのは無償使用を許可する、たとえば GNU GPL、SIL OFL などの規定に従うフォントに限定されます. Google Fonts はフリーフォントのディレクトリの一例ですが、ULS の作者による検証と利用は未完です. Open Font Libraryも参照してください.

First of all, you need to find or produce such a free font (this is the most important part and you have to do it yourself); then, it has to be converted to the required formats, which are eot, ttf, woff; finally, you can file a request in Phabricator for the font to be added to the extension.

#Preparing webfonts below explains how to convert the fonts: basic knowledge about GNU/Linux based operating system is required; if you have difficulty in doing this, you can skip this step and ask someone else to do it for you on the same Phabricator request (of course this will slow down the process).

Webフォントの準備
Sfntly is required for creating web fonts (command line only).

Once installed, following commands can be used.

.woff の作成:

.woff2 の作成:

Use https://github.com/google/woff2 to generate woff2 from ttf. This will produce a compressed woff2 file. Modern browsers support this format.

Create a font.ini file. Here's an example:

An asterisk after a language code means that this font will be the default font for that language. If you just want the option to use this font for that language, don't use the asterisk.

After creating the files, do the following:
 * 1) Create a directory for the font under data/fontrepo/fonts.
 * 2) Put the ttf, woff, eot and font.ini files in that directory and add them to the source repository.
 * 3) Go to data/fontrepo/scripts and run.
 * 4) Commit the changes to the repository  and submit them according to the Git workflow.

Adding support for a new key mapping (input method)
Follow the instructions on the jquery.ime github wiki, but file requests in the Wikimedia-extensions-UniversalLanguageSelector Phabricator product.

LanguageNameIndexの更新
For performing cross language search, searching autonyms, language data needs to be populated. ULS comes with a pre-populated language name index(data/langnames.ser). In case you want to update it, install Extension:CLDR and update the data with the following command.

php UniversalLanguageSelector/data/LanguageNameIndexer.php and verify that langnames.ser file gets generated in ULS/data/ folder.

設定
The following variables are created automatically during initialization and can be used from JavaScript using mw.config.get( NAME ):
 * - an associative array where the keys are language codes and the values are language names in English.
 * - an array of language codes from the user's Accept-Language value. These are the languages selected in the user's browser preferences.

For serving fonts, you might want to add the following mime types to your webserver if not already there. This guide might help.  application/x-font-woff .woff application/vnd.ms-fontobject .eot application/x-font-ttf .ttf The following variables can also be configured:
 * - ULS can use geolocation services to suggest languages based on the country the user is visiting from. Setting this to false will prevent builtin geolocation from being used. You can provide your own geolocation by setting window.Geo to object which has key 'country_code' or 'country'. If set to true, it will query Wikimedia's geoip service. The service should return jsonp that uses the supplied callback parameter. Defaults to http://freegeoip.net/json/ and expects the same format.
 * - Enable language selection, compact language links, input methods and webfonts for everyone, unless the behavior is overridden by the configuration variables below.  Even if false the classes and resource loader modules are registered for the use of other extensions. Language changing via cookie or setlang query parameter is not possible.
 * - Allow anonymous users to change language with cookie and setlang query param. Do not use if you are caching anonymous page views without taking cookies into account. Does not have any effect if either of   or $wgULSEnableAnon is set to false.
 * - Disable the input methods feature for all users by default. Can still be enabled manually by the user.
 * - The location and the form of the language selection trigger. The possible values are: : as a link near the username or the log in link in the personal toolbar (default).  : as an icon near the header of the list of interlanguage links in the sidebar.
 * - Array of jQuery selectors of elements on which IME must not be enabled. eg:

ULSトリガーの位置

 * - The location and the form of the language selection trigger. The possible values are: : as a link near the username or the log in link in the personal toolbar (default).  : as an icon near the header of the list of interlanguage links in the sidebar.

It is also possible to have ULS trigger anywhere in the screen. An element with  will act as a ULS trigger.

Overriding default fonts
ULS has a large font repository to serve as webfonts. Sometimes there are multiple fonts for a language and there is a default font for each language/script. The order of fonts or default font can be overridden as follows using global scripts (MediaWiki:Common.js) or personal scripts (Special:MyPage/common.js):

Here, languageCode should be a valid language code(eg: en, hi, nl). FontA and FontB are fonts available in font repository. In the above example for languageCode, we set a font available in local computer as default font. ie No default webfont.

Caching configuration
To ensure that the web fonts files are cached on the clients' machines, font file types must be added to the web server configuration. In Apache2 this consists of:
 * Adding font file extensions to the FileTimes regex at FilesMatch for the relevant directory, example:
 * Adding ExpiresByType values to the relevant MIME types, similarly to image MIME types.
 * Note that there's no standard MIME type for TTF. application/x-font-ttf is used for Wikimedia.
 * Adding the MIME types:

 AddType application/x-woff .woff AddType application/vnd.ms-fontobject .eot AddType application/x-font-ttf .ttf

For a full example see the caching configuration update done for the Wikimedia cluster.

ページ翻訳
UniversalLanguageSelector is one of the dependencies of the Translate extension, which uses it for several language selection features. One of it is the MyLanguage system for links, which depends on the interface language of the user, but more can be configured: see Page translation feature.

Webフォントの使用
User can choose webfonts for a language from the Language settings -> Display settings. By default, the first font in that menu will be applied to the wiki. A user can change the font and it will be remembered across the pages. Optionally user can disable the font embedding too by selecting system font.

If the font is available in user's local system, font will not be downloaded from the mediawiki server. It will be taken from the user's computer. Otherwise, font will be downloaded from the server only once. ie when the user selects the font first time. Next time onwards, font will be taken from the local cache.

フォントファミリーを指定
Inside the wiki text YourText, webfonts extension will check whether the font is available with the extension, if so it will download it to the client. So the reader will not face any difficulty in reading the text even if the font specified is not available in their computer.

言語を指定
Inside the wiki text YourText, webfonts extension will check whether any font is available for the given language with the extension, if so it will download it to the client. So the reader will not face any difficulty in reading the text even if the font specified is not available in their computer. If there are multiple fonts for the language, the default font will be used. If default font is not preferred, use the font-family approach to specify the font. If the tag has both lang and font-family definitions, font-family get precedence.

例:

𒄖𒉈𒅁𒌨𒅎

gives the text rendered in Cuneiform using Akkadian font

𒄖𒉈𒅁𒌨𒅎

関連項目

 * Universal Language Selector
 * Universal Language Selector/Interaction Design Framework
 * Universal Language Selector/Technical Design
 * Technical details of Webfonts feature of Universal Language Selector