Linux あれこれ

Linux 関連(一部 Windows11 )の備忘録です。

Lubuntu 20.04 LTS にて「Update Notifier」を「アップデートの通知」に翻訳〈H49〉

登録日: 2020-05-15 更新日: 2020-05-23

公開されたばかりの「Lubuntu 20.04 LTS」をUSB メモリにインストールしました。

新しく、システム更新を通知する「Update Notifier」アプリが登場しました。便利になりましたが、日本語化はまだのようです。「Update Notifier」を「アップデートの通知」に翻訳してみました。その備忘録です。当然ながら自己責任です。

-

「目次」

-


「Update Notifier」ダイアログを「アップデートの通知」に日本語化

定期的(1時間ごと?)に自動でシステム更新があるかをチェック、システム更新があると更新を実行するかダイアログが表示されます。自分の都合で更新するタイミングを選べるのはありがたいです。

→日本語化されていません。

→閉じておいて、再表示されるまで待つのもよいのですが、下記のように、 メニューから手動で更新を実行することもできます:

-

前前回の翻訳 ( lubuntu-upgrader の修正)が完了していれば:

メニュー →設定 →「すべてのアップグレードの適用」→下記の画面が表示。

f:id:FuRuYa7:20200515005324j:plain

-


「アップデートの通知」の処理の流れ:

1. 自動起動:

名称: upgNotifier

コマンド:
/usr/lib/lubuntu-update-notifier/lubuntu-upg-notifier.sh

-

2. /usr/lib/update-notifier/apt-check.py

→(3600秒: 1時間ごとにチェック)

国際化対応されています。

: 前回 (H48)に、pot 再作成して翻訳し直し。翻訳されるメッセージが増えたぐらい。

-

3. /usr/lib/lubuntu-update-notifier/lubuntu-notifier.py

→ 国際化されてません。

(今回の翻訳対象: lubuntu-notifier.py)

-

4. 「Update Notifier」ダイアログ表示

→今回の翻訳で、日本語化される「アップデートの通知」画面です。

-

5. /usr/bin/lubuntu-upgrader

→ 国際化されてません。

: 前前回 (H47)に、翻訳した「すべてのアップグレード」

-


lubuntu-upg-notifier.sh の内容:

$ cat /usr/lib/lubuntu-update-notifier/lubuntu-upg-notifier.sh

抜粋:

↓ライセンスの表示:

#!/bin/sh
# coding=utf-8

# Copyright (C) 2019 Hans P. Möller <hmollercl@lubuntu.me>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
while true;
    do
        OUT=`/usr/lib/update-notifier/apt-check 2>&1`
        #echo $OUT
        oldIFS=$IFS
        IFS=';'
        j=0
        for STRING in $OUT; do
            case $j in
                0)
                    UPG=$STRING;;
                1)
                    SEC=$STRING;;
            esac                                                                                       
             j=`expr $j + 1`                                                                           
        done                                                                                           
        IFS=$oldIFS                                                                                    
        /usr/lib/lubuntu-update-notifier/lubuntu-notifier.py -u $UPG -s $SEC -p /usr/bin/lubuntu-upgrader                                                                                                     
        sleep 3600                                                                                     
done;

-

$ ls -l /usr/lib/update-notifier/                                                         
: 
-rwxr-xr-x 1 root root  2444  4月  2 20:25 apt-cdrom-check                                             
lrwxrwxrwx 1 root root    12  4月  2 20:25 apt-check -> apt_check.py                                   
-rwxr-xr-x 1 root root 12354  4月  2 20:25 apt_check.py
-rwxr-xr-x 1 root root  4848  4月  2 20:25 backend_helper.py
-rwxr-xr-x 1 root root   619  4月  2 20:25 cddistupgrader
-rwxr-xr-x 1 root root 12112  4月  2 20:25 package-data-downloader
-rwxr-xr-x 1 root root   358  4月  2 20:25 package-system-locked
-rwxr-xr-x 1 root root  2853  4月  2 20:25 update-motd-fsck-at-reboot
-rwxr-xr-x 1 root root  1857  4月  2 20:25 update-motd-hwe-eol
-rwxr-xr-x 1 root root   115  4月  2 20:25 update-motd-reboot-required
-rwxr-xr-x 1 root root  1502  4月  2 20:25 update-motd-updates-available

-


apt_check.py の内容:

$ cat /usr/lib/update-notifier/apt_check.py

国際化には、gettext が使われています。python の国際化の参考にできそうです。

→現在の翻訳ファイルに反映されていない、未翻訳の追加されたメッセージ(ESM 関連)が見受けられます。

抜粋:

import gettext

def _(msg):
    return gettext.dgettext("update-notifier", msg)

def _handleException(type, value, tb):
    sys.stderr.write("E: " + _("Unknown Error: '%s' (%s)") % (type, value))
    sys.exit(-1)

:

def write_human_readable_summary(outstream, upgrades, security_updates,
                                 esm_updates, have_esm, disabled_esm_updates):
    " write out human summary summary to outstream "
    if have_esm is not None:
        if have_esm:
            outstream.write(gettext.dgettext("update-notifier",
                                             "UA Infrastructure Extended "
                                             "Security Maintenance (ESM) is "
                                             "enabled."))
        else:
            outstream.write(gettext.dgettext("update-notifier",
                                             "UA Infrastructure Extended "
                                             "Security Maintenance (ESM) is "
                                             "not enabled."))
        outstream.write("\n\n")

:

if __name__ == "__main__":
    # setup a exception handler to make sure that uncaught stuff goes
    # to the notifier
    sys.excepthook = _handleException

    # gettext
    APP = "update-notifier"
    DIR = "/usr/share/locale"
    gettext.bindtextdomain(APP, DIR)
    gettext.textdomain(APP)

:

    (options, args) = parser.parse_args()

    # run it
    init()
    run(options)

→表示するのに「 outstream.write() 」が使われていて、国際化のマーク「 gettext.dgettext( ) 」も違います。

-


lubuntu-notifier.py の内容:

$ cat /usr/lib/lubuntu-update-notifier/lubuntu-notifier.py

→国際化対応されていません。

抜粋:

↓ライセンスの表示:

#!/usr/bin/python3
# coding=utf-8

# Copyright (C) 2019 Hans P. Möller <hmollercl@lubuntu.me>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

-

''' Open Notification Dialog to enable upgrade'''

和訳: 通知ダイアログを開いてアップグレードを有効にします。

やっと、翻訳したいターゲットを見つけました:

        if self.upgrades > 0:
            text = "There are upgrades available. Do you want to do a system"
            text += " upgrade?\nThis will mean packages could be upgraded,"
            text += " installed, or removed."

-


「lubuntu-notifier.py」の日本語化

プログラムは「Python 3」スクリプトで書かれています。国際化されていません。翻訳するなら、プログラムの更新があることを考えるとプログラムを国際化に対応させて(他の国の人も)翻訳しやすくするのがベターです。自分で国際化対応にするなら上記の「/usr/lib/update-notifier/apt_check.py」が参考になりそうです。ですが、python のスキル不足です。

主な表示を直接、日本語に翻訳してみました。(禁じ手かな)

-


1. 原本の退避:

$ cd /usr/lib/lubuntu-update-notifier/
$ sudo cp lubuntu-notifier.py lubuntu-notifier.py-ORG

$ ls -l /usr/lib/lubuntu-update-notifier/
:
drwxr-xr-x 2 root root 4096  4月 23 16:37 __pycache__
-rwxr-xr-x 1 root root 5961  8月 23  2019 lubuntu-notifier.py
-rwxr-xr-x 1 root root 5961  5月 13 21:11 lubuntu-notifier.py-ORG
-rwxr-xr-x 1 root root 1231  8月 23  2019 lubuntu-upg-notifier.sh

-


2. 翻訳作業:

$ cd /usr/lib/lubuntu-update-notifier/
$ cp lubuntu-notifier.py ~/ダウンロード/翻訳/lubuntu-notifier_ja.py

$ featherpad ~/ダウンロード/翻訳/lubuntu-notifier_ja.py

→動作に支障が出ないように、下記のように安全と思われる部分だけを翻訳しました。

-


