デスクトップでUbuntuを使っています

Linuxで役立つ情報を独自にまとめます。間違っているかもしれません。古いのもいっぱいあります。

アプリを日本語化する

 前回紹介した付箋アプリ「Indicator Stickynotes」のメニューやメッセージが英語だったので、日本語化してみました。日本語化するためには、「/usr/share/locale/ja/LC_MESSAGES/indicator-stickynotes.mo」というファイルを作成しなくてはいけません。

f:id:linux_user:20160913122916p:plain

 まず、Indicator Stickynotesのソースコードを入手するために、入手先となるリポジトリー情報を追加します。「/etc/apt/sources.list.d/umang-ubuntu-indicator-stickynotes-xenial.list」の2行目の先頭にある「# 」を取ります。テキストエディタで編集してもよいのですが、文字列を置換できる「sed」コマンドを使って書き換えました。
$ sudo sed -i -e "s/^# //" /etc/apt/sources.list.d/umang-ubuntu-indicator-stickynotes-xenial.list
 書き換えたら、リポジトリー情報を更新し、作業用ディレクトリー(~/stickynotes)を作成して、その中にIndicator Stickynotesのソースコードをダウンロードします。
$ sudo apt update
$ mkdir ~/stickynotes
$ cd ~/stickynotes
$ apt source indicator-stickynotes
 入手したソースコードの「indicator-stickynotes-0.5.8/po/」ディレクトリー内に、メニューなどをそれぞれの言語に変換するファイル(拡張子は「.po」)があります。どれかのファイルを「ja.po」の名前でコピーして書き換えます。
$ cd indicator-stickynotes-0.5.8/po
$ cp ca.po ja.po
$ gedit ja.po
 書き換えた内容は、次の通りです。著者情報などの書き方はよく知らないので間違っているかもしれません。

# Japanese translation for indicator-stickynotes
# Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013
# This file is distributed under the same license as the indicator-stickynotes package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2013.
#
msgid ""
msgstr ""
"Project-Id-Version: indicator-stickynotes\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2016-09-15 09:50+0900\n"
"PO-Revision-Date: 2016-09-15 09:50+0900\n"
"Last-Translator: Ubuntu user <Unknown>\n"
"Language-Team: Japanese <ja@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 16bit\n"
"X-Launchpad-Export-Date: 2016-00-00 00:00+0900\n"
"X-Generator: Launchpad (build xxxx)\n"

#: indicator-stickynotes.py:62
msgid "Error reading data file. Do you want to backup the current data?"
msgstr "読み取りエラー。現在のデータをバックアップしますか?"

#: indicator-stickynotes.py:67
msgid "Backup"
msgstr "バックアップ"

#: indicator-stickynotes.py:68 indicator-stickynotes-i18n.desktop.in:4
msgid "Indicator Stickynotes"
msgstr "付箋インジケーター"

#: indicator-stickynotes.py:88 indicator-stickynotes.py:267 StickyNotes.ui:33
#: indicator-stickynotes-i18n.desktop.in:5
msgid "Sticky Notes"
msgstr "付箋"

#: indicator-stickynotes.py:91 StickyNotes.ui:88
msgid "New Note"
msgstr "新しい付箋"

#: indicator-stickynotes.py:100
msgid "Show All"
msgstr "すべて表示"

#: indicator-stickynotes.py:105
msgid "Hide All"
msgstr "すべて隠す"

#: indicator-stickynotes.py:114
msgid "Lock All"
msgstr "すべてロック"

#: indicator-stickynotes.py:119
msgid "Unlock All"
msgstr "すべてアンロック"

#: indicator-stickynotes.py:128 indicator-stickynotes.py:197
msgid "Export Data"
msgstr "書き出し"

#: indicator-stickynotes.py:133 indicator-stickynotes.py:223
msgid "Import Data"
msgstr "読み込み"

#: indicator-stickynotes.py:142
msgid "About"
msgstr "アプリについて"

#: indicator-stickynotes.py:147 GlobalDialogs.ui:93 stickynotes/gui.py:227
msgid "Settings"
msgstr "設定"

