Modify Ubuntu tofu to Japanese environment

Introduction

Since Japanese characters were garbled and displayed in a square (so-called Tofu tofu), set the environment for displaying Japanese.

environment

Ubuntu 16.04.5 LTS Windows10 Vagrant

procedure

If you check the environment variable, it is an English environment, so change the environment variable to Japanese

echo $LANG
en_US.UTF-8

Install two Japanese packages (** language-pack-ja-base ** and ** language-pack-ja **) with ** apt **

sudo apt install language-pack-ja-base language-pack-ja

Go home and add the following at the bottom of **. Bashrc **

case $TERM in
    linux) LANG=C ;;
    *)     LANG=ja_JP.UTF-8;;
esac

Commentary The terminal type is set in the environment variable of $ TERM. By the way, ** xterm-256color ** is set in my environment. If the terminal type is ** linux **, the localization is ** C **, otherwise it is in Japanese. When the terminal type is linux, it is the case that the client directly contacts the server instead of using the terminal by SSH connection. In this case, if you use Japanese, the characters will be garbled, so ** C ** is set to create an English environment. If you don't want to touch the server directly, you can just use one line ** LANG = ja_JP.UTF8 **.

Execute **. bashrc ** to reflect

source .bashrc

When you install the Japanese package, a file called ** ja ** will be added to ** /var/lib/locales/supported.d **, so check the contents.

cat /var/lib/locales/supported.d/ja
ja_JP.UTF-8 UTF-8

Display the list of installed locales and confirm that ** ja_JP.utf8 ** is displayed.

locale -a | grep ja

If you check the default locale, it is in English

cat /etc/default/locale

#  File generated by update-locale
LANG="en_US.UTF-8"
LANGUAGE="en_US:"

Change the default locale to Japanese. error? A message that seems to be displayed is displayed, but it has been updated properly.

sudo update-locale LANG=ja_JP.UTF-8
*** update-locale: Warning: LANGUAGE ("en_US:") is not compatible with LANG (ja_JP.UTF-8). Disabling it.

Confirm that it has been changed. Japanese was added and English was commented

cat /etc/default/locale

#  File generated by update-locale
LANG=ja_JP.UTF-8
#LANGUAGE="en_US:"

In the case of vagrant environment, the character code environment on the Windows side (PowerShell side) may be the cause. If the above does not solve the problem, ↓ https://qiita.com/FmtWeisszwerg/items/ccd34acfb2e88c2fb35f

Recommended Posts

Modify Ubuntu tofu to Japanese environment
From Ubuntu 20.04 introduction to environment construction
Steps to install Python environment on Ubuntu
Introduction to docker Create ubuntu environment in ubuntu
[Latest] How to build Java environment on Ubuntu
How to build Java environment on Ubuntu (Linux)
Introducing WSL (Ubuntu 18.04) to WIndows10 ~ Proxy environment second part ~
What I did to ssh to the VPS Ubuntu environment
[Introduction to RasPi4] Environment construction; OpenCV / Tensorflow, Japanese input ♪
Program to weaken Japanese
Ubuntu 19.10 Eoan Ermine Japanese / Japanese locale environment and time zone settings
How to build a new python virtual environment on Ubuntu
Enabled to input Japanese in Linux environment (crostini) of Chromebook
[Ubuntu 18.04] Tensorflow 2.0.0-GPU environment construction
Build python3 environment with ubuntu 16.04
ubuntu 20.04 + geth environment ether remittance
Ubuntu18.04 Development environment creation memo
Kernel parameters to modify often
Ubuntu14.04 + GPU + TensorFlow environment construction
How to build a Python environment using Virtualenv on Ubuntu 18.04 LTS
Shell script to build pyenv environment on ubuntu in one shot