Title( 」で検索:
  • self.set*Title('*')」はタイトル名なので翻訳。
69行:
        self.setWindowTitle("Update Notifier")
↓
        self.setWindowTitle("アップデートの通知")

-


text = 」で検索:
  • text =」の行は文字列の代入文なので翻訳。
73行:
            text = "There are upgrades available. Do you want to do a system"
            text += " upgrade?\nThis will mean packages could be upgraded,"
            text += " installed, or removed."

↓
            text = "利用可能なアップグレードがあります。"
            text += "システムのアップグレードを行いますか? \nパッケージ"
            text += "をアップグレード、インストール、または削除できます。"

-

78行:
            if text == "":
                text = "Reboot is needed"
                self.upgradeBtn.setVisible(False)
            else:
                text = text + "\nReboot is needed"
↓
            if text == "":
                text = "再起動が必要です"
                self.upgradeBtn.setVisible(False)
            else:
                text = text + "\n再起動が必要です"

-

116行:
            text = "Upgrade finished"
↓
            text = "アップグレードが完了しました"

-

120行:
                text = text + "\n" + "Restart required"
↓
                text = text + "\n" + "再起動が必要です"

-


" 」で検索:
  • 「""」で囲った文字列は翻訳。
50行:
        self.upgradeBtn = QPushButton("Upgrade")
        self.closeBtn = QPushButton("Close")
↓
        self.upgradeBtn = QPushButton("アップグレード")
        self.closeBtn = QPushButton("閉じる")

-

101行:
        self.label.setText("Upgrading...")
↓
        self.label.setText("アップグレードしています...")

-

152行:
                        help="Define software/app to open for upgrade",
↓
                        help="アップグレードのために開くソフトウェア/アプリを定義します",

-

157行:
                        help="How many upgrades are available",
↓
                        help="利用可能なアップグレードの数",

-

162行:
                        help="How many security upgrades are available",
↓
                        help="利用可能なセキュリティアップグレードの数",

-


3. 反映:

スクリプトなのでコピーするだけです。

$ cd /usr/lib/lubuntu-update-notifier/
$ sudo cp ~/ダウンロード/翻訳/lubuntu-notifier_ja.py lubuntu-notifier.py

-


4. 確認:

再起動

作業中に、システム更新の通知があったら、システム更新せずに閉じておきます。そうすれば、再起動してすぐか、 1時間ほどで通知のダイアログが表示されると思います。

lubuntu-upg-notifier.sh にある「sleep 3600」を修正することで、確認周期を短く出来ますが、肝心の更新がないと確認できないので、どちらにしても放っておくしかありません。なので触らないほうが良さそう。

→日本語化されていることを確認。

-

動作が確認できたので、次のプログラム更新に備えコピーしました:

$ cd /usr/lib/lubuntu-update-notifier/
$ sudo cp ~/ダウンロード/翻訳/lubuntu-notifier_ja.py lubuntu-notifier_ja.py

$ ls -l /usr/lib/lubuntu-update-notifier/
:
drwxr-xr-x 2 root root 4096  4月 23 16:37 __pycache__
-rwxr-xr-x 1 root root 6220  5月 13 22:06 lubuntu-notifier.py
-rwxr-xr-x 1 root root 5961  5月 13 21:11 lubuntu-notifier.py-ORG
-rwxr-xr-x 1 root root 6220  5月 13 22:22 lubuntu-notifier_ja.py
-rwxr-xr-x 1 root root 1231  8月 23  2019 lubuntu-upg-notifier.sh

→lubuntu-notifier.py_ja のサイズ(6220) に着目。lubuntu-notifier.py のサイズが変わったら、更新された合図です。 その場合は、コピーで戻すのでなく参考にしての修正を行います。修正しやすいように差分を表示させました。

-


ファイルの差分表示:

$ cat /usr/lib/lubuntu-update-notifier/lubuntu-notifier_ja.py

先頭のライセンス部分を表示しておきます:

#!/usr/bin/python3
# coding=utf-8

# Copyright (C) 2019 Hans P. Möller <hmollercl@lubuntu.me>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

差分表示:

$ cd /usr/lib/lubuntu-update-notifier/
$ diff lubuntu-notifier.py-ORG lubuntu-notifier_ja.py

50,51c50,51
<         self.upgradeBtn = QPushButton("Upgrade")
<         self.closeBtn = QPushButton("Close")
---
>         self.upgradeBtn = QPushButton("アップグレード")
>         self.closeBtn = QPushButton("閉じる")
69c69
<         self.setWindowTitle("Update Notifier")
---
>         self.setWindowTitle("アップデートの通知")
73,75c73,75
<             text = "There are upgrades available. Do you want to do a system"
<             text += " upgrade?\nThis will mean packages could be upgraded,"
<             text += " installed, or removed."
---
>             text = "利用可能なアップグレードがあります。"
>             text += "システムのアップグレードを行いますか? \nパッケージ"
>             text += "をアップグレード、インストール、または削除できます。"
79c79
<                 text = "Reboot is needed"
---
>                 text = "再起動が必要です"
82c82
<                 text = text + "\nReboot is needed"
---
>                 text = text + "\n再起動が必要です"
101c101
<         self.label.setText("Upgrading...")
---
>         self.label.setText("アップグレードしています...")
116c116
<             text = "Upgrade finished"
---
>             text = "アップグレードが完了しました"
120c120
<                 text = text + "\n" + "Restart required"
---
>                 text = text + "\n" + "再起動が必要です"
152c152
<                         help="Define software/app to open for upgrade",
---
>                         help="アップグレードのために開くソフトウェア/アプリを定義します",
157c157
<                         help="How many upgrades are available",
---
>                         help="利用可能なアップグレードの数",
162c162
<                         help="How many security upgrades are available",
---
>                         help="利用可能なセキュリティアップグレードの数",

-

  • 差分の見方:
50,51c50,51  ←(左側: 50〜51行が、右側: 50〜51行に変更されています )
<         self.upgradeBtn = QPushButton("Upgrade")  ←(左側: 変更前)
<         self.closeBtn = QPushButton("Close")    ←(左側: 変更前)
---
>         self.upgradeBtn = QPushButton("アップグレード")   →(右側: 変更後)
>         self.closeBtn = QPushButton("閉じる")        →(右側: 変更後)

→左側: lubuntu-notifier.py-ORG(原本)、右側: lubuntu-notifier_ja.py(翻訳)

-


まとめ

前前回の「Apply Full Upgrade」(すべてのアップグレードの適用)アプリと、今回の「Update Notifier」(アップデートの通知)の日本語化にて、システム更新関連の表示が日本語化され、わかりやすくなりました。今のところ、支障ありません。何かあっても、自己責任です。

早くアプリが国際化に対応して、翻訳が楽になるといいですね。自分はまだ力が足りず、学習が必要です。

-

-


目次

先頭

-


-