#: indicator-stickynotes.py:156
msgid "Quit"
msgstr "終了"

#: indicator-stickynotes.py:211
msgid "Please choose a different destination for the backup file."
msgstr "バックアップの保存場所を選んでください"

#: indicator-stickynotes.py:237
msgid "Error importing data."
msgstr "読み込み"

#: GlobalDialogs.ui:8
msgid "About Indicator Stickynotes"
msgstr "付箋インジケーターについて"

#: GlobalDialogs.ui:15
msgid ""
"Please report bugs, contribute translations, and make suggestions on the "
"Launchpad homepage below.\n"
"\n"
"Keyboard shortcuts:\n"
"Ctrl + W:  Delete note\n"
"Ctrl + L:  Lock note\n"
"Ctrl + N:  New note"
msgstr ""
"以下のホームページにバグレポートをお送りください\n"
"\n"
"キーボードショートカット:\n"
"Ctrl + W:  付箋の削除\n"
"Ctrl + L:  付箋のロック\n"
"Ctrl + N:  新しい付箋"

#: GlobalDialogs.ui:149 GlobalDialogs.ui:151
msgid "New"
msgstr "新規"

#: GlobalDialogs.ui:205
msgid "_Categories"
msgstr "_カテゴリー"

#: SettingsCategory.ui:23
msgid "Background Color"
msgstr "背景カラー"

#: SettingsCategory.ui:35
msgid "Text Color"
msgstr "テキストカラー"

#: SettingsCategory.ui:48
msgid "Pick a Background Color"
msgstr "背景カラーを選ぶ"

#: SettingsCategory.ui:62
msgid "Pick a Text Color"
msgstr "テキストカラーを選ぶ"

#: SettingsCategory.ui:76
msgid "Name"
msgstr "名前"

#: SettingsCategory.ui:100
msgid "Font"
msgstr "フォント"

#: SettingsCategory.ui:133
msgid "Make Default Category"
msgstr "デフォルトカテゴリーの作成"

#: SettingsCategory.ui:135
msgid "Make Default"
msgstr "デフォルトとして設定"

#: SettingsCategory.ui:149 SettingsCategory.ui:151 StickyNotes.ui:54
msgid "Delete"
msgstr "削除"

#: SettingsCategory.ui:174 stickynotes/gui.py:246 stickynotes/gui.py:336
#: stickynotes/gui.py:357
msgid "New Category"
msgstr "新しいカテゴリー"

#: stickynotes/gui.py:222
msgid "Always on top"
msgstr "前面に表示"

#: stickynotes/gui.py:238
msgid "Categories:"
msgstr "カテゴリー:"

#: stickynotes/gui.py:268
msgid "Are you sure you want to delete this note?"
msgstr "この付箋を削除してもよいですか?"

#: stickynotes/gui.py:300
msgid "Unlock"
msgstr "アンロック"

#: stickynotes/gui.py:301
msgid "Lock"
msgstr "ロック"

#: stickynotes/gui.py:359
msgid "Default Category"
msgstr "デフォルトカテゴリー"

#: stickynotes/gui.py:366
msgid "Are you sure you want to delete this category?"
msgstr "このカテゴリーを削除してもよいですか?"

#: indicator-stickynotes-i18n.desktop.in:6
msgid "Write reminders on notes"
msgstr "付箋にメモを書く"

 ja.poファイルを拡張子「.mo」のファイルに変換し、/usr/share/locale/ja/LC_MESSAGES/indicator-stickynotes.moファイルとして保存します。

$ msgfmt -o ja.mo ja.po

$ sudo cp ja.mo /usr/share/locale/ja/LC_MESSAGES/indicator-stickynotes.mo
 これで、メニューやメッセージがすべて日本語で表示されます。既にIndicator Stickynotesを起動している場合は、再起動してください。

f:id:linux_user:20160913140824p:plain

 ちなみに、英語以外の言語に対応しているアプリなら同じような手順で日本語化できることがほとんどです。