Last active
June 22, 2018 06:29
-
-
Save onokatio/36feb06211bc663ba697d7856ba83d9b to your computer and use it in GitHub Desktop.
【ja_JP.UTF-8】Linuxのロケールをroot権限なしでローカルインストールする ref: https://qiita.com/onokatio/items/79adac8c3d1701a40a15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
使用法: localedef [OPTION...] NAME | |
または: localedef [OPTION...] | |
[--add-to-archive|--delete-from-archive] FILE... | |
または: localedef [OPTION...] --list-archive [FILE] | |
ロケール仕様をコンパイルする | |
入力ファイル: | |
-f, --charmap=FILE シンボル文字名は FILE | |
内で定義されています | |
-i, --inputfile=FILE FILE 内でソース定義が見つかりました | |
-u, --repertoire-map=FILE FILE にはシンボル名から UCS4 | |
値へのマップが含まれます | |
出力制御: | |
-c, --force | |
警告メッセージがあっても出力を作成する | |
--posix Strictly conform to POSIX | |
--prefix=PATH | |
出力ファイルにオプションの接頭辞を付加する | |
--quiet 警告と情報メッセージを抑制する | |
-v, --verbose 詳細なメッセージを表示する | |
書庫制御: | |
--add-to-archive | |
パラメータで指定された名前のロケールを書庫に追加する | |
-A, --alias-file=FILE 書庫を作成する時に locale.alias | |
ファイルを参照する | |
--big-endian Generate big-endian output | |
--delete-from-archive | |
パラメータで指定された名前のロケールを書庫から削除する | |
--list-archive 書庫の内容のリストを表示する | |
--little-endian Generate little-endian output | |
--no-archive 書庫に新しいデータを追加しない | |
--replace 既存の書庫の内容を置換する | |
-?, --help このヘルプ一覧を表示する | |
--usage 短い使用方法を表示する | |
-V, --version プログラムのバージョンを表示する |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 設定ファイルの作成 | |
$ localedef -i /usr/share/i18n/locales/ja_JP -c -f UTF-8 -A /usr/share/locale/locale.alias /home/user/mylocale/ja_JP.UTF-8 | |
# 書庫の作成 | |
$ mkdir -p /home/user/locale/usr/lib/locale | |
$ localedef -i /usr/share/i18n/locales/ja_JP -c -f UTF-8 -A /usr/share/locale/locale.alias --add-to-archive --prefix=/home/user/locale | |
# prefixで指定したディレクトリ以下のusr/lob/locale/locale-archiveに書庫が生成されます。直接ディレクトリは指定できないようです 。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export LANG=ja_JP.UTF-8 | |
export LOCPATH=$MYLOCAL/usr/lib/locale |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
if [[ -z "$MYLOCAL" ]];then | |
echo '$MYLOCAL is not set.' | |
exit | |
fi | |
LOCALEGEN=$MYLOCAL/etc/locale.gen | |
LOCALES=/usr/share/i18n/locales | |
USER_LOCALES=/usr/local/share/i18n/locales | |
LOCALE_ARCHIVE=$MYLOCAL/usr/lib/locale | |
if [ -n "$POSIXLY_CORRECT" ]; then | |
unset POSIXLY_CORRECT | |
fi | |
[ -f $LOCALEGEN ] || exit 0; | |
[ -s $LOCALEGEN ] || exit 0; | |
KEEP= | |
if [ "$1" = '--keep-existing' ]; then | |
KEEP=1 | |
fi | |
if [ -z "$KEEP" ]; then | |
# Remove all old locale dir and locale-archive before generating new | |
# locale data. | |
rm -rf $LOCALE_ARCHIVE/locale-archive || true | |
fi | |
umask 022 | |
is_entry_ok() { | |
if [ -n "$locale" -a -n "$charset" ] ; then | |
true | |
else | |
echo "error: Bad entry '$locale $charset'" | |
false | |
fi | |
} | |
echo "Generating locales (this might take a while)..." | |
while read locale charset; do \ | |
case $locale in \#*) continue;; "") continue;; esac; \ | |
is_entry_ok || continue | |
if [ "$KEEP" ] && PERL_BADLANG=0 perl -MPOSIX -e \ | |
'exit 1 unless setlocale(LC_ALL, $ARGV[0])' "$locale"; then | |
continue | |
fi | |
echo -n " `echo $locale | sed 's/\([^.\@]*\).*/\1/'`"; \ | |
echo -n ".$charset"; \ | |
echo -n `echo $locale | sed 's/\([^\@]*\)\(\@.*\)*/\2/'`; \ | |
echo -n '...'; \ | |
if [ -f $USER_LOCALES/$locale ] ; then | |
input=$USER_LOCALES/$locale | |
elif [ -f $LOCALES/$locale ]; then | |
input=$locale | |
else | |
input=`echo $locale | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/'` | |
if [ -f $USER_LOCALES/$input ]; then | |
input=$USER_LOCALES/$input | |
fi | |
fi | |
localedef -i $input -c -f $charset -A /usr/share/locale/locale.alias $LOCALE_ARCHIVE/$locale || :; \ | |
echo ' done'; \ | |
localedef -i $input -c -f $charset -A /usr/share/locale/locale.alias --add-to-archive --prefix=$MYLOCAL|| :; \ | |
done < $LOCALEGEN | |
echo "Generation complete." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment