如何读写日语

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page How to read and write in Japanese and the translation is 14% complete.
Outdated translations are marked like this.
Other languages:

本指南将会告诉你如何在非日语系统上读写日语。你可以根据自己的经验来对下述步骤进行修改。

需求

为了能支持日语和日语符号,我们需要安装或启用一些工具、库和功能。

日语字体

大多数非日语系统上都没有安装日语字体。在这时如果试图输入日语,你将只能在屏幕上看到一个个小方块。

Japanese Menus and Environment

For those interested (perhaps for immersion based learning) in having a Japanese language based environment, in order to change menus and other materials into the Japanese language, change your profile into LANG=ja_JP.UTF-8 (in your locale as well as .bash_profile[1])

输入法

首先我们要实现能通过键盘输入日语文字和符号。我们使用一种被叫做“输入法”的程序来实现这个目标。我们有两种常见的日语输入法:anthymozc

使用输入法可以在我们在键盘上敲下 ta 时输入日语假名 。同时通过一些简单的操作可以从平假名 切换到片假名

同时我们敲下 “nihou” 时将会输入 にほん,我们也可以很容易得切换到日语汉字版的词语,日本

附注
It is not the purpose of this guide to describe in detail how the "anthy" or "mozc" input methods work. Please refer to the documentation of these software components.

IME

On top of this users also need a way to switch from the input method normally used for the primary language to the one needed for the Japanese language. This functionality is provided by another piece of software called an IME (Input Method Editor) such as app-i18n/ibus, app-i18n/scim or app-i18n/fcitx.

Once installed, this allows users to switch from one language's input method to the Japanese input method using a key combination or using the mouse to select a relevant icon in the icon tray.

Installation

Japanese fonts

As a minimum, install the media-fonts/kochi-substitute package.

root #emerge --ask kochi-substitute

Additionally, the following packages are also available:

附注
Many Japanese fonts display a yen symbol (¥) instead of a backslash (\). To see backslashes instead, the media-fonts/noto-cjk package can be used.
附注
When multiple fonts are installed, fc-config will pick a single font for Monospace, Sans and Serif. Verify which font is used with fc-match monospace, fc-match sans and fc-match serif respectively.

Input tools

It is recommended to use IBus instead of SCIM.

警告
Compose key will stop working when ibus engine is not xkb:*.

anthy

app-i18n/ibus-anthy

root #emerge --ask ibus-anthy

mozc

app-i18n/mozc

root #USE=ibus emerge --ask app-i18n/mozc
附注
mozc has a better reputation than anthy though anthy has been proving working fine for years now. Among pros for mozc, there are the fact that it shows the candidates instantly during typing and has a better learning system in order to present the user the best candidates depending on the user's habit and context. It also provides the ATOK mechanism for quickly change an hiragana input to katakana (e.g. F7 as default before hitting space) or to other modes.
附注
When trying to use mozc some problems might occur. After selecting mozc as an input method in the ibus-preferences graphical utility, the mozc icon in the keyboard icon tray might not be visible. Open the gnome settings --> Countries & Languages, remove all Japanese input methods (in this case "anthy") and add "Japanese(Mozc)".

Configuring

See IBus article on running IBus on login.

user $ibus-setup

In the dialog box that appears, click on the "Input method" tab and add the "japanese-anthy" or "Japanese - Mozc" method. Then return to the "General" tab and define a key combination as a keyboard short cut for switching the input method.

Following useful keybindings could be setted up for "Japanese - Mozc" method:

Preferences → General → Keymap → Keymap style → Customize…

Mode Key Command
Direct input Ctrl ` Set input mode to Hiragana
Precomposition Ctrl ` Deactivate IME
警告
You will most likely want to convert your typing to hiragana. In anthy, change the input mode from Latin to Hiragana.

Common USE Flags

The following use flags are commonly employed[2]:
cjk - Support for Hanzi-inspired characters (containing two bytes, hence the cause of accented a's cum sans cjk environment)
nls - 'native language support' - enables other languages in interface,
immqt-bc - For Qt to manage other language inputs
immqt - conflicts with immqt-bc as of Qt3.
unicode - Standard except for cursive hebrew

Latex

Here are some additional requirements to write Latex files in Japanese.

CJK and xetex support

In order to write Japanese chunks in Latex files, add support for CJK languages and for xetex in Texlive.

This can be accomplished by adding or modifying the following lines in /etc/portage/package.use:

文件 /etc/portage/package.use/latexEnabling cjk and xetex support
app-text/texlive cjk xetex
app-text/texlive-core cjk xetex

Then reinstall the packages:

root #emerge --ask --newuse app-text/texlive app-text/texlive-core

Here is a working short LaTeX sample:

文件 japanese.tex
\documentclass{article}
\usepackage{CJKutf8}
\usepackage{color}
 
\begin{document}
 
\begin{CJK}{UTF8}{min}
\section{One simple example}
\textcolor{red}{これは赤いです。}
\\
私は日本語で書けます。
\\
But I can also write with latin characters
\end{CJK}
 
\end{document}
附注
In the \begin{CJK}{UTF8}{min} command in the example above, the third argument defines the font. Here {min} is used for Mincho, but other supported fonts are Gothic ({goth}) and Maru Gothic ({maru}).

Editor configuration

To compile and visualize the output of the sample above Texmaker or Texstudio editor needs to be configured properly.

Open Texmaker, and go to Options -> Configure Texmaker. Under the Commands tab change the following:

  • At the LaTeX line, change "latex" with "platex".
  • At the Dvipdfm line, change "divipdfm" with "dvipdfmx".

Through the Fast compile tab, choose "Latex + Dvipdfm + View PDF".

Finally go to the Editor tab, choose UTF8 encoding and deselect On the fly on the dictionary line.

See also

  • IBus — an open source input framework for Linux and Unix.
  • TeX Live — a complete TeX distribution with several programs to create professional documents.